Scopira
20080306
|
#include <xml.h>
Public Types | |
enum | { element_c = XML_ELEMENT_NODE, text_c = XML_TEXT_NODE } |
iterator-filter types | |
Public Member Functions | |
xml_node (void) | |
xml_node (xmlNodePtr ptr) | |
xmlNodePtr | get_ptr (void) const |
returns the internal pointer – use with care | |
int | get_type (void) const |
const char * | get_c_name (void) const |
std::string | get_name (void) const |
const char * | get_c_content (void) const |
bool | is_null (void) const |
bool | is_valid (void) const |
void | next (void) |
void | next_type (int typ) |
void | next_name (const std::string &name) |
int | count_children (const std::string &name) const |
xml_node | get_first_child (void) const |
xml_node | get_first_child_type (int typ) const |
xml_node | get_first_child_name (const std::string &name) const |
xml_attrib | get_first_attrib (void) const |
const char * | get_attrib_c_text (const std::string &aname) const |
const char * | get_child_c_text (const std::string &nname) const |
bool | has_attrib (const std::string &aname) const |
xml_node | add_child (const std::string &name) |
xml_node | add_comment (const std::string &comment_contents) |
void | clear_this (void) |
void | add_attrib (const std::string &key, const std::string &val) |
xml_node | add_content_child (const std::string &content) |
void | clear_content_children (void) |
const char * | get_text_c_content (void) const |
const char * | get_leaf_text_content (const std::string &pathnodespec) const |
void | load_string_attrib (const std::string &name, std::string &outval) |
template<class I > | |
void | children_load_xml (const std::string &elementname, I iter) const |
template<class I > | |
void | children_load_attrib (const std::string &elementname, const std::string &attribname, I iter) const |
template<class I > | |
void | children_load_text (const std::string &elementname, I iter) const |
A pointer/link to a NODE within an existing XML document. This is an ultra light, full copyable, non-virtual class.
|
inline |
Null pointer constructor
|
inlineexplicit |
Initialization constructor
void scopira::tool::xml_node::add_attrib | ( | const std::string & | key, |
const std::string & | val | ||
) |
Sets/adds the given attribute and value
xml_node scopira::tool::xml_node::add_child | ( | const std::string & | name | ) |
Adds a new child node with the given name and return it
xml_node scopira::tool::xml_node::add_comment | ( | const std::string & | comment_contents | ) |
Adds a comment to this node and returns it.
xml_node scopira::tool::xml_node::add_content_child | ( | const std::string & | content | ) |
Adds the given content/text block to this node
|
inline |
Loads attributes from all the sub elements in the iteration
References is_valid().
|
inline |
Loads texts/content blocks from all the sub elementname in the iteration
References is_valid().
|
inline |
Applies load_xml to all the sub elements in the iteration.
References is_valid().
void scopira::tool::xml_node::clear_content_children | ( | void | ) |
Remove any and all text sub nodes from this node.
void scopira::tool::xml_node::clear_this | ( | void | ) |
Removes THIS node from the parent and deletes itself. After this call, THIS node is no longer valid.
int scopira::tool::xml_node::count_children | ( | const std::string & | name | ) | const |
Counts the number of children nodes with the given name
const char* scopira::tool::xml_node::get_attrib_c_text | ( | const std::string & | aname | ) | const |
Super helper. Return the full attrib value of the given key.
Returns "" on not found.
|
inline |
Gets the text of this node, as a C string. This may return null!
|
inline |
Gets the name of this node, (C) string
const char* scopira::tool::xml_node::get_child_c_text | ( | const std::string & | nname | ) | const |
Super helper. Returns the full c_area of the SUB node with the given name.
Returns "" on any and all errors.
xml_attrib scopira::tool::xml_node::get_first_attrib | ( | void | ) | const |
Gets the first attribute of this node
|
inline |
Get the first child node May return an empty node.
xml_node scopira::tool::xml_node::get_first_child_name | ( | const std::string & | name | ) | const |
Get the first child node with the given name May return an empty node.
xml_node scopira::tool::xml_node::get_first_child_type | ( | int | typ | ) | const |
Get the first child node with the given type May return an empty node.
const char* scopira::tool::xml_node::get_leaf_text_content | ( | const std::string & | pathnodespec | ) | const |
Gets the first text/content block's text.
This is a convience verion, that allows you to drill down into sub nodes, using / in the names. It never returns null or fails, but will return empty string if it can't find a particular node.
Examples: "blah" "leafnode/nodename" "subnode/leafnode/nodename"
|
inline |
Gets the name of this node
const char* scopira::tool::xml_node::get_text_c_content | ( | void | ) | const |
Gets the first text/content block's text. If this node has no text blocks, an empty (but otherwise valid) string will be returned. Never returns null when the node itself is valid.
|
inline |
Gets the node type
bool scopira::tool::xml_node::has_attrib | ( | const std::string & | aname | ) | const |
Does this node have an attribute with the given name?
|
inline |
Is this an empty node?
|
inline |
Is this node not-empty (valid)?
Referenced by children_load_attrib(), children_load_text(), and children_load_xml().
void scopira::tool::xml_node::load_string_attrib | ( | const std::string & | name, |
std::string & | outval | ||
) |
Loads the given attribute. outval will be set to "" if the given attribute could not be found.
|
inline |
Advance this node to the next node in the list
void scopira::tool::xml_node::next_name | ( | const std::string & | name | ) |
Advance this node to the next node in the list that has the given name
void scopira::tool::xml_node::next_type | ( | int | typ | ) |
Advance this node to the next node in the list that has the given type