libhomegear-base
0.7
Base library for Homegear and Homegear family modules.
|
This class represents root of the DOM hierarchy. More...
#include <rapidxml.h>
Public Member Functions | |
xml_document () | |
Constructs empty XML document. More... | |
template<int Flags> | |
void | parse (char *text) |
Parses zero-terminated XML string according to given flags. More... | |
void | clear () |
Clears the document by deleting all nodes and clearing the memory pool. More... | |
Public Member Functions inherited from rapidxml::xml_node | |
xml_node (node_type type) | |
Constructs an empty node with the specified type. More... | |
node_type | type () const |
Gets type of node. More... | |
xml_document * | document () const |
Gets document of which node is a child. More... | |
xml_node * | 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. More... | |
xml_node * | last_node (const char *name=nullptr, std::size_t name_size=0, bool case_sensitive=true) const |
Gets last child node, optionally matching node name. More... | |
xml_node * | previous_sibling (const char *name=nullptr, std::size_t name_size=0, bool case_sensitive=true) const |
Gets previous sibling node, optionally matching node name. More... | |
xml_node * | 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. More... | |
xml_attribute * | 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. More... | |
xml_attribute * | last_attribute (const char *name=nullptr, 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 *child) |
Prepends a new child node. More... | |
void | append_node (xml_node *child) |
Appends a new child node. More... | |
void | insert_node (xml_node *where, xml_node *child) |
Inserts a new child node at specified place inside the node. More... | |
void | remove_first_node () |
Removes first child node. More... | |
void | remove_last_node () |
Removes last child of the node. More... | |
void | remove_node (xml_node *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 *attribute) |
Prepends a new attribute to the node. More... | |
void | append_attribute (xml_attribute *attribute) |
Appends a new attribute to the node. More... | |
void | insert_attribute (xml_attribute *where, xml_attribute *attribute) |
Inserts a new attribute at specified place inside the node. More... | |
void | remove_first_attribute () |
Removes first attribute of the node. More... | |
void | remove_last_attribute () |
Removes last attribute of the node. More... | |
void | remove_attribute (xml_attribute *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 | |
xml_base () | |
char * | name () const |
Gets name of the node. More... | |
std::size_t | name_size () const |
Gets size of node name, not including terminator character. More... | |
char * | value () const |
Gets value of node. More... | |
std::size_t | value_size () const |
Gets size of node value, not including terminator character. More... | |
void | name (const char *name, std::size_t size) |
Sets name of node to a non zero-terminated string. More... | |
void | name (const char *name) |
Sets name of node to a zero-terminated string. More... | |
void | value (const char *value, std::size_t size) |
Sets value of node to a non zero-terminated string. More... | |
void | value (const char *value) |
Sets value of node to a zero-terminated string. More... | |
xml_node * | parent () const |
Gets node parent. More... | |
Public Member Functions inherited from rapidxml::memory_pool | |
memory_pool () | |
Constructs empty pool with default allocator functions. More... | |
~memory_pool () | |
Destroys pool and frees all the memory. More... | |
xml_node * | 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. More... | |
xml_attribute * | 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. More... | |
char * | allocate_string (const char *source=nullptr, std::size_t size=0) |
Allocates a char array of given size from the pool, and optionally copies a given string to it. More... | |
xml_node * | clone_node (const xml_node *source, xml_node *result=nullptr) |
Clones an xml_node and its hierarchy of child nodes and attributes. More... | |
void | clear () |
Clears the pool. More... | |
void | set_allocator (alloc_func *af, free_func *ff) |
Sets or resets the user-defined memory allocation functions for the pool. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from rapidxml::xml_base | |
static char * | nullstr () |
Protected Attributes inherited from rapidxml::xml_base | |
char * | m_name |
char * | m_value |
std::size_t | m_name_size |
std::size_t | m_value_size |
xml_node * | m_parent |
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.
Ch | Character type to use. |
rapidxml::xml_document::xml_document | ( | ) |
Constructs empty XML document.
void rapidxml::xml_document::clear | ( | ) |
Clears the document by deleting all nodes and clearing the memory pool.
All nodes owned by document pool are destroyed.
void rapidxml::xml_document::parse | ( | char * | text | ) |
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.
text | XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser. |