#include <node.h>
Public Types | |
typedef std::size_t | size_type |
size type | |
enum | node_type { type_element, type_text, type_cdata, type_pi, type_comment, type_entity, type_entity_ref, type_xinclude, type_document, type_document_type, type_document_frag, type_notation, type_dtd, type_dtd_element, type_dtd_attribute, type_dtd_entity, type_dtd_namespace } |
enum for the different types of XML nodes More... | |
Public Member Functions | |
node (void) | |
Construct a new blank xml::node. | |
node (const char *name) | |
Construct a new xml::node and set the name of the node. | |
node (const char *name, const char *content) | |
Construct a new xml::node given a name and content. | |
node (cdata cdata_info) | |
Construct a new xml::node that is of type_cdata. | |
node (comment comment_info) | |
Construct a new xml::node that is of type_comment. | |
node (pi pi_info) | |
Construct a new xml::node that is of type_pi. | |
node (const node &other) | |
Construct a new xml::node by copying another xml::node. | |
node & | operator= (const node &other) |
Make this node equal to some other node via assignment. | |
~node (void) | |
Class destructor. | |
void | set_name (const char *name) |
Set the name of this xml::node. | |
const char * | get_name (void) const |
Get the name of this xml::node. | |
void | set_content (const char *content) |
Set the content of a node. | |
const char * | get_content (void) const |
Get the content for this text node. | |
node_type | get_type (void) const |
Get this node's "type". | |
xml::attributes & | get_attributes (void) |
Get the list of attributes. | |
const xml::attributes & | get_attributes (void) const |
Get the list of attributes. | |
bool | is_text (void) const |
Find out if this node is a text node or sometiming like a text node, CDATA for example. | |
void | push_back (const node &child) |
Add a child xml::node to this node. | |
void | swap (node &other) |
Swap this node with another one. | |
size_type | size (void) const |
Returns the number of childer this nodes has. | |
bool | empty (void) const |
Find out if this node has any children. | |
iterator | begin (void) |
Get an iterator that points to the beginning of this node's children. | |
const_iterator | begin (void) const |
Get a const_iterator that points to the beginning of this node's children. | |
iterator | end (void) |
Get an iterator that points one past the last child for this node. | |
const_iterator | end (void) const |
Get a const_iterator that points one past the last child for this node. | |
iterator | self (void) |
Get an iterator that points back at this node. | |
const_iterator | self (void) const |
Get a const_iterator that points back at this node. | |
iterator | parent (void) |
Get an iterator that points at the parent of this node. | |
const_iterator | parent (void) const |
Get a const_iterator that points at the parent of this node. | |
iterator | find (const char *name) |
Find the first child node that has the given name. | |
const_iterator | find (const char *name) const |
Find the first child node that has the given name. | |
iterator | find (const char *name, iterator start) |
Find the first child node, starting with the given iterator, that has the given name. | |
const_iterator | find (const char *name, const_iterator start) const |
Find the first child node, starting with the given const_iterator, that has the given name. | |
iterator | insert (const node &n) |
Insert a new child node. | |
iterator | insert (iterator position, const node &n) |
Insert a new child node. | |
iterator | replace (iterator old_node, const node &new_node) |
Replace the node pointed to by the given iterator with another node. | |
iterator | erase (iterator to_erase) |
Erase the node that is pointed to by the given iterator. | |
iterator | erase (iterator first, iterator last) |
Erase all nodes in the given range, from frist to last. | |
size_type | erase (const char *name) |
Erase all children nodes with the given name. | |
void | sort (const char *node_name, const char *attr_name) |
Sort all the children nodes of this node using one of thier attributes. | |
template<typename T> void | sort (T compare) |
Sort all the children nodes of this node using the given comparison function object. | |
void | node_to_string (std::string &xml) const |
Convert the node and all its children into XML text and set the given string to that text. | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const node &n) |
Write a node and all of its children to the given stream. |
This includes the name of the node, the namespace of the node and attributes for the node. It also has an iterator whereby you can get to the children nodes.
It should be noted that any member function that returns a const char* returns a temporary value. The pointer that is returned will change with ANY operation to the xml::node. If you need the data to stick around a little longer you should put it inside a std::string.
|
size type
|
|
|
Construct a new blank xml::node.
|
|
Construct a new xml::node and set the name of the node.
|
|
Construct a new xml::node given a name and content. The content will be used to create a new child text node.
|
|
Construct a new xml::node that is of type_cdata. The cdata_info parameter should contain the contents of the CDATA section.
|
|
Construct a new xml::node that is of type_comment. The comment_info parameter should contain the contents of the XML comment.
|
|
Construct a new xml::node that is of type_pi. The pi_info parameter should contain the name of the XML processing instruction (PI), and optionally, the contents of the XML PI.
|
|
Construct a new xml::node by copying another xml::node.
|
|
Class destructor.
|
|
Get a const_iterator that points to the beginning of this node's children.
|
|
Get an iterator that points to the beginning of this node's children.
|
|
Find out if this node has any children. This is the same as xml::node::size() == 0 except it is much faster.
|
|
Get a const_iterator that points one past the last child for this node.
|
|
Get an iterator that points one past the last child for this node.
|
|
Erase all children nodes with the given name. This will find all nodes that have the given node name and remove them from this node. This will invalidate any iterators that point to the nodes to be erased, or any pointers or references to those nodes.
|
|
Erase all nodes in the given range, from frist to last. This will invalidate any iterators that point to the nodes to be erased, or any pointers or references to those nodes.
|
|
Erase the node that is pointed to by the given iterator. The node and all its children will be removed from this node. This will invalidate any iterators that point to the node to be erased, or any pointers or references to that node.
|
|
Find the first child node, starting with the given const_iterator, that has the given name. If no such node can be found, this function will return the same const_iterator that end() would return. This function should be given a const_iterator to one of this node's children. The search will begin with that node and continue with all its sibliings. This function will not recurse down the tree, it only searches in one level.
|
|
Find the first child node, starting with the given iterator, that has the given name. If no such node can be found, this function will return the same iterator that end() would return. This function should be given an iterator to one of this node's children. The search will begin with that node and continue with all its sibliings. This function will not recurse down the tree, it only searches in one level.
|
|
Find the first child node that has the given name. If no such node can be found, this function will return the same const_iterator that end() would return. This function is not recursive. That is, it will not search down the tree for the requested node. Instead, it will only search one level deep, only checking the children of this node.
|
|
Find the first child node that has the given name. If no such node can be found, this function will return the same iterator that end() would return. This function is not recursive. That is, it will not search down the tree for the requested node. Instead, it will only search one level deep, only checking the children of this node.
|
|
Get the list of attributes. You can use the returned object to get the attributes for this node. Make sure you use a reference to this returned object, to prevent a copy.
|
|
Get the list of attributes. You can use the returned object to get and set the attributes for this node. Make sure you use a reference to this returned object, to prevent a copy.
|
|
Get the content for this text node. If this node is not a text node but it has children nodes that are text nodes, the contents of those child nodes will be returned. If there is no content or these conditions do not apply, zero will be returned. This function may change in the future to return std::string. Feedback is welcome.
|
|
Get the name of this xml::node. This function may change in the future to return std::string. Feedback is welcome.
|
|
Get this node's "type". You can use that information to know what you can and cannot do with it.
|
|
Insert a new child node. The new node will be inserted before the node pointed to by the given iterator.
|
|
Insert a new child node. The new node will be inserted at the end of the child list. This is similar to the xml::node::push_back member function except that an iterator to the inserted node is returned.
|
|
Find out if this node is a text node or sometiming like a text node, CDATA for example.
|
|
Convert the node and all its children into XML text and set the given string to that text.
|
|
Make this node equal to some other node via assignment.
|
|
Get a const_iterator that points at the parent of this node. If this node does not have a parent, this member function will return an "end" const_iterator.
|
|
Get an iterator that points at the parent of this node. If this node does not have a parent, this member function will return an "end" iterator.
|
|
Add a child xml::node to this node.
|
|
Replace the node pointed to by the given iterator with another node. The old node will be removed, including all its children, and replaced with the new node. This will invalidate any iterators that point to the node to be replaced, or any pointers or references to that node.
|
|
Get a const_iterator that points back at this node.
|
|
Get an iterator that points back at this node.
|
|
Set the content of a node. If this node is an element node, this function will remove all of its children nodes and replace them with one text node set to the given string.
|
|
Set the name of this xml::node.
|
|
Returns the number of childer this nodes has. If you just want to know how if this node has children or not, you should use xml::node::empty() instead.
|
|
Sort all the children nodes of this node using the given comparison function object. All element type nodes will be considered for sorting.
|
|
Sort all the children nodes of this node using one of thier attributes. Only nodes that are of xml::node::type_element will be sorted, and they must have the given node_name. The sorting is done by calling std::strcmp on the value of the given attribute.
|
|
Swap this node with another one.
|
|
Write a node and all of its children to the given stream.
|