Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | Related Pages

cxmlelement.h

00001 //==========================================================================
00002 //  CXMLELEMENT.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 // Contents:
00007 //   class cXMLElement
00008 //
00009 //==========================================================================
00010 
00011 /*--------------------------------------------------------------*
00012   Copyright (C) 2002-2005 Andras Varga
00013 
00014   This file is distributed WITHOUT ANY WARRANTY. See the file
00015   `license' for details on this and other legal matters.
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 // TBD if namespaces are supported by Expat & libxml in an easy way, maybe do it here
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     // internal: Constructor
00089     cXMLElement(const char *tagname, const char *srcloc, cXMLElement *parent);
00090 
00091     // internal: sets text node within element
00092     virtual void setNodeValue(const char *s, int len);
00093 
00094     // internal: appends to text node within element
00095     virtual void appendNodeValue(const char *s, int len);
00096 
00097     // internal: Destructor. Destroys children too.
00098     virtual ~cXMLElement();
00099 
00100     // internal: Sets the value of the attribute with the given name.
00101     virtual void setAttribute(const char *attr, const char *value);
00102 
00103     // internal: Appends the given element at the end of the child element list.
00104     virtual void appendChild(cXMLElement *node);
00105 
00106     // internal: Inserts the given element just before the specified child element
00107     // in the child element list. The where element must be a child of this element.
00108     virtual void insertChildBefore(cXMLElement *where, cXMLElement *newnode);
00109 
00110     // internal: Removes the given element from the child element list.
00111     // The pointer passed should be a child of this element.
00112     virtual cXMLElement *removeChild(cXMLElement *node);
00113 
00114     // internal: matches from root element
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 

Generated on Fri Apr 1 12:25:33 2005 for OMNeT++/OMNEST Simulation Library by  doxygen 1.3.9.1