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;
99 typedef std::pair<opp_pooledstring,opp_pooledstring> Attr;
100 std::vector<Attr> attrs;
109 void doGetElementsByTagName(
const char *tagname, cXMLElementList& list)
const;
119 virtual void setSourceLocation(
const char *fname,
int line);
122 virtual void setNodeValue(
const char *s);
125 virtual void setNodeValue(
const char *s,
int len);
128 virtual void appendNodeValue(
const char *s,
int len);
134 virtual void setAttribute(
const char *attr,
const char *value);
137 virtual void setAttributes(
const char **attrs);
151 static cXMLElement *getDocumentElementByPath(
cXMLElement *documentnode,
const char *pathexpr, ParamResolver *resolver=
nullptr);
155 Attr *findAttr(
const char *name)
const;
156 void addAttr(
const char *name,
const char *value);
157 virtual void print(std::ostream& os,
int indentLevel)
const;
160 int getNumAttrs()
const;
161 const char *getAttrName(
int index)
const;
162 const char *getAttrValue(
int index)
const;
163 std::string getAttrDesc(
int index)
const;
164 int getNumChildren()
const;
173 virtual const char *
getName()
const override {
return getTagName();}
178 virtual std::string str()
const override;
193 virtual void forEachChild(
cVisitor *v)
override;
202 virtual const char *getTagName()
const;
218 virtual const char *getSourceLocation()
const;
224 virtual const char *getNodeValue()
const;
230 virtual const char *getAttribute(
const char *attr)
const;
235 virtual bool hasAttributes()
const;
240 virtual cXMLAttributeMap getAttributes()
const;
245 virtual std::string getXML()
const;
258 virtual bool hasChildren()
const;
300 virtual cXMLElement *getFirstChildWithTag(
const char *tagname)
const;
316 virtual cXMLElement *getNextSiblingWithTag(
const char *tagname)
const;
321 virtual cXMLElementList getChildren()
const;
326 virtual cXMLElementList getChildrenByTagName(
const char *tagname)
const;
332 virtual cXMLElementList getElementsByTagName(
const char *tagname)
const;
343 virtual cXMLElement *getFirstChildWithAttribute(
const char *tagname,
const char *attr,
const char *attrvalue=
nullptr)
const;
350 virtual cXMLElement *getElementById(
const char *idattrvalue)
const;
381 virtual cXMLElement *getElementByPath(
const char *pathexpression,
cXMLElement *root=
nullptr, ParamResolver *resolver=
nullptr)
const;
398 virtual bool resolve(
const char *paramname, std::string& value)
override;
410 typedef std::map<std::string,std::string> StringMap;
415 virtual bool resolve(
const char *paramname, std::string& value)
override;