00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TREENODE_H
00024 #define TREENODE_H
00025
00026 #include "skString.h"
00027 #include "skException.h"
00028
00029 class CLASSEXPORT skTreeNode;
00030 class CLASSEXPORT skTreeNodeList;
00031 class CLASSEXPORT skExecutableContext;
00032 class CLASSEXPORT skInputSource;
00033 class CLASSEXPORT skOutputDestination;
00034
00038 class CLASSEXPORT skTreeNodeListIterator
00039 {
00040 public:
00044 skTreeNodeListIterator(const skTreeNode&);
00048 ~skTreeNodeListIterator();
00052 skTreeNode * operator ()();
00056 void reset();
00057 private:
00058 const skTreeNode& m_Node;
00059 USize m_Index;
00060 };
00061
00067 class CLASSEXPORT skTreeNode
00068 {
00069 public:
00073 skTreeNode();
00077 virtual ~skTreeNode();
00081 skTreeNode(const skTreeNode& );
00085 skTreeNode(const skString& label);
00089 skTreeNode(const skString& label,const skString& data);
00093 skTreeNode(const skString& label,bool data);
00097 skTreeNode(const skString& label,int data);
00101 skTreeNode(const skString& label,float data);
00105 skTreeNode& operator=(const skTreeNode& );
00109 skString label() const;
00113 void label(const skString& s);
00117 skString data() const;
00121 void data(const skString& s);
00125 bool boolData() const;
00129 void boolData(bool);
00133 int intData() const;
00137 void intData(int);
00141 float floatData() const;
00145 void floatData(float);
00149 void prependChild(skTreeNode*);
00153 void addChild(skTreeNode*);
00157 void setChild(skTreeNode*);
00161 void removeChild(skTreeNode*);
00165 void deleteChild(skTreeNode*);
00169 bool containsChild(skTreeNode*);
00174 skTreeNode* findChild(const skString& label) const;
00179 skTreeNode* findChild(const skString& label,const skString& data) const;
00186 skString findChildData(const skString& label,const skString& defaultVal=skString()) const;
00193 bool findChildboolData(const skString& label, bool defaultVal=false) const;
00200 int findChildIntData(const skString& label, int defaultVal=0) const;
00207 float findChildFloatData(const skString& label, float defaultVal=0.0f) const;
00211 skString nthChildData(USize index) const;
00215 int nthChildIntData(USize index) const;
00219 void write(skOutputDestination& out,USize tabstops) const;
00224 bool write(const skString& file) const;
00231 skTreeNode * nthChild(USize i) const;
00235 USize numChildren() const;
00239 void copyItems(skTreeNode& node);
00243 void moveItemsFrom(skTreeNode& node);
00247 void clear();
00254 static skTreeNode * read(const skString& file,skExecutableContext& ctxt);
00255 friend class skTreeNodeList;
00256 friend class skTreeNodeListIterator;
00257
00258 private:
00262 skString m_Label;
00266 skString m_Data;
00270 skTreeNodeList * m_Items;
00271 };
00275 class CLASSEXPORT skTreeNodeReader
00276 {
00277 public:
00278 skTreeNodeReader(skInputSource& in, const skString& source_name);
00282 ~skTreeNodeReader();
00289 skTreeNode* read(skExecutableContext& ctxt);
00290 private:
00291 class P_TreeNodeReader* pimp;
00292 };
00293
00297 class CLASSEXPORT skTreeNodeReaderException : public skException
00298 {
00299 public:
00303 skTreeNodeReaderException(const skString& fileName,const skString& msg)
00304 : m_FileName(fileName),m_Msg(msg){
00305 }
00309 skString toString() const{
00310 return m_FileName+skSTR(":")+m_Msg;
00311 }
00312 private:
00313 skString m_FileName;
00314 skString m_Msg;
00315 };
00316
00317 #endif
00318
00319
00320
00321
00322
00323
00324
00325
00326