#include <XMLObject.h>
Note that the class assumes memory management responsibility for all child objects, i.e. when the destructor is called, all child objects are recursively destroyed as well (using delete).
Definition at line 56 of file XMLObject.h.
std::string | tag_ |
Attrs | attrs_ |
ProcInsts | proc_insts_ |
Elements | elements_ |
std::string | text_ |
XMLObject * | parent_ |
const std::string & | tag () const |
Accessors. | |
const Attrs & | attrs () const |
const ProcInsts & | proc_insts () const |
const Elements & | elements () const |
const std::string & | text () const |
XMLObject * | parent () const |
void | add_attr (const std::string &attr, const std::string &val) |
Append an attribute/value pair. | |
void | add_proc_inst (const std::string &target, const std::string &data) |
Append a processing instruction / value pair. | |
void | add_element (XMLObject *child) |
Append a child element and assume memory management responsibility for it. | |
void | add_text (const char *text, size_t len=0) |
Append some text data. | |
void | to_string (StringBuffer *buf, int indent, int cur_indent=0) const |
Recursively generate formatted XML text and put it into the given buffer. | |
NO_ASSIGN_COPY (XMLObject) | |
We don't support assignment of the class. | |
Public Types | |
typedef std::vector< std::string > | Attrs |
Type for the attribute list is a vector of strings of the form "attr1" "val1" "attr2" "val2" . | |
typedef std::vector< std::string > | ProcInsts |
Type for the attribute list is a vector of strings of the form "target1" "data1" "target2" "data2" . | |
typedef std::vector< XMLObject * > | Elements |
Type for the element list is a vector of XMLObject* pointers. | |
Public Member Functions | |
XMLObject (const std::string &tag) | |
The constructor requires the tag name. | |
~XMLObject () | |
The destructor recursively deletes all subelements. |
typedef std::vector<std::string> oasys::XMLObject::Attrs |
Type for the attribute list is a vector of strings of the form "attr1" "val1" "attr2" "val2" .
..
Definition at line 62 of file XMLObject.h.
typedef std::vector<std::string> oasys::XMLObject::ProcInsts |
Type for the attribute list is a vector of strings of the form "target1" "data1" "target2" "data2" .
..
Definition at line 68 of file XMLObject.h.
typedef std::vector<XMLObject*> oasys::XMLObject::Elements |
Type for the element list is a vector of XMLObject* pointers.
Definition at line 73 of file XMLObject.h.
oasys::XMLObject::XMLObject | ( | const std::string & | tag | ) |
oasys::XMLObject::~XMLObject | ( | ) |
The destructor recursively deletes all subelements.
Definition at line 51 of file XMLObject.cc.
References elements_.
const std::string& oasys::XMLObject::tag | ( | ) | const [inline] |
Accessors.
Definition at line 86 of file XMLObject.h.
References tag_.
Referenced by oasys::ExpatXMLParser::end_element().
const Attrs& oasys::XMLObject::attrs | ( | ) | const [inline] |
const ProcInsts& oasys::XMLObject::proc_insts | ( | ) | const [inline] |
const Elements& oasys::XMLObject::elements | ( | ) | const [inline] |
const std::string& oasys::XMLObject::text | ( | ) | const [inline] |
XMLObject* oasys::XMLObject::parent | ( | ) | const [inline] |
Definition at line 91 of file XMLObject.h.
References parent_.
Referenced by oasys::ExpatXMLParser::end_element().
void oasys::XMLObject::add_attr | ( | const std::string & | attr, | |
const std::string & | val | |||
) |
Append an attribute/value pair.
Definition at line 61 of file XMLObject.cc.
References attrs_.
Referenced by oasys::ExpatXMLParser::start_element().
void oasys::XMLObject::add_proc_inst | ( | const std::string & | target, | |
const std::string & | data | |||
) |
Append a processing instruction / value pair.
Definition at line 69 of file XMLObject.cc.
References proc_insts_.
void oasys::XMLObject::add_element | ( | XMLObject * | child | ) |
Append a child element and assume memory management responsibility for it.
Definition at line 78 of file XMLObject.cc.
References elements_, and parent_.
Referenced by oasys::ExpatXMLParser::start_element().
void oasys::XMLObject::add_text | ( | const char * | text, | |
size_t | len = 0 | |||
) |
Append some text data.
Definition at line 86 of file XMLObject.cc.
References text_.
Referenced by oasys::ExpatXMLParser::character_data().
void oasys::XMLObject::to_string | ( | StringBuffer * | buf, | |
int | indent, | |||
int | cur_indent = 0 | |||
) | const |
Recursively generate formatted XML text and put it into the given buffer.
indent | Indentation control for subelements. If -1, put all subelements and text on the same line. If >= 0 then put each tag on a new line indented with the given number of spaces. | |
cur_indent | The current cumulative indentation |
Definition at line 97 of file XMLObject.cc.
References oasys::StringBuffer::append(), oasys::StringBuffer::appendf(), attrs_, elements_, proc_insts_, tag_, and text_.
Referenced by oasys::XMLDocument::to_string().
oasys::XMLObject::NO_ASSIGN_COPY | ( | XMLObject | ) | [protected] |
We don't support assignment of the class.
std::string oasys::XMLObject::tag_ [protected] |
Attrs oasys::XMLObject::attrs_ [protected] |
ProcInsts oasys::XMLObject::proc_insts_ [protected] |
Definition at line 132 of file XMLObject.h.
Referenced by add_proc_inst(), proc_insts(), and to_string().
Elements oasys::XMLObject::elements_ [protected] |
Definition at line 133 of file XMLObject.h.
Referenced by add_element(), elements(), to_string(), and ~XMLObject().
std::string oasys::XMLObject::text_ [protected] |
XMLObject* oasys::XMLObject::parent_ [protected] |