00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CXMLELEMENT_H
00019 #define __CXMLELEMENT_H
00020
00021 #include <string>
00022 #include <map>
00023 #include <vector>
00024 #include "defs.h"
00025
00026 class cXMLElement;
00027
00031 typedef std::vector<cXMLElement*> cXMLElementList;
00032
00036 typedef std::map<std::string,std::string> cXMLAttributeMap;
00037
00038
00070
00071 class SIM_API cXMLElement
00072 {
00073 private:
00074 std::string ename;
00075 std::string srcloc;
00076 std::string value;
00077 cXMLAttributeMap attrs;
00078 cXMLElement *parent;
00079 cXMLElement *firstchild;
00080 cXMLElement *lastchild;
00081 cXMLElement *prevsibling;
00082 cXMLElement *nextsibling;
00083
00084 private:
00085 void doGetElementsByTagName(const char *tagname, cXMLElementList& list) const;
00086
00087 public:
00088
00089 cXMLElement(const char *tagname, const char *srcloc, cXMLElement *parent);
00090
00091
00092 virtual void setNodeValue(const char *s, int len);
00093
00094
00095 virtual void appendNodeValue(const char *s, int len);
00096
00097
00098 virtual ~cXMLElement();
00099
00100
00101 virtual void setAttribute(const char *attr, const char *value);
00102
00103
00104 virtual void appendChild(cXMLElement *node);
00105
00106
00107
00108 virtual void insertChildBefore(cXMLElement *where, cXMLElement *newnode);
00109
00110
00111
00112 virtual cXMLElement *removeChild(cXMLElement *node);
00113
00114
00115 static cXMLElement *getDocumentElementByPath(cXMLElement *documentnode, const char *pathexpr);
00116
00119
00123 virtual const char *getTagName() const;
00124
00129 virtual const char *getSourceLocation() const;
00130
00135 virtual const char *getNodeValue() const;
00136
00141 virtual const char *getAttribute(const char *attr) const;
00142
00146 virtual bool hasAttributes() const;
00147
00151 virtual const cXMLAttributeMap& getAttributes() const;
00153
00159 virtual cXMLElement *getParentNode() const;
00160
00164 virtual bool hasChildren() const;
00165
00170 virtual cXMLElement *getFirstChild() const;
00171
00176 virtual cXMLElement *getLastChild() const;
00177
00193 virtual cXMLElement *getNextSibling() const;
00194
00200 virtual cXMLElement *getPreviousSibling() const;
00201
00205 virtual cXMLElementList getChildren() const;
00206
00210 virtual cXMLElementList getChildrenByTagName(const char *tagname) const;
00211
00216 virtual cXMLElementList getElementsByTagName(const char *tagname);
00218
00227 cXMLElement *getFirstChildWithAttribute(const char *tagname, const char *attr, const char *attrvalue=NULL) const;
00228
00234 cXMLElement *getElementById(const char *idattrvalue);
00235
00265 cXMLElement *getElementByPath(const char *pathexpression);
00266
00273 void debugDump(int depth=0) const;
00275 };
00276
00277 #endif
00278