Simple C Expat Wrapper (SCEW)  1.1.7
Files | Functions
Hierarchy

Handle element's hierarchy. More...

Files

file  element.h
 SCEW element's handling routines.
 

Functions

SCEW_API unsigned int scew_element_count (scew_element const *element)
 Returns the number of children of the specified element. More...
 
SCEW_API scew_elementscew_element_parent (scew_element const *element)
 Returns the parent of the given element. More...
 
SCEW_API scew_listscew_element_children (scew_element const *element)
 Returns the list of all the element's children. More...
 
SCEW_API scew_elementscew_element_add (scew_element *element, XML_Char const *name)
 Creates and adds, as a child of element, a new element with the given name. More...
 
SCEW_API scew_elementscew_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. More...
 
SCEW_API scew_elementscew_element_add_element (scew_element *element, scew_element *child)
 Adds a child to the given element. More...
 
SCEW_API void scew_element_delete_all (scew_element *element)
 Deletes all the children for the given element. More...
 
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. More...
 
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. More...
 
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. More...
 
SCEW_API void scew_element_detach (scew_element *element)
 Detaches the given element from its parent, if any. More...
 

Detailed Description

Handle element's hierarchy.

Function Documentation

SCEW_API unsigned int scew_element_count ( scew_element const *  element)

Returns the number of children of the specified element.

An element can have zero or more children.

Precondition
element != NULL
Returns
the number of children, or 0 if the element has no children.
SCEW_API scew_element* scew_element_parent ( scew_element const *  element)

Returns the parent of the given element.

Precondition
element != NULL
Returns
the element's parent, or NULL if the given element has no parent (e.g. root element).
SCEW_API scew_list* scew_element_children ( scew_element const *  element)

Returns the list of all the element's children.

This is the internal list where element's children are stored, so no modifications or deletions should be performed on this list.

Precondition
element != NULL
Returns
the list of the given element's children, or NULL if the element has no children.
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.

Precondition
element != NULL
name != NULL
Returns
the new created element, or NULL if an error is found.
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.

Precondition
element != NULL
name != NULL
contents != NULL
Returns
the new created element, or NULL if an error is found.
SCEW_API scew_element* scew_element_add_element ( scew_element element,
scew_element child 
)

Adds a child to the given element.

Note that the element being added should be a clean element, that is, an element created with scew_element_create or an element detached from another tree after being detached (via scew_element_detach).

Precondition
element != NULL
child != NULL
scew_element_parent (child) == NULL
Returns
the element being added, or NULL if the element could not be added.
SCEW_API void scew_element_delete_all ( scew_element element)

Deletes all the children for the given element.

This function deletes all subchildren recursively. This will automatically free the elements.

Precondition
element != NULL
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.

This will automatically free the element.

Precondition
element != NULL
name != NULL
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.

This will automatically free the element.

Precondition
element != NULL
name != NULL
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.

This will automatically free the element.

Precondition
element != NULL
index < scew_element_count
SCEW_API void scew_element_detach ( scew_element element)

Detaches the given element from its parent, if any.

This function only detaches the element, but does not free it. If the element has no parent, this function does not have any effect.

Precondition
element != NULL