oasys::XMLObject Class Reference

#include <XMLObject.h>

List of all members.


Detailed Description

A simple object-based representation of an XML entity.

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 35 of file XMLObject.h.
std::string tag_
Attrs attrs_
ProcInsts proc_insts_
Elements elements_
std::string text_
XMLObjectparent_
const std::string & tag () const
 Accessors.
const Attrsattrs () const
const ProcInstsproc_insts () const
const Elementselements () const
const std::string & text () const
XMLObjectparent () 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.


Member Typedef Documentation

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 41 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 47 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 52 of file XMLObject.h.


Constructor & Destructor Documentation

oasys::XMLObject::XMLObject ( const std::string &  tag  ) 

The constructor requires the tag name.

Definition at line 24 of file XMLObject.cc.

oasys::XMLObject::~XMLObject (  ) 

The destructor recursively deletes all subelements.

Definition at line 30 of file XMLObject.cc.

References elements_.


Member Function Documentation

const std::string& oasys::XMLObject::tag (  )  const [inline]

Accessors.

Definition at line 65 of file XMLObject.h.

References tag_.

Referenced by oasys::ExpatXMLParser::end_element().

const Attrs& oasys::XMLObject::attrs (  )  const [inline]

Definition at line 66 of file XMLObject.h.

References attrs_.

const ProcInsts& oasys::XMLObject::proc_insts (  )  const [inline]

Definition at line 67 of file XMLObject.h.

References proc_insts_.

const Elements& oasys::XMLObject::elements (  )  const [inline]

Definition at line 68 of file XMLObject.h.

References elements_.

const std::string& oasys::XMLObject::text (  )  const [inline]

Definition at line 69 of file XMLObject.h.

References text_.

XMLObject* oasys::XMLObject::parent (  )  const [inline]

Definition at line 70 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 40 of file XMLObject.cc.

References attrs_.

Referenced by oasys::XMLMarshal::process(), and 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 48 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 57 of file XMLObject.cc.

References elements_, and parent_.

Referenced by oasys::XMLMarshal::process(), and oasys::ExpatXMLParser::start_element().

void oasys::XMLObject::add_text ( const char *  text,
size_t  len = 0 
)

Append some text data.

Definition at line 65 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.

Parameters:
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 76 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.


Member Data Documentation

std::string oasys::XMLObject::tag_ [protected]

Definition at line 109 of file XMLObject.h.

Referenced by tag(), and to_string().

Attrs oasys::XMLObject::attrs_ [protected]

Definition at line 110 of file XMLObject.h.

Referenced by add_attr(), attrs(), and to_string().

ProcInsts oasys::XMLObject::proc_insts_ [protected]

Definition at line 111 of file XMLObject.h.

Referenced by add_proc_inst(), proc_insts(), and to_string().

Elements oasys::XMLObject::elements_ [protected]

Definition at line 112 of file XMLObject.h.

Referenced by add_element(), elements(), to_string(), and ~XMLObject().

std::string oasys::XMLObject::text_ [protected]

Definition at line 113 of file XMLObject.h.

Referenced by add_text(), text(), and to_string().

XMLObject* oasys::XMLObject::parent_ [protected]

Definition at line 114 of file XMLObject.h.

Referenced by add_element(), and parent().


The documentation for this class was generated from the following files:
Generated on Thu Jun 7 16:57:03 2007 for DTN Reference Implementation by  doxygen 1.5.1