Scopira 20080306

scopira::tool::xml_node Class Reference

#include <xml.h>

List of all members.

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

Detailed Description

A pointer/link to a NODE within an existing XML document. This is an ultra light, full copyable, non-virtual class.

Author:
Aleksander Demko

Constructor & Destructor Documentation

scopira::tool::xml_node::xml_node ( void  ) [inline]

Null pointer constructor

Author:
Aleksander Demko

Referenced by get_first_child().

scopira::tool::xml_node::xml_node ( xmlNodePtr  ptr) [inline, explicit]

Initialization constructor

Author:
Aleksander Demko

Member Function Documentation

void scopira::tool::xml_node::add_attrib ( const std::string &  key,
const std::string &  val 
)

Sets/adds the given attribute and value

Author:
Aleksander Demko
xml_node scopira::tool::xml_node::add_child ( const std::string &  name)

Adds a new child node with the given name and return it

Author:
Aleksander Demko
xml_node scopira::tool::xml_node::add_comment ( const std::string &  comment_contents)

Adds a comment to this node and returns it.

Author:
Aleksander Demko
xml_node scopira::tool::xml_node::add_content_child ( const std::string &  content)

Adds the given content/text block to this node

Author:
Aleksander Demko
template<class I >
void scopira::tool::xml_node::children_load_attrib ( const std::string &  elementname,
const std::string &  attribname,
iter 
) const [inline]

Loads attributes from all the sub elements in the iteration

Author:
Aleksander Demko

References get_first_child_name(), and is_valid().

template<class I >
void scopira::tool::xml_node::children_load_text ( const std::string &  elementname,
iter 
) const [inline]

Loads texts/content blocks from all the sub elementname in the iteration

Author:
Aleksander Demko

References get_first_child_name(), and is_valid().

template<class I >
void scopira::tool::xml_node::children_load_xml ( const std::string &  elementname,
iter 
) const [inline]

Applies load_xml to all the sub elements in the iteration.

Author:
Aleksander Demko

References get_first_child_name(), and is_valid().

void scopira::tool::xml_node::clear_content_children ( void  )

Remove any and all text sub nodes from this node.

Author:
Aleksander Demko
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.

Author:
Aleksander Demko
int scopira::tool::xml_node::count_children ( const std::string &  name) const

Counts the number of children nodes with the given name

Author:
Aleksander Demko
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.

Author:
Aleksander Demko
const char* scopira::tool::xml_node::get_c_content ( void  ) const [inline]

Gets the text of this node, as a C string. This may return null!

Author:
Aleksander Demko
const char* scopira::tool::xml_node::get_c_name ( void  ) const [inline]

Gets the name of this node, (C) string

Author:
Aleksander Demko
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.

Author:
Aleksander Demko
xml_attrib scopira::tool::xml_node::get_first_attrib ( void  ) const

Gets the first attribute of this node

Author:
Aleksander Demko
xml_node scopira::tool::xml_node::get_first_child ( void  ) const [inline]

Get the first child node May return an empty node.

Author:
Aleksander Demko

References xml_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.

Author:
Aleksander Demko

Referenced by children_load_attrib(), children_load_text(), and children_load_xml().

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.

Author:
Aleksander Demko
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"

Author:
Aleksander Demko
std::string scopira::tool::xml_node::get_name ( void  ) const [inline]

Gets the name of this node

Author:
Aleksander Demko
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.

Author:
Aleksander Demko
int scopira::tool::xml_node::get_type ( void  ) const [inline]

Gets the node type

Author:
Aleksander Demko
bool scopira::tool::xml_node::has_attrib ( const std::string &  aname) const

Does this node have an attribute with the given name?

Author:
Aleksander Demko
bool scopira::tool::xml_node::is_null ( void  ) const [inline]

Is this an empty node?

Author:
Aleksander Demko
bool scopira::tool::xml_node::is_valid ( void  ) const [inline]

Is this node not-empty (valid)?

Author:
Aleksander Demko

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.

Author:
Aleksander Demko
void scopira::tool::xml_node::next ( void  ) [inline]

Advance this node to the next node in the list

Author:
Aleksander Demko
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

Author:
Aleksander Demko
void scopira::tool::xml_node::next_type ( int  typ)

Advance this node to the next node in the list that has the given type

Author:
Aleksander Demko

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