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
00028
00029 #ifndef _CXMLElement
00030 #define _CXMLElement
00031 #include "libMRML/include/uses-declarations.h"
00032 #include <map>
00033 #include <list>
00034 #include <string>
00035 #include "libMRML/include/CMagic.h"
00036 #include "libMRML/include/CAttributeList.h"
00037 class CXMLElementVisitor;
00038 #include "libMRML/include/CMutex.h"
00039 #include "libMRML/include/CNoDelete.h"
00051 class CXMLElement:public CMagic,public CNoDelete{
00052 public:
00054 typedef list<CXMLElement*> lCChildren;
00055 protected:
00057 CXMLElement* mFather;
00059 CXMLElement* mCurrentChild;
00060 protected:
00062 lCChildren mChildren;
00064 CAttributeList mAttributes;
00066 string mName;
00068 void setFather(CXMLElement*);
00069
00074 string mText;
00081 const int mTypeOfNode;
00082 public:
00086 static int const cTextNode;
00090 static int const cElementNode;
00091
00092 public:
00094 CXMLElement* getFather()const;
00095
00097 void addAttribute(const string& inAttribute,long inValue);
00099 void addAttribute(const string& inAttribute,double inValue);
00101 void addAttribute(const string& inAttribute,const string& inValue);
00102
00109 pair<bool,bool> boolReadAttribute(const string& inAttribute)const;
00111 pair<bool,long> longReadAttribute(const string& inAttribute)const;
00113 pair<bool,double> doubleReadAttribute(const string& inAttribute)const;
00123 virtual pair<bool,string> stringReadAttribute(const string& inAttribute)const;
00124
00132 CXMLElement* clone(bool inDeep=true)const;
00133
00137 void toXML(string& outString,const int=0)const;
00141 void traverse(CXMLElementVisitor& inoutVisitor)const;
00145 void traverse(CXMLElementVisitor& inoutVisitor);
00146
00148 list<CXMLElement*>::const_iterator child_list_begin()const;
00151 list<CXMLElement*>::const_iterator child_list_end()const;
00153 list<CXMLElement*>::iterator child_list_begin();
00156 list<CXMLElement*>::iterator child_list_end();
00157
00158
00163 virtual void addChild(CXMLElement* inChild);
00169 virtual void addChild(const string&,
00170 const char* const* const inAttributeList=0);
00171
00175 void moveUp();
00180 bool isSubtreeFinished()const;
00181
00186 CXMLElement(const string&,
00187 const char* const* const inAttributeList=0);
00189 virtual ~CXMLElement();
00193 CXMLElement(const int inType,
00194 const string&);
00196 CXMLElement(const string& inString,
00197 const list< pair<string,string> >& inList);
00199 CXMLElement(const string& inString,
00200 const CAttributeList& inList);
00204 CXMLElement(const CXMLElement& in);
00210 list<pair<string,string> >* createNamedValueList()const;
00212 string getText()const;
00214 string getName()const;
00216 int getTypeOfNode()const;
00218 int getNumberOfAttributes()const;
00220 void check()const;
00221
00222 };
00223
00224 #endif