xml_document< Ch > Class Template Reference

This class represents root of the DOM hierarchy. More...

#include <ArmarXCore/core/rapidxml/rapidxml.hpp>

+ Inheritance diagram for xml_document< Ch >:

Public Member Functions

void clear ()
 Clears the document by deleting all nodes and clearing the memory pool.
 
template<int Flags>
void parse (Ch *text)
 Parses zero-terminated XML string according to given flags.
 
 xml_document ()
 Constructs empty XML document.
 
- Public Member Functions inherited from xml_node< char >
void append_attribute (xml_attribute< char > *attribute)
 Appends a new attribute to the node.
 
void append_node (xml_node< char > *child)
 Appends a new child node.
 
xml_document< char > * document () const
 Gets document of which node is a child.
 
xml_attribute< char > * first_attribute (const char *name=nullptr, std::size_t name_size=0, bool case_sensitive=true) const
 Gets first attribute of node, optionally matching attribute name.
 
xml_node< char > * first_node (const char *name=nullptr, std::size_t name_size=0, bool case_sensitive=true) const
 Gets first child node, optionally matching node name.
 
void insert_attribute (xml_attribute< char > *where, xml_attribute< char > *attribute)
 Inserts a new attribute at specified place inside the node.
 
void insert_node (xml_node< char > *where, xml_node< char > *child)
 Inserts a new child node at specified place inside the node.
 
xml_attribute< char > * last_attribute (const char *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets last attribute of node, optionally matching attribute name.
 
xml_node< char > * last_node (const char *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets last child node, optionally matching node name.
 
xml_node< char > * next_sibling (const char *name=nullptr, std::size_t name_size=0, bool case_sensitive=true) const
 Gets next sibling node, optionally matching node name.
 
void prepend_attribute (xml_attribute< char > *attribute)
 Prepends a new attribute to the node.
 
void prepend_node (xml_node< char > *child)
 Prepends a new child node.
 
xml_node< char > * previous_sibling (const char *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 Gets previous sibling node, optionally matching node name.
 
void remove_all_attributes ()
 Removes all attributes of node.
 
void remove_all_nodes ()
 Removes all child nodes (but not attributes).
 
void remove_attribute (xml_attribute< char > *where)
 Removes specified attribute from node.
 
void remove_first_attribute ()
 Removes first attribute of the node.
 
void remove_first_node ()
 Removes first child node.
 
void remove_last_attribute ()
 Removes last attribute of the node.
 
void remove_last_node ()
 Removes last child of the node.
 
void remove_node (xml_node< char > *where)
 Removes specified child from the node.
 
node_type type () const
 Gets type of node.
 
void type (node_type type)
 Sets type of node.
 
 xml_node (node_type type)
 Constructs an empty node with the specified type.
 
- Public Member Functions inherited from xml_base< char >
char * name () const
 Gets name of the node.
 
void name (const char *name)
 Sets name of node to a zero-terminated string.
 
void name (const char *name, std::size_t size)
 Sets name of node to a non zero-terminated string.
 
std::size_t name_size () const
 Gets size of node name, not including terminator character.
 
xml_node< char > * parent () const
 Gets node parent.
 
char * value () const
 Gets value of node.
 
void value (const char *value)
 Sets value of node to a zero-terminated string.
 
void value (const char *value, std::size_t size)
 Sets value of node to a non zero-terminated string.
 
std::size_t value_size () const
 Gets size of node value, not including terminator character.
 
 xml_base ()
 
- Public Member Functions inherited from memory_pool< char >
xml_attribute< char > * allocate_attribute (const char *name=nullptr, const char *value=nullptr, std::size_t name_size=0, std::size_t value_size=0)
 Allocates a new attribute from the pool, and optionally assigns name and value to it.
 
xml_node< char > * allocate_node (node_type type, const char *name=nullptr, const char *value=nullptr, std::size_t name_size=0, std::size_t value_size=0)
 Allocates a new node from the pool, and optionally assigns name and value to it.
 
char * allocate_string (const char *source=0, std::size_t size=0)
 Allocates a char array of given size from the pool, and optionally copies a given string to it.
 
void clear ()
 Clears the pool.
 
xml_node< char > * clone_node (const xml_node< char > *source, xml_node< char > *result=0)
 Clones an xml_node and its hierarchy of child nodes and attributes.
 
 memory_pool ()
 Constructs empty pool with default allocator functions.
 
void set_allocator (alloc_func *af, free_func *ff)
 Sets or resets the user-defined memory allocation functions for the pool.
 
 ~memory_pool ()
 Destroys pool and frees all the memory.
 

Additional Inherited Members

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

Detailed Description

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

This class represents root of the DOM hierarchy.

It is also an xml_node and a memory_pool through public inheritance. Use parse() function to build a DOM tree from a zero-terminated XML text string. parse() function allocates memory for nodes and attributes by using functions of xml_document, which are inherited from memory_pool. To access root node of the document, use the document itself, as if it was an xml_node.

Parameters
ChCharacter type to use.

Definition at line 1659 of file rapidxml.hpp.

Constructor & Destructor Documentation

◆ xml_document()

template<class Ch = char>
xml_document ( )
inline

Constructs empty XML document.

Definition at line 1664 of file rapidxml.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

template<class Ch = char>
void clear ( )
inline

Clears the document by deleting all nodes and clearing the memory pool.

All nodes owned by document pool are destroyed.

Definition at line 1723 of file rapidxml.hpp.

+ Here is the call graph for this function:

◆ parse()

template<class Ch = char>
template<int Flags>
void parse ( Ch * text)
inline

Parses zero-terminated XML string according to given flags.

Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used. The string must persist for the lifetime of the document. In case of error, rapidxml::parse_error exception will be thrown.

If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning. Make sure that data is zero-terminated.

Document can be parsed into multiple times. Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.

Parameters
textXML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.

Definition at line 1681 of file rapidxml.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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