Go to the documentation of this file.
52 name_(name), value_(
""), parent_(parent) {
66 name_(old.name_), value_(old.value_), parent_(NULL),
67 attributes_(old.attributes_) {
101 const std::string& name,
102 const std::string& value) {
104 AttributeTable::iterator iter =
attributes_.begin();
106 if ((*iter).name ==
name) {
107 (*iter).value = value;
114 newAttribute.
value = value;
206 AttributeTable::const_iterator iter =
attributes_.begin();
208 if ((*iter).name ==
name) {
230 const string procName =
"ObjectState::attribute";
232 errorMsg +=
"Requested attribute by index '";
234 errorMsg +=
"' which is out of range.";
235 throw OutOfRange(__FILE__, __LINE__, procName, errorMsg);
250 AttributeTable::const_iterator iter =
attributes_.begin();
252 if ((*iter).name ==
name) {
253 return (*iter).value;
258 string procName =
"ObjectState::stringAttribute";
260 errorMsg +=
"Requested attribute by name '";
262 errorMsg +=
"' which doesn't exist.";
263 throw KeyNotFound(__FILE__, __LINE__, procName, errorMsg);
345 const string procName =
"ObjectState::boolAttribute";
359 ChildTable::const_iterator iter =
children_.begin();
361 if ((*iter)->name() ==
name) {
394 const string procName =
"ObjectState::removeChild";
409 if (newChild->
parent() != NULL) {
410 const string procName =
"ObjectState::replaceChild";
414 ChildTable::iterator it =
children_.begin();
418 ChildTable::iterator pt = it;
444 ChildTable::const_iterator iter =
children_.begin();
446 if ((*iter)->name() ==
name) {
452 string procName =
"ObjectState::childByName";
454 errorMsg +=
"Requested child by name '";
456 errorMsg +=
"' which doesn't exist.";
473 const string procName =
"ObjectState::child";
475 errorMsg +=
"Requested child by index '";
477 errorMsg +=
"' which is out of range.";
478 throw OutOfRange(__FILE__, __LINE__, procName, errorMsg);
495 children_.size() !=
static_cast<unsigned int>(
object.childCount()) ||
496 static_cast<int>(
attributes_.size()) !=
object.attributeCount()) {
506 if (attr.
value !=
object.stringAttribute(attr.
name)) {
512 for (
size_t i = 0; i <
children_.size(); i++) {
515 if (
child != compare) {
530 string errorMsg =
"ObjectState ";
542 std::ostream& output,
543 const std::string& identation) {
548 cout << identation <<
"Name: "<< state.
name() <<
" ";
554 cout << identation <<
"Attr: " << state.
attribute(i)->
name <<
" = "
557 for (
int i = 0; i < state.
childCount(); i++) {
AttributeTable attributes_
Contains all the attributes of the element.
bool hasAttribute(const std::string &name) const
Attribute * attribute(int index) const
Struct for describing an attribute of the XML element.
std::string stringAttribute(const std::string &name) const
std::string name
Name of the attribute.
std::string value
Value of the attribute.
ULongWord uLongAttribute(const std::string &name) const
std::string value_
The value of a leaf element.
bool operator!=(const ObjectState &object)
ChildTable children_
The child elements.
static std::string toString(const T &source)
void replaceChild(ObjectState *old, ObjectState *newChild)
ObjectState * childByName(const std::string &name) const
#define assert(condition)
static double toDouble(const T &source)
static void dumpObjectState(const ObjectState &state, std::ostream &output, const std::string &identation="")
ObjectState(const std::string &name, ObjectState *parent=NULL)
std::string commonErrorMessage() const
ObjectState * child(int index) const
void addChild(ObjectState *child)
bool hasChild(const std::string &name) const
static unsigned int toUnsignedInt(const T &source)
ObjectState * parent() const
double doubleAttribute(const std::string &name) const
unsigned int unsignedIntAttribute(const std::string &name) const
void removeChild(ObjectState *child)
bool boolAttribute(const std::string &name) const
ObjectState * parent_
The parent element.
std::string stringValue() const
int intAttribute(const std::string &name) const
static int toInt(const T &source)
static ULongWord toUnsignedLong(const T &source)
void setAttribute(const std::string &name, const std::string &value)
std::string name_
Name of the element.
int attributeCount() const