A simple XML class that loads an XML-ish structure into an internal tree and allows easy access to each element through a "current location". More...
#include <SimpleXML.h>
Classes | |
class | Tag |
Public Member Functions | |
ADCHPP_DLL void | addAttrib (const std::string &aName, const std::string &aData) throw (SimpleXMLException) |
template<typename T > | |
void | addAttrib (const std::string &aName, const T &aData) throw (SimpleXMLException) |
ADCHPP_DLL void | addChildAttrib (const std::string &aName, const std::string &aData) throw (SimpleXMLException) |
template<typename T > | |
void | addChildAttrib (const std::string &aName, const T &aData) throw (SimpleXMLException) |
void | addTag (const std::string &aName, int64_t aData) throw (SimpleXMLException) |
void | addTag (const std::string &aName, int aData) throw (SimpleXMLException) |
ADCHPP_DLL void | addTag (const std::string &aName, const std::string &aData=Util::emptyString) throw (SimpleXMLException) |
ADCHPP_DLL bool | findChild (const std::string &aName) const throw () |
ADCHPP_DLL void | fromXML (const std::string &aXML) throw (SimpleXMLException) |
bool | getBoolChildAttrib (const std::string &aName) const |
const std::string & | getChildAttrib (const std::string &aName, const std::string &aDefault=Util::emptyString) const |
const std::string & | getChildData () const |
const std::string & | getChildName () const |
const std::string & | getData () const |
int | getIntChildAttrib (const std::string &aName) const |
int64_t | getLongLongChildAttrib (const std::string &aName) const |
void | resetCurrentChild () const throw () |
ADCHPP_DLL | SimpleXML (int numAttribs=0) |
ADCHPP_DLL void | stepIn () const throw (SimpleXMLException) |
ADCHPP_DLL void | stepOut () const throw (SimpleXMLException) |
std::string | toXML () |
ADCHPP_DLL | ~SimpleXML () |
Static Public Member Functions | |
static ADCHPP_DLL void | escape (std::string &aString, bool aAttrib, bool aLoading=false) |
static bool | needsEscape (const std::string &aString, bool aAttrib, bool aLoading=false) |
This is a heurestic for whether escape needs to be called or not. | |
Private Member Functions | |
void | checkChildSelected () const throw () |
Private Attributes | |
int | attribs |
Tag::Ptr | current |
Current position. | |
Tag::Iter | currentChild |
bool | found |
Tag::Ptr | root |
Bogus root tag, should be only one child! |
A simple XML class that loads an XML-ish structure into an internal tree and allows easy access to each element through a "current location".
Definition at line 33 of file SimpleXML.h.
adchpp::SimpleXML::SimpleXML | ( | int | numAttribs = 0 |
) |
Definition at line 27 of file SimpleXML.cpp.
References current, adchpp::Util::emptyString, and root.
adchpp::SimpleXML::~SimpleXML | ( | ) |
Definition at line 31 of file SimpleXML.cpp.
References root.
void adchpp::SimpleXML::addAttrib | ( | const std::string & | aName, | |
const std::string & | aData | |||
) | throw (SimpleXMLException) |
Definition at line 320 of file SimpleXML.cpp.
void adchpp::SimpleXML::addAttrib | ( | const std::string & | aName, | |
const T & | aData | |||
) | throw (SimpleXMLException) [inline] |
Definition at line 48 of file SimpleXML.h.
References adchpp::Util::toString().
void adchpp::SimpleXML::addChildAttrib | ( | const std::string & | aName, | |
const std::string & | aData | |||
) | throw (SimpleXMLException) |
Definition at line 327 of file SimpleXML.cpp.
void adchpp::SimpleXML::addChildAttrib | ( | const std::string & | aName, | |
const T & | aData | |||
) | throw (SimpleXMLException) [inline] |
Definition at line 55 of file SimpleXML.h.
References adchpp::Util::toString().
void adchpp::SimpleXML::addTag | ( | const std::string & | aName, | |
int64_t | aData | |||
) | throw (SimpleXMLException) [inline] |
Definition at line 43 of file SimpleXML.h.
References addTag(), and adchpp::Util::toString().
void adchpp::SimpleXML::addTag | ( | const std::string & | aName, | |
int | aData | |||
) | throw (SimpleXMLException) [inline] |
Definition at line 40 of file SimpleXML.h.
References addTag(), and adchpp::Util::toString().
void adchpp::SimpleXML::addTag | ( | const std::string & | aName, | |
const std::string & | aData = Util::emptyString | |||
) | throw (SimpleXMLException) |
Definition at line 302 of file SimpleXML.cpp.
Referenced by addTag().
void adchpp::SimpleXML::checkChildSelected | ( | ) | const throw () [inline, private] |
Definition at line 180 of file SimpleXML.h.
References adchpp::SimpleXML::Tag::children, current, currentChild, and dcassert.
Referenced by getBoolChildAttrib(), getChildAttrib(), getChildData(), getChildName(), getIntChildAttrib(), getLongLongChildAttrib(), and stepIn().
void adchpp::SimpleXML::escape | ( | std::string & | aString, | |
bool | aAttrib, | |||
bool | aLoading = false | |||
) | [static] |
Definition at line 35 of file SimpleXML.cpp.
References dcasserta.
Referenced by adchpp::SimpleXML::Tag::appendAttribString(), and adchpp::SimpleXML::Tag::toXML().
bool adchpp::SimpleXML::findChild | ( | const std::string & | aName | ) | const throw () |
Definition at line 140 of file SimpleXML.cpp.
References adchpp::SimpleXML::Tag::children, current, currentChild, dcassert, and found.
void adchpp::SimpleXML::fromXML | ( | const std::string & | aXML | ) | throw (SimpleXMLException) |
Definition at line 333 of file SimpleXML.cpp.
References adchpp::Util::emptyString.
bool adchpp::SimpleXML::getBoolChildAttrib | ( | const std::string & | aName | ) | const [inline] |
Definition at line 99 of file SimpleXML.h.
References checkChildSelected(), and getChildAttrib().
const std::string& adchpp::SimpleXML::getChildAttrib | ( | const std::string & | aName, | |
const std::string & | aDefault = Util::emptyString | |||
) | const [inline] |
Definition at line 86 of file SimpleXML.h.
References checkChildSelected().
Referenced by getBoolChildAttrib(), getIntChildAttrib(), and getLongLongChildAttrib().
const std::string& adchpp::SimpleXML::getChildData | ( | ) | const [inline] |
Definition at line 81 of file SimpleXML.h.
References checkChildSelected().
const std::string& adchpp::SimpleXML::getChildName | ( | ) | const [inline] |
Definition at line 76 of file SimpleXML.h.
References checkChildSelected().
const std::string& adchpp::SimpleXML::getData | ( | ) | const [inline] |
Definition at line 60 of file SimpleXML.h.
References current, adchpp::SimpleXML::Tag::data, and dcassert.
int adchpp::SimpleXML::getIntChildAttrib | ( | const std::string & | aName | ) | const [inline] |
Definition at line 91 of file SimpleXML.h.
References checkChildSelected(), getChildAttrib(), and adchpp::Util::toInt().
int64_t adchpp::SimpleXML::getLongLongChildAttrib | ( | const std::string & | aName | ) | const [inline] |
Definition at line 95 of file SimpleXML.h.
References checkChildSelected(), getChildAttrib(), and adchpp::Util::toInt64().
static bool adchpp::SimpleXML::needsEscape | ( | const std::string & | aString, | |
bool | aAttrib, | |||
bool | aLoading = false | |||
) | [inline, static] |
This is a heurestic for whether escape needs to be called or not.
The results are only guaranteed for false, i e sometimes true might be returned even though escape was not needed...
Definition at line 115 of file SimpleXML.h.
Referenced by adchpp::SimpleXML::Tag::appendAttribString(), and adchpp::SimpleXML::Tag::toXML().
void adchpp::SimpleXML::resetCurrentChild | ( | ) | const throw () [inline] |
Definition at line 68 of file SimpleXML.h.
References adchpp::SimpleXML::Tag::children, current, currentChild, dcassert, and found.
void adchpp::SimpleXML::stepIn | ( | ) | const throw (SimpleXMLException) |
Definition at line 156 of file SimpleXML.cpp.
References checkChildSelected(), adchpp::SimpleXML::Tag::children, current, currentChild, and found.
void adchpp::SimpleXML::stepOut | ( | ) | const throw (SimpleXMLException) |
Definition at line 163 of file SimpleXML.cpp.
References current, currentChild, dcassert, found, adchpp::SimpleXML::Tag::parent, and root.
std::string adchpp::SimpleXML::toXML | ( | ) | [inline] |
Definition at line 107 of file SimpleXML.h.
References adchpp::SimpleXML::Tag::children, adchpp::Util::emptyString, and root.
int adchpp::SimpleXML::attribs [private] |
Definition at line 185 of file SimpleXML.h.
Tag::Ptr adchpp::SimpleXML::current [mutable, private] |
Current position.
Definition at line 176 of file SimpleXML.h.
Referenced by checkChildSelected(), findChild(), getData(), resetCurrentChild(), SimpleXML(), stepIn(), and stepOut().
Tag::Iter adchpp::SimpleXML::currentChild [mutable, private] |
Definition at line 178 of file SimpleXML.h.
Referenced by checkChildSelected(), findChild(), resetCurrentChild(), stepIn(), and stepOut().
bool adchpp::SimpleXML::found [mutable, private] |
Definition at line 186 of file SimpleXML.h.
Referenced by findChild(), resetCurrentChild(), stepIn(), and stepOut().
Tag::Ptr adchpp::SimpleXML::root [private] |
Bogus root tag, should be only one child!
Definition at line 173 of file SimpleXML.h.
Referenced by SimpleXML(), stepOut(), toXML(), and ~SimpleXML().