YAGE  v0.1.1
Yet Another Game Engine
rapidxml::xml_node< Ch > Class Template Reference

Class representing a node of XML document. Each node may have associated name and value strings, which are available through name() and value() functions. Interpretation of name and value depends on type of the node. Type of node can be determined by using type() function.

Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. Thus, this text must persist in the memory for the lifetime of node. More...

#include <rapidxml.h>

Inheritance diagram for rapidxml::xml_node< Ch >:
rapidxml::xml_base< Ch > rapidxml::xml_document< Ch >

Public Member Functions

 xml_node (node_type type)
 Constructs an empty node with the specified type. Consider using memory_pool of appropriate document to allocate nodes manually. More...
 
node_type type () const
 Gets type of node. More...
 
xml_document< Ch > * document () const
 Gets document of which node is a child. More...
 
xml_node< Ch > * first_node (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets first child node, optionally matching node name. More...
 
xml_node< Ch > * last_node (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets last child node, optionally matching node name. Behaviour is undefined if node has no children. Use first_node() to test if node has children. More...
 
xml_node< Ch > * previous_sibling (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets previous sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use parent() to test if node has a parent. More...
 
xml_node< Ch > * next_sibling (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets next sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use parent() to test if node has a parent. More...
 
xml_attribute< Ch > * first_attribute (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets first attribute of node, optionally matching attribute name. More...
 
xml_attribute< Ch > * last_attribute (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets last attribute of node, optionally matching attribute name. More...
 
void type (node_type type)
 Sets type of node. More...
 
void prepend_node (xml_node< Ch > *child)
 Prepends a new child node. The prepended child becomes the first child, and all existing children are moved one position back. More...
 
void append_node (xml_node< Ch > *child)
 Appends a new child node. The appended child becomes the last child. More...
 
void insert_node (xml_node< Ch > *where, xml_node< Ch > *child)
 Inserts a new child node at specified place inside the node. All children after and including the specified node are moved one position back. More...
 
void remove_first_node ()
 Removes first child node. If node has no children, behaviour is undefined. Use first_node() to test if node has children. More...
 
void remove_last_node ()
 Removes last child of the node. If node has no children, behaviour is undefined. Use first_node() to test if node has children. More...
 
void remove_node (xml_node< Ch > *where)
 Removes specified child from the node. More...
 
void remove_all_nodes ()
 Removes all child nodes (but not attributes). More...
 
void prepend_attribute (xml_attribute< Ch > *attribute)
 Prepends a new attribute to the node. More...
 
void append_attribute (xml_attribute< Ch > *attribute)
 Appends a new attribute to the node. More...
 
void insert_attribute (xml_attribute< Ch > *where, xml_attribute< Ch > *attribute)
 Inserts a new attribute at specified place inside the node. All attributes after and including the specified attribute are moved one position back. More...
 
void remove_first_attribute ()
 Removes first attribute of the node. If node has no attributes, behaviour is undefined. Use first_attribute() to test if node has attributes. More...
 
void remove_last_attribute ()
 Removes last attribute of the node. If node has no attributes, behaviour is undefined. Use first_attribute() to test if node has attributes. More...
 
void remove_attribute (xml_attribute< Ch > *where)
 Removes specified attribute from node. More...
 
void remove_all_attributes ()
 Removes all attributes of node. More...
 
- Public Member Functions inherited from rapidxml::xml_base< Ch >
 xml_base ()
 
Ch * name () const
 Gets name of the node. Interpretation of name depends on type of node. Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.

Use name_size() function to determine length of the name. More...
 
std::size_t name_size () const
 Gets size of node name, not including terminator character. This function works correctly irrespective of whether name is or is not zero terminated. More...
 
Ch * value () const
 Gets value of node. Interpretation of value depends on type of node. Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.

Use value_size() function to determine length of the value. More...
 
std::size_t value_size () const
 Gets size of node value, not including terminator character. This function works correctly irrespective of whether value is or is not zero terminated. More...
 
void name (const Ch *name, std::size_t size)
 Sets name of node to a non zero-terminated string. See ownership_of_strings.

Note that node does not own its name or value, it only stores a pointer to it. It will not delete or otherwise free the pointer on destruction. It is reponsibility of the user to properly manage lifetime of the string. The easiest way to achieve it is to use memory_pool of the document to allocate the string - on destruction of the document the string will be automatically freed.

Size of name must be specified separately, because name does not have to be zero terminated. Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated). More...
 
void name (const Ch *name)
 Sets name of node to a zero-terminated string. See also ownership_of_strings and xml_node::name(const Ch *, std::size_t). More...
 
void value (const Ch *value, std::size_t size)
 Sets value of node to a non zero-terminated string. See ownership_of_strings.

Note that node does not own its name or value, it only stores a pointer to it. It will not delete or otherwise free the pointer on destruction. It is reponsibility of the user to properly manage lifetime of the string. The easiest way to achieve it is to use memory_pool of the document to allocate the string - on destruction of the document the string will be automatically freed.

Size of value must be specified separately, because it does not have to be zero terminated. Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).

If an element has a child node of type node_data, it will take precedence over element value when printing. If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser. More...
 
void value (const Ch *value)
 Sets value of node to a zero-terminated string. See also ownership_of_strings and xml_node::value(const Ch *, std::size_t). More...
 
xml_node< Ch > * parent () const
 Gets node parent. More...
 

Private Member Functions

 xml_node (const xml_node &)
 
void operator= (const xml_node &)
 

Private Attributes

node_type m_type
 
xml_node< Ch > * m_first_node
 
xml_node< Ch > * m_last_node
 
xml_attribute< Ch > * m_first_attribute
 
xml_attribute< Ch > * m_last_attribute
 
xml_node< Ch > * m_prev_sibling
 
xml_node< Ch > * m_next_sibling
 

Additional Inherited Members

- Static Protected Member Functions inherited from rapidxml::xml_base< Ch >
static Ch * nullstr ()
 
- Protected Attributes inherited from rapidxml::xml_base< Ch >
Ch * m_name
 
Ch * m_value
 
std::size_t m_name_size
 
std::size_t m_value_size
 
xml_node< Ch > * m_parent
 

Detailed Description

template<class Ch = char>
class rapidxml::xml_node< Ch >

Parameters
ChCharacter type to use.

Constructor & Destructor Documentation

◆ xml_node() [1/2]

template<class Ch = char>
rapidxml::xml_node< Ch >::xml_node ( node_type  type)
inline
Parameters
typeType of node to construct.

◆ xml_node() [2/2]

template<class Ch = char>
rapidxml::xml_node< Ch >::xml_node ( const xml_node< Ch > &  )
private

Member Function Documentation

◆ append_attribute()

template<class Ch = char>
void rapidxml::xml_node< Ch >::append_attribute ( xml_attribute< Ch > *  attribute)
inline
Parameters
attributeAttribute to append.

◆ append_node()

template<class Ch = char>
void rapidxml::xml_node< Ch >::append_node ( xml_node< Ch > *  child)
inline
Parameters
childNode to append.

◆ document()

template<class Ch = char>
xml_document<Ch>* rapidxml::xml_node< Ch >::document ( ) const
inline
Returns
Pointer to document that contains this node, or 0 if there is no parent document.

◆ first_attribute()

template<class Ch = char>
xml_attribute<Ch>* rapidxml::xml_node< Ch >::first_attribute ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inline
Parameters
nameName of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found attribute, or 0 if not found.

◆ first_node()

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::first_node ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inline
Parameters
nameName of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found child, or 0 if not found.

◆ insert_attribute()

template<class Ch = char>
void rapidxml::xml_node< Ch >::insert_attribute ( xml_attribute< Ch > *  where,
xml_attribute< Ch > *  attribute 
)
inline
Parameters
wherePlace where to insert the attribute, or 0 to insert at the back.
attributeAttribute to insert.

◆ insert_node()

template<class Ch = char>
void rapidxml::xml_node< Ch >::insert_node ( xml_node< Ch > *  where,
xml_node< Ch > *  child 
)
inline
Parameters
wherePlace where to insert the child, or 0 to insert at the back.
childNode to insert.

◆ last_attribute()

template<class Ch = char>
xml_attribute<Ch>* rapidxml::xml_node< Ch >::last_attribute ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inline
Parameters
nameName of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found attribute, or 0 if not found.

◆ last_node()

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::last_node ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inline
Parameters
nameName of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found child, or 0 if not found.

◆ next_sibling()

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::next_sibling ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inline
Parameters
nameName of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found sibling, or 0 if not found.

◆ operator=()

template<class Ch = char>
void rapidxml::xml_node< Ch >::operator= ( const xml_node< Ch > &  )
private

◆ prepend_attribute()

template<class Ch = char>
void rapidxml::xml_node< Ch >::prepend_attribute ( xml_attribute< Ch > *  attribute)
inline
Parameters
attributeAttribute to prepend.

◆ prepend_node()

template<class Ch = char>
void rapidxml::xml_node< Ch >::prepend_node ( xml_node< Ch > *  child)
inline
Parameters
childNode to prepend.

◆ previous_sibling()

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::previous_sibling ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inline
Parameters
nameName of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found sibling, or 0 if not found.

◆ remove_all_attributes()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_all_attributes ( )
inline

◆ remove_all_nodes()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_all_nodes ( )
inline

◆ remove_attribute()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_attribute ( xml_attribute< Ch > *  where)
inline
Parameters
wherePointer to attribute to be removed.

◆ remove_first_attribute()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_first_attribute ( )
inline

◆ remove_first_node()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_first_node ( )
inline

◆ remove_last_attribute()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_last_attribute ( )
inline

◆ remove_last_node()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_last_node ( )
inline

◆ remove_node()

template<class Ch = char>
void rapidxml::xml_node< Ch >::remove_node ( xml_node< Ch > *  where)
inline

◆ type() [1/2]

template<class Ch = char>
node_type rapidxml::xml_node< Ch >::type ( ) const
inline
Returns
Type of node.

◆ type() [2/2]

template<class Ch = char>
void rapidxml::xml_node< Ch >::type ( node_type  type)
inline
Parameters
typeType of node to set.

Member Data Documentation

◆ m_first_attribute

template<class Ch = char>
xml_attribute<Ch>* rapidxml::xml_node< Ch >::m_first_attribute
private

◆ m_first_node

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::m_first_node
private

◆ m_last_attribute

template<class Ch = char>
xml_attribute<Ch>* rapidxml::xml_node< Ch >::m_last_attribute
private

◆ m_last_node

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::m_last_node
private

◆ m_next_sibling

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::m_next_sibling
private

◆ m_prev_sibling

template<class Ch = char>
xml_node<Ch>* rapidxml::xml_node< Ch >::m_prev_sibling
private

◆ m_type

template<class Ch = char>
node_type rapidxml::xml_node< Ch >::m_type
private

The documentation for this class was generated from the following file: