Simple C Expat Wrapper (SCEW)  1.1.7
element.h
Go to the documentation of this file.
1 
38 #ifndef ELEMENT_H_0211250048
39 #define ELEMENT_H_0211250048
40 
41 #include "export.h"
42 
43 #include "list.h"
44 
45 #include <expat.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif /* __cplusplus */
50 
56 typedef struct scew_element scew_element;
57 
64 
77  scew_element const *);
78 
79 
96 extern SCEW_API scew_element* scew_element_create (XML_Char const *name);
97 
109 extern SCEW_API scew_element* scew_element_copy (scew_element const *element);
110 
119 extern SCEW_API void scew_element_free (scew_element *element);
120 
121 
140 extern SCEW_API scew_element*
141 scew_element_by_name (scew_element const *element, XML_Char const *name);
142 
155 extern SCEW_API scew_element*
156 scew_element_by_index (scew_element const *element, unsigned int index);
157 
172 extern SCEW_API scew_list*
173 scew_element_list_by_name (scew_element const *element, XML_Char const *name);
174 
175 
213 extern SCEW_API scew_bool scew_element_compare (scew_element const *a,
214  scew_element const *b,
215  scew_element_cmp_hook hook);
216 
217 
234 extern SCEW_API XML_Char const*
235 scew_element_name (scew_element const *element);
236 
248 extern SCEW_API XML_Char const*
249 scew_element_contents (scew_element const *element);
250 
263 extern SCEW_API XML_Char const* scew_element_set_name (scew_element *element,
264  XML_Char const *name);
265 
277 extern SCEW_API XML_Char const*
278 scew_element_set_contents (scew_element *element, XML_Char const *contents);
279 
288 extern SCEW_API void scew_element_free_contents (scew_element *element);
289 
290 
308 extern SCEW_API unsigned int scew_element_count (scew_element const *element);
309 
320 extern SCEW_API scew_element*
321 scew_element_parent (scew_element const *element);
322 
335 extern SCEW_API scew_list* scew_element_children (scew_element const *element);
336 
348 extern SCEW_API scew_element* scew_element_add (scew_element *element,
349  XML_Char const *name);
350 
363 extern SCEW_API scew_element* scew_element_add_pair (scew_element *element,
364  XML_Char const *name,
365  XML_Char const *contents);
366 
382 extern SCEW_API scew_element* scew_element_add_element (scew_element *element,
383  scew_element *child);
384 
394 extern SCEW_API void scew_element_delete_all (scew_element *element);
395 
405 extern SCEW_API void scew_element_delete_all_by_name (scew_element *element,
406  XML_Char const *name);
407 
417 extern SCEW_API void scew_element_delete_by_name (scew_element *element,
418  XML_Char const *name);
419 
429 extern SCEW_API void scew_element_delete_by_index (scew_element *element,
430  unsigned int index);
431 
441 extern SCEW_API void scew_element_detach (scew_element *element);
442 
443 
458 extern SCEW_API unsigned int
459 scew_element_attribute_count (scew_element const *element);
460 
472 extern SCEW_API scew_list*
473 scew_element_attributes (scew_element const *element);
474 
486 extern SCEW_API scew_attribute*
487 scew_element_attribute_by_name (scew_element const *element,
488  XML_Char const *name);
489 
502 extern SCEW_API scew_attribute*
503 scew_element_attribute_by_index (scew_element const *element,
504  unsigned int index);
505 
524 extern SCEW_API scew_attribute*
525 scew_element_add_attribute (scew_element *element, scew_attribute *attribute);
526 
544 extern SCEW_API scew_attribute*
545 scew_element_add_attribute_pair (scew_element *element,
546  XML_Char const *name,
547  XML_Char const *value);
548 
557 extern SCEW_API void scew_element_delete_attribute_all (scew_element *element);
558 
568 extern SCEW_API void scew_element_delete_attribute (scew_element *element,
569  scew_attribute *attribute);
570 
580 extern SCEW_API void
581 scew_element_delete_attribute_by_name (scew_element *element,
582  XML_Char const* name);
583 
594 extern SCEW_API void
595 scew_element_delete_attribute_by_index (scew_element *element,
596  unsigned int index);
597 
598 #ifdef __cplusplus
599 }
600 #endif /* __cplusplus */
601 
602 #endif /* ELEMENT_H_0211250048 */
SCEW_API scew_element * scew_element_create(XML_Char const *name)
Creates a new element with the given name.
SCEW_API void scew_element_delete_attribute_by_index(scew_element *element, unsigned int index)
Deletes the attribute of the given element at the specified zero-based index.
SCEW_API unsigned int scew_element_count(scew_element const *element)
Returns the number of children of the specified element.
SCEW_API XML_Char const * scew_element_name(scew_element const *element)
Returns the given element's name.
SCEW_API scew_list * scew_element_list_by_name(scew_element const *element, XML_Char const *name)
Returns a list of children from the specified element that matches the given name.
SCEW shared library support.
SCEW_API void scew_element_free(scew_element *element)
Frees the given element recursively.
SCEW_API scew_list * scew_element_attributes(scew_element const *element)
Returns the list of all the element's attributes.
struct scew_list scew_list
This is the type delcaration for SCEW lists.
Definition: list.h:55
SCEW_API void scew_element_delete_all_by_name(scew_element *element, XML_Char const *name)
Deletes all the children of the given element that matches name.
SCEW_API XML_Char const * scew_element_set_name(scew_element *element, XML_Char const *name)
Sets a new name to the given element and frees the old one.
SCEW_API void scew_element_free_contents(scew_element *element)
Frees the current contents of the given element.
SCEW_API scew_attribute * scew_element_add_attribute(scew_element *element, scew_attribute *attribute)
Adds an existent attribute to the given element.
scew_bool(* scew_element_cmp_hook)(scew_element const *, scew_element const *)
SCEW element compare hooks might be used to define new user XML element comparisons.
Definition: element.h:76
unsigned char scew_bool
This should be defined using stdbool.h when C99 is available.
Definition: bool.h:35
SCEW_API scew_element * scew_element_parent(scew_element const *element)
Returns the parent of the given element.
SCEW_API void scew_element_delete_attribute_by_name(scew_element *element, XML_Char const *name)
Deletes the first attribute of the given element that matches name.
struct scew_attribute scew_attribute
This is the type declaration for SCEW attributes.
Definition: element.h:63
SCEW_API XML_Char const * scew_element_contents(scew_element const *element)
Returns the given element's contents.
SCEW_API XML_Char const * scew_element_set_contents(scew_element *element, XML_Char const *contents)
Sets a new contents to the given element and frees the old one.
SCEW_API scew_element * scew_element_add(scew_element *element, XML_Char const *name)
Creates and adds, as a child of element, a new element with the given name.
SCEW_API scew_element * scew_element_add_element(scew_element *element, scew_element *child)
Adds a child to the given element.
SCEW_API scew_bool scew_element_compare(scew_element const *a, scew_element const *b, scew_element_cmp_hook hook)
Performs a deep comparison of the two given elements.
SCEW_API scew_attribute * scew_element_attribute_by_name(scew_element const *element, XML_Char const *name)
Returns the first attribute from the specified element that matches the given name.
SCEW general list implementation.
SCEW_API void scew_element_delete_by_index(scew_element *element, unsigned int index)
Deletes the child of the given element at the specified zero-based index.
SCEW_API scew_list * scew_element_children(scew_element const *element)
Returns the list of all the element's children.
SCEW_API scew_element * scew_element_copy(scew_element const *element)
Makes a deep copy of the given element.
SCEW_API void scew_element_delete_attribute(scew_element *element, scew_attribute *attribute)
Deletes the given attribute from the specified element.
SCEW_API void scew_element_delete_all(scew_element *element)
Deletes all the children for the given element.
SCEW_API void scew_element_delete_attribute_all(scew_element *element)
Deletes all the attributes of the given element.
SCEW_API void scew_element_delete_by_name(scew_element *element, XML_Char const *name)
Deletes the first child of the given element that matches name.
SCEW_API void scew_element_detach(scew_element *element)
Detaches the given element from its parent, if any.
SCEW_API scew_element * scew_element_by_name(scew_element const *element, XML_Char const *name)
Returns the first child from the specified element that matches the given name.
struct scew_element scew_element
This is the type delcaration for SCEW elements.
Definition: element.h:56
SCEW_API scew_attribute * scew_element_add_attribute_pair(scew_element *element, XML_Char const *name, XML_Char const *value)
Creates and adds a new attribute to the given element.
SCEW_API scew_element * scew_element_add_pair(scew_element *element, XML_Char const *name, XML_Char const *contents)
Creates and adds, as a child of element, a new element with the given name and contents.
SCEW_API scew_element * scew_element_by_index(scew_element const *element, unsigned int index)
Returns the child of the given element at the specified zero-based index.
SCEW_API unsigned int scew_element_attribute_count(scew_element const *element)
Returns the number of attributes of the given element.
SCEW_API scew_attribute * scew_element_attribute_by_index(scew_element const *element, unsigned int index)
Returns the attribute of the given element at the specified zero-based index.