00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _CXMLElement
00028 #define _CXMLElement
00029 #include "libMRML/include/uses-declarations.h"
00030 #include <map>
00031 #include <list>
00032 #include <string>
00033 #include "libMRML/include/CMagic.h"
00034 #include "libMRML/include/CAttributeList.h"
00035 class CXMLElementVisitor;
00036 #include "libMRML/include/CMutex.h"
00037 #include "libMRML/include/CNoDelete.h"
00049 class CXMLElement:public CMagic,public CNoDelete{
00050 public:
00052 typedef list<CXMLElement*> lCChildren;
00053 protected:
00055 CXMLElement* mFather;
00057 CXMLElement* mCurrentChild;
00058 protected:
00060 lCChildren mChildren;
00062 CAttributeList mAttributes;
00064 string mName;
00066 void setFather(CXMLElement*);
00067
00072 string mText;
00079 const int mTypeOfNode;
00080 public:
00084 static int const cTextNode;
00088 static int const cElementNode;
00089
00090 public:
00092 CXMLElement* getFather()const;
00093
00095 void addAttribute(const string& inAttribute,long inValue);
00097 void addAttribute(const string& inAttribute,double inValue);
00099 void addAttribute(const string& inAttribute,const string& inValue);
00100
00107 pair<bool,bool> boolReadAttribute(const string& inAttribute)const;
00109 pair<bool,long> longReadAttribute(const string& inAttribute)const;
00111 pair<bool,double> doubleReadAttribute(const string& inAttribute)const;
00121 virtual pair<bool,string> stringReadAttribute(const string& inAttribute)const;
00122
00130 CXMLElement* clone(bool inDeep=true)const;
00131
00135 void toXML(string& outString,const int=0)const;
00139 void traverse(CXMLElementVisitor& inoutVisitor)const;
00143 void traverse(CXMLElementVisitor& inoutVisitor);
00144
00146 list<CXMLElement*>::const_iterator child_list_begin()const;
00149 list<CXMLElement*>::const_iterator child_list_end()const;
00151 list<CXMLElement*>::iterator child_list_begin();
00154 list<CXMLElement*>::iterator child_list_end();
00155
00156
00161 virtual void addChild(CXMLElement* inChild);
00167 virtual void addChild(const string&,
00168 const char* const* const inAttributeList=0);
00169
00173 void moveUp();
00178 bool isSubtreeFinished()const;
00179
00184 CXMLElement(const string&,
00185 const char* const* const inAttributeList=0);
00187 virtual ~CXMLElement();
00191 CXMLElement(const int inType,
00192 const string&);
00194 CXMLElement(const string& inString,
00195 const list< pair<string,string> >& inList);
00197 CXMLElement(const string& inString,
00198 const CAttributeList& inList);
00202 CXMLElement(const CXMLElement& in);
00208 list<pair<string,string> >* createNamedValueList()const;
00210 string getText()const;
00212 string getName()const;
00214 int getTypeOfNode()const;
00216 int getNumberOfAttributes()const;
00218 void check()const;
00219
00220 };
00221
00222 #endif