UQTk: Uncertainty Quantification Toolkit 3.1.5
|
#include <XMLElement.h>
Public Member Functions | |
XMLElement (const std::string &) | |
Construct a new xml element object and give it a label. | |
virtual | ~XMLElement () |
Destructor. | |
const std::string & | label () const |
Get the label of this node. | |
void | set_label (const std::string &) |
Assign a new label to this node. | |
int | count_attributes () const |
RefPtr< XMLAttributeList > | attributes () |
Get access to the attribute list. | |
void | set_attributes (RefPtr< XMLAttributeList >) |
Assign an attribute list to this element. | |
int | count_children () const |
Utility function to check how many children this element has. | |
RefPtr< XMLElement > | get_child (int) |
RefPtr< XMLElement > | get_child (const std::string &) |
void | add_child (RefPtr< XMLElement >) |
void | add_child_rpt (RefPtr< XMLElement >) |
Same as add_child, but this allows for repeating children. | |
void | clear_children () |
Erase all child elements from this node. | |
int | count_content () const |
const std::string & | get_content_line (int) |
void | add_content_line (const std::string &) |
Add a line of content. | |
void | clear_content () |
Clear all text content. | |
Public Member Functions inherited from Object | |
Object () | |
Construct a new reference counted object with a zero reference count. | |
virtual | ~Object () |
Destroy this object. | |
long int | reference_count () const |
Returns the number of references that are held to this object. | |
Private Member Functions | |
XMLElement (const XMLElement &) | |
XMLElement & | operator= (const XMLElement &) |
void | recurse (RefPtr< XMLElement >, std::set< RefPtr< XMLElement > >) |
Private Attributes | |
std::string | label_ |
The iterator type returned for list of children. | |
RefPtr< XMLAttributeList > | attributes_ |
The list of attributes associated with this element. | |
std::vector< RefPtr< XMLElement > > | children_ |
The list of children associated with this element. | |
std::vector< std::string > | content_ |
The list of content associated with this element. | |
Friends | |
template<class T > | |
class | RefPtr |
template<class T > | |
class | ConstRefPtr |
Additional Inherited Members | |
Protected Member Functions inherited from Object | |
long int | reference_grab () const |
long int | reference_release () const |
This is the implementation of a node in an XML parse tree. Each node contains the following three containers, any (or all) of which may be empty.
attributes (XMLAttributeList): Contains attributes (key/value pairs). children (Vector<XMLElement>): Contains children of this node. content (Vector<std::string>): Contains content (text) data.
The implementation is very limited. In particular, the following advanced features are missing:
encoding: Support for character types other than char/std::string. comments: Allowing comment blocks to accompany each element. other xml types (control statements, etc.).
This implementation is heavily based on Kevin Long's XMLObject.
XMLElement::XMLElement | ( | const std::string & | lbl | ) |
Construct a new xml element object and give it a label.
|
private |
Blocked copy constructor.
MyException. |
|
virtual |
Destructor.
void XMLElement::add_child | ( | RefPtr< XMLElement > | kid | ) |
Add a child to the back of the list. Ignored if the child is already in the list.
MyException | if adding the child would result in a cyclic relationship. |
MyException | if the child holds a NULL pointer. |
void XMLElement::add_child_rpt | ( | RefPtr< XMLElement > | kid | ) |
Same as add_child, but this allows for repeating children.
void XMLElement::add_content_line | ( | const std::string & | text | ) |
Add a line of content.
RefPtr< XMLAttributeList > XMLElement::attributes | ( | ) |
Get access to the attribute list.
void XMLElement::clear_children | ( | ) |
Erase all child elements from this node.
void XMLElement::clear_content | ( | ) |
Clear all text content.
int XMLElement::count_attributes | ( | ) | const |
Utility function to check how many attributes this element has. This amounts to the same as calling '.attributes().size()'
int XMLElement::count_children | ( | ) | const |
Utility function to check how many children this element has.
int XMLElement::count_content | ( | ) | const |
Utility function to check how many lines of text content are associated with this element.
RefPtr< XMLElement > XMLElement::get_child | ( | const std::string & | lbl | ) |
Find the first instance of a child with a given label and return a pointer to it.
MyException | if the child label can not be found |
RefPtr< XMLElement > XMLElement::get_child | ( | int | index | ) |
Get the child with the given index.
MyException | if the index is invalid. |
const std::string & XMLElement::get_content_line | ( | int | index | ) |
Get a line of content by index.
MyException | if the index is out of range. |
const std::string & XMLElement::label | ( | ) | const |
Get the label of this node.
|
private |
Blocked assignment operator.
MyExcepiton. |
|
private |
A private routine called recursively to ensure that we don't have a cyclic relationship.
void XMLElement::set_attributes | ( | RefPtr< XMLAttributeList > | att | ) |
Assign an attribute list to this element.
void XMLElement::set_label | ( | const std::string & | lbl | ) |
Assign a new label to this node.
|
friend |
|
friend |
|
private |
The list of attributes associated with this element.
|
private |
The list of children associated with this element.
|
private |
The list of content associated with this element.
|
private |
The iterator type returned for list of children.
The label of this element.