16 #ifndef __OMNETPP_CXMLELEMENT_H
17 #define __OMNETPP_CXMLELEMENT_H
22 #include "simkerneldefs.h"
25 #include "opp_pooledstring.h"
35 typedef std::vector<cXMLElement*> cXMLElementList;
40 typedef std::map<std::string,std::string> cXMLAttributeMap;
77 friend class cXMLElementDescriptor;
92 virtual bool resolve(
const char *paramname, std::string& value) = 0;
98 typedef std::pair<opp_pooledstring,opp_pooledstring> Attr;
99 std::vector<Attr> attrs;
108 void doGetElementsByTagName(
const char *tagname, cXMLElementList& list)
const;
128 virtual void setTagName(
const char *tagName) {setName(tagName);}
131 virtual void setSourceLocation(
const char *fname,
int line);
134 virtual void setNodeValue(
const char *s);
137 virtual void setNodeValue(
const char *s,
int len);
140 virtual void appendNodeValue(
const char *s,
int len);
143 virtual void setAttribute(
const char *attr,
const char *value);
146 virtual void setAttributes(
const char **attrs);
149 virtual void appendChild(cXMLElement *node);
153 virtual void insertChildBefore(cXMLElement *where, cXMLElement *newnode);
157 virtual cXMLElement *removeChild(cXMLElement *node);
160 static cXMLElement *getDocumentElementByPath(cXMLElement *documentnode,
const char *pathexpr, ParamResolver *resolver=
nullptr);
164 Attr *findAttr(
const char *name)
const;
165 void addAttr(
const char *name,
const char *value);
166 virtual void print(std::ostream& os,
int indentLevel)
const;
169 int getNumAttrs()
const;
170 const char *getAttrName(
int index)
const;
171 const char *getAttrValue(
int index)
const;
172 std::string getAttrDesc(
int index)
const;
173 int getNumChildren()
const;
174 cXMLElement *getChild(
int index)
const;
182 virtual std::string str()
const override;
192 virtual void forEachChild(cVisitor *v)
override;
217 virtual const char *getSourceLocation()
const;
223 virtual const char *getNodeValue()
const;
229 virtual const char *getAttribute(
const char *attr)
const;
234 virtual bool hasAttributes()
const;
239 virtual cXMLAttributeMap getAttributes()
const;
244 virtual std::string getXML()
const;
257 virtual bool hasChildren()
const;
299 virtual cXMLElement *getFirstChildWithTag(
const char *tagname)
const;
315 virtual cXMLElement *getNextSiblingWithTag(
const char *tagname)
const;
320 virtual cXMLElementList getChildren()
const;
325 virtual cXMLElementList getChildrenByTagName(
const char *tagname)
const;
331 virtual cXMLElementList getElementsByTagName(
const char *tagname)
const;
342 virtual cXMLElement *getFirstChildWithAttribute(
const char *tagname,
const char *attr,
const char *attrvalue=
nullptr)
const;
349 virtual cXMLElement *getElementById(
const char *idattrvalue)
const;
380 virtual cXMLElement *getElementByPath(
const char *pathexpression,
cXMLElement *root=
nullptr, ParamResolver *resolver=
nullptr)
const;
397 virtual bool resolve(
const char *paramname, std::string& value)
override;
409 typedef std::map<std::string,std::string> StringMap;
414 virtual bool resolve(
const char *paramname, std::string& value)
override;