Add missing files
[gmpc-magnatune.git] / src / axl / axl_node.h
blob8f69fd656d2dae266f54cec59a7b857e0aeb0c61
1 /**
2 * LibAxl: Another XML library
3 * Copyright (C) 2006 Advanced Software Production Line, S.L.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 * 02111-1307 USA
20 * You may find a copy of the license under this software is released
21 * at COPYING file. This is LGPL software: you are welcome to
22 * develop proprietary applications using this library without any
23 * royalty or fee but returning back any change, improvement or
24 * addition in the form of source code, project image, documentation
25 * patches, etc.
27 * For commercial support on build XML enabled solutions contact us:
29 * Postal address:
30 * Advanced Software Production Line, S.L.
31 * C/ Dr. Michavila NÂș 14
32 * Coslada 28820 Madrid
33 * Spain
35 * Email address:
36 * info@aspl.es - http://fact.aspl.es
38 #ifndef __AXL_NODE_H__
39 #define __AXL_NODE_H__
41 #include <axl_decl.h>
43 BEGIN_C_DECLS
45 /**
46 * \addtogroup axl_node_module
47 * @{
50 axlNode * axl_node_create (const char * name);
52 axlNode * axl_node_create_ref (char * name);
54 axlNode * axl_node_parse_strings (axlError ** error, ...);
56 axlNode * axl_node_parse (axlError ** error, const char * content, ...);
58 void axl_node_set_name (axlNode * node,
59 const char * name);
61 void axl_node_set_name_ref (axlNode * node,
62 char * name);
64 void axl_node_set_name_from_factory (axlNode * node,
65 char * name);
67 axlNode * axl_node_copy (axlNode * node,
68 bool copy_attributes,
69 bool copy_childs);
71 axlDoc * axl_node_get_doc (axlNode * node);
73 void axl_node_set_doc (axlNode * node,
74 axlDoc * doc);
76 void axl_node_set_attribute (axlNode * node,
77 const char * attribute,
78 const char * value);
80 void axl_node_set_attribute_ref (axlNode * node,
81 char * attribute,
82 char * value);
84 void axl_node_set_attribute_from_factory (axlFactory * factory,
85 axlNode * node,
86 char * attribute,
87 char * value);
89 /**
90 * @brief Macro definition which works as an alias for \ref
91 * axl_node_get_attribute_value.
93 * @param node The node being checked to have an attribute value.
94 * @param attr The attribute that is being check to be present in the node provided.
96 * @return \ref true if the node has the provided attribute, otherwise
97 * \ref false is returned.
99 #define HAS_ATTR(node,attr) axl_node_has_attribute(node,attr)
101 bool axl_node_has_attribute (axlNode * node,
102 const char * attribute);
104 void axl_node_remove_attribute (axlNode * node,
105 const char * attribute);
107 int axl_node_num_attributes (axlNode * node);
110 /**
111 * @brief Macro definition, which works as an alias for \ref
112 * axl_node_get_attribute_value.
114 * @param node The node that is being required to return the content
115 * of a particular node.
117 * @param attr The attribute that is requested.
119 * @return The value assocaited to the attribute value or null if it
120 * fails. See \ref axl_node_get_attribute_value.
122 #define ATTR_VALUE(node,attr) axl_node_get_attribute_value(node, attr)
124 const char * axl_node_get_attribute_value (axlNode * node,
125 const char * attribute);
127 char * axl_node_get_attribute_value_copy (axlNode * node,
128 const char * attribute);
130 /**
131 * @brief Simple alias definition to \ref axl_node_get_attribute_value_trans function.
133 * @param node The node which contains the attribute requested.
135 * @param attr The attribute key that is being requested.
137 * @return A newly allocated string containing the attribute value,
138 * with known entity references translated.
140 #define ATTR_VALUE_TRANS(node,attr) axl_node_get_attribute_value_trans(node,attr)
142 char * axl_node_get_attribute_value_trans (axlNode * node,
143 const char * attribute);
145 /**
146 * @brief Allows to get the value associated to the attributed
147 * provided, inside the node selected, removing trailing and ending
148 * white spaces (in the W3C sence: \\n, \\t, \\r, ' ').
150 * This is a macro alias to \ref axl_node_get_attribute_value_trimmed.
152 * @param node The node that is requested to return the associated
153 * value to the attributed.
155 * @param attr The attribute that is being requested.
157 * @return A reference to the attribute value or NULL if it fails.
159 #define ATTR_VALUE_TRIMMED(node,attr) axl_node_get_attribute_value_trimmed(node,attr)
161 const char * axl_node_get_attribute_value_trimmed (axlNode * node,
162 const char * attribute);
165 * @brief Convenience macro wrapping \ref
166 * axl_node_has_attribute_value.
168 #define HAS_ATTR_VALUE(node, attr,value) (axl_node_has_attribute_value (node, attr, value))
170 bool axl_node_has_attribute_value (axlNode * node,
171 const char * attribute,
172 const char * value);
174 bool axl_node_has_attributes (axlNode * node);
177 * @}
180 /**
181 * \addtogroup axl_node_attribute_cursor
182 * @{
185 /* XML node attribute iteration API provided to traverse all
186 * attributes without knowing them. */
187 axlAttrCursor * axl_node_attr_cursor_new (axlNode * node);
189 void axl_node_attr_cursor_first (axlAttrCursor * cursor);
191 void axl_node_attr_cursor_next (axlAttrCursor * cursor);
193 bool axl_node_attr_cursor_has_next (axlAttrCursor * cursor);
195 bool axl_node_attr_cursor_has_item (axlAttrCursor * cursor);
197 const char * axl_node_attr_cursor_get_key (axlAttrCursor * cursor);
199 const char * axl_node_attr_cursor_get_value (axlAttrCursor * cursor);
201 void axl_node_attr_cursor_free (axlAttrCursor * cursor);
203 void axl_node_attr_foreach (axlNode * node,
204 axlNodeAttrForeachFunc func,
205 axlPointer data,
206 axlPointer data2);
210 * @}
213 /**
214 * \addtogroup axl_node_annotate
215 * @{
218 void axl_node_annotate_data (axlNode * node,
219 const char * key,
220 axlPointer data);
222 void axl_node_annotate_data_full (axlNode * node,
223 const char * key,
224 axlDestroyFunc key_destroy,
225 axlPointer data,
226 axlDestroyFunc data_destroy);
228 axlPointer axl_node_annotate_get (axlNode * node,
229 const char * key,
230 bool lookup_in_parent);
232 void axl_node_annotate_int (axlNode * node,
233 const char * key,
234 int int_value);
236 void axl_node_annotate_string (axlNode * node,
237 const char * key,
238 const char * string_value);
240 void axl_node_annotate_double (axlNode * node,
241 const char * key,
242 double double_value);
244 int axl_node_annotate_get_int (axlNode * node,
245 const char * key,
246 bool lookup_in_parent);
248 char * axl_node_annotate_get_string (axlNode * node,
249 const char * key,
250 bool lookup_in_parent);
252 double axl_node_annotate_get_double (axlNode * node,
253 const char * key,
254 bool lookup_in_parent);
257 * @}
261 /**
262 * \addtogroup axl_node_module
263 * @{
266 /**
267 * @brief Allows to easily check that the given xml node (\ref
268 * axlNode) have the provided name.
270 * This macro is provided as a convenience to check that a particular
271 * node have a particular name. Check the documentation that this
272 * macro is wrapping to get examples: \ref axl_node_get_name.
274 * <i><b>NOTE:</b> This function isn't XML Namespace aware. You must use \ref axl_ns_node_cmp instead. See \ref axl_ns_doc_validate. </i>
276 * @param node The \ref axlNode where the name will be compared with
277 * the provided value.
279 * @param name The name to compare.
281 * @return \ref true if names are equal or \ref false if not.
283 #define NODE_CMP_NAME(node,name) (axl_cmp ((node != NULL) ? axl_node_get_name(node) : "><", (name != NULL) ? name : "<>"))
285 const char * axl_node_get_name (axlNode * node);
287 axlNode * axl_node_get_parent (axlNode * node);
289 axlNode * axl_node_get_next (axlNode * node);
291 axlNode * axl_node_get_next_called (axlNode * node,
292 char * name);
294 axlNode * axl_node_get_previous (axlNode * node);
296 axlNode * axl_node_get_previous_called (axlNode * node,
297 char * name);
299 axlNode * axl_node_get_first_child (axlNode * node);
301 axlNode * axl_node_get_last_child (axlNode * node);
303 void axl_node_set_child (axlNode * parent,
304 axlNode * child);
306 void axl_node_set_child_after (axlNode * reference,
307 axlNode * child);
309 void axl_node_replace (axlNode * node,
310 axlNode * new_node,
311 bool dealloc);
313 void axl_node_remove (axlNode * node,
314 bool dealloc);
316 void axl_node_deattach (axlNode * node);
319 void axl_node_set_is_empty (axlNode * node,
320 bool empty);
322 bool axl_node_is_empty (axlNode * node);
324 const char * axl_node_get_content (axlNode * node,
325 int * content_size);
327 char * axl_node_get_content_copy (axlNode * node,
328 int * content_size);
330 char * axl_node_get_content_trans (axlNode * node,
331 int * content_size);
333 char * axl_node_get_content_trim (axlNode * node,
334 int * content_size);
336 void axl_node_set_content (axlNode * node,
337 const char * content,
338 int content_size);
340 void axl_node_set_content_ref (axlNode * node,
341 char * content,
342 int content_size);
344 void axl_node_set_content_from_factory (axlFactory * factory,
345 axlNode * node,
346 char * content,
347 int content_size);
349 void axl_node_set_cdata_content (axlNode * node,
350 char * content,
351 int content_size);
353 void axl_node_set_cdata_content_from_factory (axlFactory * factory,
354 axlNode * node,
355 char * content,
356 int content_size);
358 void axl_node_set_comment (axlNode * node,
359 char * comment,
360 int comment_size);
362 void axl_node_set_have_childs (axlNode * node, bool childs);
364 bool axl_node_have_childs (axlNode * node);
366 axlNode * axl_node_get_child_called (axlNode * parent, char * name);
368 axlNode * axl_node_find_called (axlNode * parent, char * name);
370 axlNode * axl_node_get_child_nth (axlNode * parent, int position);
372 int axl_node_get_child_num (axlNode * parent);
374 axlList * axl_node_get_childs (axlNode * node);
376 bool axl_node_are_equal (axlNode * node, axlNode * node2);
378 void axl_node_add_pi_target (axlNode * node,
379 char * target,
380 char * content);
382 bool axl_node_has_pi_target (axlNode * node,
383 char * pi_target);
385 char * axl_node_get_pi_target_content (axlNode * node,
386 char * pi_target);
388 axlList * axl_node_get_pi_target_list (axlNode * node);
390 void axl_node_transfer_childs (axlNode * old_parent,
391 axlNode * new_parent);
393 bool axl_node_dump (axlNode * node,
394 char ** content,
395 int * size);
397 bool axl_node_dump_pretty (axlNode * node,
398 char ** content,
399 int * size,
400 int tabular);
402 bool axl_node_dump_to_file (axlNode * node,
403 char * file_path);
405 bool axl_node_dump_pretty_to_file (axlNode * node,
406 char * file_path,
407 int tabular);
409 int axl_node_get_flat_size (axlNode * node,
410 bool pretty_print,
411 int level,
412 int tabular);
414 int axl_node_dump_at (axlNode * node,
415 char * content,
416 int desp,
417 bool pretty_print,
418 int level,
419 int tabular);
421 bool axl_node_has_invalid_chars (const char * content,
422 int content_size,
423 int * added_size);
425 char * axl_node_content_copy_and_escape (const char * content,
426 int content_size,
427 int additional_size);
429 void axl_node_free (axlNode * node);
431 void axl_node_free_full (axlNode * node, bool also_childs);
433 /* @} */
435 /* item interface */
437 axlItem * axl_item_new (AxlItemType type,
438 axlPointer data);
440 axlItem * axl_item_new_ref (AxlItemType type,
441 axlPointer data);
443 axlDoc * axl_item_get_doc (axlItem * item);
445 void axl_item_set_doc (axlItem * item, axlDoc * doc);
447 axlNode * axl_item_get_parent (axlItem * item);
449 axlItem * axl_item_get_next (axlItem * item);
451 axlItem * axl_item_node_next (axlNode * node);
453 axlItem * axl_item_get_previous (axlItem * item);
455 axlItem * axl_item_node_previous (axlNode * node);
457 axlItem * axl_item_node_holder (axlNode * node);
459 axlItem * axl_item_get_first_child (axlNode * node);
461 axlItem * axl_item_get_last_child (axlNode * node);
463 AxlItemType axl_item_get_type (axlItem * item);
465 axlPointer axl_item_get_data (axlItem * item);
467 char * axl_item_get_content (axlItem * item,
468 int * size);
470 void axl_item_set_child (axlNode * parent,
471 AxlItemType type,
472 axlPointer data);
474 void axl_item_set_child_ref (axlNode * parent,
475 axlItem * item);
477 void axl_item_set_after (axlItem * item,
478 AxlItemType type,
479 axlPointer data);
481 axlItem * axl_item_copy (axlItem * item,
482 axlNode * set_parent);
484 void axl_item_remove (axlItem * item,
485 bool dealloc);
487 void axl_item_replace (axlItem * item,
488 axlItem * new_item,
489 bool dealloc);
491 void axl_item_transfer_childs_after (axlNode * old_parent,
492 axlItem * item_ref);
494 bool axl_item_are_equal (axlItem * item,
495 axlItem * item2,
496 bool trimmed);
498 void axl_item_free (axlItem * item,
499 bool dealloc);
501 axlFactory * axl_item_factory_create ();
503 axlItem * axl_item_factory_get (axlFactory * factory);
505 axlFactory * axl_node_factory_create ();
507 axlNode * axl_node_factory_get (axlFactory * factory);
509 axlFactory * axl_item_content_factory_create ();
511 axlFactory * axl_item_attr_factory_create ();
513 END_C_DECLS
515 #endif