pcce::XmlNode Class Reference

#include <XmlNode.h>

List of all members.

Public Member Functions

 XmlNode (XmlDoc *doc, TiXmlElement *element)
const std::string GetName () const
XmlNodeGetNextSibling () const
XmlNodeGetNextSibling (const std::string &nodeName) const
XmlNodeGetPrevSibling () const
XmlNodeGetPrevSibling (const std::string &nodeName) const
XmlNodeGetFirstChild () const
XmlNodeGetFirstChild (const std::string &nodeName) const
XmlNodeCreateChild (const std::string &nodeName)
XmlNodeGetParent () const
const Variant GetAttribute (const std::string &name) const
void SetAttribute (const std::string &name, Variant value)
const tPropertyBagPtrGetAttributes () const

Private Member Functions

void BuildAttributes ()

Private Attributes

XmlDocmDoc
TiXmlElement * mElement
tPropertyBagPtr mAttributes

Friends

bool operator== (const XmlNode &a, const XmlNode &b)
bool operator!= (const XmlNode &a, const XmlNode &b)
bool operator== (const XmlNode &a, const void *b)
bool operator!= (const XmlNode &a, const void *b)


Detailed Description

Definition at line 46 of file XmlNode.h.


Constructor & Destructor Documentation

XmlNode::XmlNode ( XmlDoc doc,
TiXmlElement *  element 
)

Definition at line 41 of file XmlNode.cpp.

References BuildAttributes(), mDoc, mElement, and PCCE_CHECK.

00041                                                   : mDoc(doc), mElement(element), mAttributes(new PropertyBag()) {
00042   PCCE_CHECK(mDoc != NULL, "XmlNode: Doc is NULL");
00043   PCCE_CHECK(mElement != NULL, "XmlNode: Element is NULL");
00044   BuildAttributes();
00045 }


Member Function Documentation

const std::string XmlNode::GetName (  )  const

Definition at line 47 of file XmlNode.cpp.

References mElement.

00047                                        {
00048   return mElement->ValueStr();
00049 }

XmlNode * XmlNode::GetNextSibling (  )  const

Definition at line 51 of file XmlNode.cpp.

References mDoc, mElement, and pcce::XmlDoc::NodeFromElement().

00051                                        {
00052   TiXmlElement* element = mElement->NextSiblingElement();
00053   if (element == NULL) {
00054     return NULL;
00055   } else {
00056     return mDoc->NodeFromElement(element);
00057   }
00058 }

XmlNode* pcce::XmlNode::GetNextSibling ( const std::string &  nodeName  )  const

XmlNode * XmlNode::GetPrevSibling (  )  const

Definition at line 69 of file XmlNode.cpp.

References mDoc, mElement, and pcce::XmlDoc::NodeFromElement().

00069                                        {
00070   TiXmlNode* node = mElement->PreviousSibling();
00071   if (node == NULL) {
00072     return NULL;
00073   } else {
00074     return mDoc->NodeFromElement(node->ToElement());
00075   }
00076 }

XmlNode* pcce::XmlNode::GetPrevSibling ( const std::string &  nodeName  )  const

XmlNode * XmlNode::GetFirstChild (  )  const

Definition at line 87 of file XmlNode.cpp.

References mDoc, mElement, and pcce::XmlDoc::NodeFromElement().

00087                                       {
00088   TiXmlElement* element = mElement->FirstChildElement();
00089   if (element == NULL) {
00090     return NULL;
00091   } else {
00092     return mDoc->NodeFromElement(element);
00093   }
00094 }

XmlNode* pcce::XmlNode::GetFirstChild ( const std::string &  nodeName  )  const

XmlNode* pcce::XmlNode::CreateChild ( const std::string &  nodeName  ) 

XmlNode * XmlNode::GetParent (  )  const

Definition at line 113 of file XmlNode.cpp.

References mDoc, mElement, and pcce::XmlDoc::NodeFromElement().

00113                                   {
00114   TiXmlNode* node = mElement->Parent();
00115   if (node == NULL) {
00116     return NULL;
00117   } else {
00118     return mDoc->NodeFromElement(node->ToElement());
00119   }
00120 }

const Variant pcce::XmlNode::GetAttribute ( const std::string &  name  )  const

void XmlNode::SetAttribute ( const std::string &  name,
Variant  value 
)

Definition at line 128 of file XmlNode.cpp.

References pcce::Variant::AsString(), mAttributes, and mElement.

00128                                                                {
00129   mAttributes->AddProperty(name);
00130   mAttributes->SetValue(name, value);
00131   mElement->SetAttribute(name, value.AsString());
00132 }

const tPropertyBagPtr & XmlNode::GetAttributes (  )  const

Definition at line 134 of file XmlNode.cpp.

References mAttributes.

00134                                                     {
00135   return mAttributes;
00136 }

void XmlNode::BuildAttributes (  )  [private]

Definition at line 138 of file XmlNode.cpp.

References mAttributes, mElement, and PCCE_CHECK.

Referenced by XmlNode().

00138                               {
00139   for (const TiXmlAttribute* a = mElement->FirstAttribute(); a != NULL; a = a->Next()) {
00140     string name = a->NameTStr();
00141     PCCE_CHECK(!mAttributes->HasProperty(name), "XmlNode has duplicate attribute names");
00142     mAttributes->AddProperty(name);
00143     mAttributes->SetValue(name, a->ValueStr());
00144   }
00145 }


Friends And Related Function Documentation

bool operator== ( const XmlNode a,
const XmlNode b 
) [friend]

Definition at line 82 of file XmlNode.h.

00082                                                              {
00083     return a.mElement == b.mElement;
00084   }

bool operator!= ( const XmlNode a,
const XmlNode b 
) [friend]

Definition at line 86 of file XmlNode.h.

00086                                                              {
00087     return a.mElement != b.mElement;
00088   }

bool operator== ( const XmlNode a,
const void *  b 
) [friend]

Definition at line 90 of file XmlNode.h.

00090                                                           {
00091     return a.mElement == b;
00092   }

bool operator!= ( const XmlNode a,
const void *  b 
) [friend]

Definition at line 94 of file XmlNode.h.

00094                                                           {
00095     return a.mElement != b;
00096   }


Member Data Documentation

Definition at line 75 of file XmlNode.h.

Referenced by GetFirstChild(), GetNextSibling(), GetParent(), GetPrevSibling(), and XmlNode().

TiXmlElement* pcce::XmlNode::mElement [private]

Definition at line 77 of file XmlNode.h.

Referenced by BuildAttributes(), GetAttributes(), and SetAttribute().


The documentation for this class was generated from the following files:

Generated on Thu Mar 6 11:39:28 2008 for Protocce by  doxygen 1.5.5