00001 00002 00003 00004 00005 00006
00007
00008
00009 #ifndef TREENODE_H
00010 #define TREENODE_H
00011
00012 #include "skString.h"
00013
00014 class skTreeNode;
00015 class skTreeNodeList;
00016
00020 class skTreeNodeListIterator
00021 {
00022 public:
00026 skTreeNodeListIterator(const skTreeNode&);
00030 ~skTreeNodeListIterator();
00034 skTreeNode * operator ()();
00038 void reset();
00039 private:
00040 const skTreeNode& m_Node;
00041 USize m_Index;
00042 };
00043
00048 class skTreeNode
00049 {
00050 public:
00054 skTreeNode();
00058 virtual ~skTreeNode();
00062 skTreeNode(const skTreeNode& );
00066 skTreeNode(const skString& label);
00070 skTreeNode(const skString& label,const skString& data);
00074 skTreeNode(const skString& label,bool data);
00078 skTreeNode(const skString& label,int data);
00082 skTreeNode(const skString& label,long data);
00086 skTreeNode(const skString& label,float data);
00090 skTreeNode& operator=(const skTreeNode& );
00094 skString label() const;
00098 void label(const skString& s);
00102 skString data() const;
00106 void data(const skString& s);
00110 bool boolData() const;
00114 void boolData(bool);
00118 int intData() const;
00122 void intData(int);
00126 long longData() const;
00130 void longData(long);
00134 float floatData() const;
00138 void floatData(float);
00142 void prependChild(skTreeNode*);
00146 void addChild(skTreeNode*);
00150 void setChild(skTreeNode*);
00154 void deleteChild(skTreeNode*);
00158 bool containsChild(skTreeNode*);
00163 skTreeNode* findChild(const skString& label) const;
00168 skTreeNode* findChild(const skString& label,const skString& data) const;
00175 skString findChildData(const skString& label,const skString& defaultVal) const;
00182 bool findChildboolData(const skString& label, bool defaultVal=false) const;
00189 int findChildIntData(const skString& label, int defaultVal=0) const;
00196 long findChildLongData(const skString& label, long defaultVal=0) const;
00203 float findChildFloatData(const skString& label, float defaultVal=0.0f) const;
00207 skString nthChildData(USize index) const;
00211 int nthChildIntData(USize index) const;
00215 void write(ostream& out,USize tabstops) const;
00220 bool write(const skString& file) const;
00227 skTreeNode * nthChild(USize i) const;
00231 USize numChildren() const;
00235 void copyItems(skTreeNode& node);
00239 void moveItemsFrom(skTreeNode& node);
00243 void clear();
00248 static skTreeNode * read(const skString& file);
00249
00250 friend class skTreeNodeList;
00251 friend class skTreeNodeListIterator;
00252
00253 private:
00257 skString m_Label;
00261 skString m_Data;
00265 skTreeNodeList * m_Items;
00266 };
00270 class skTreeNodeReader
00271 {
00272 public:
00276 skTreeNodeReader(istream& in);
00280 skTreeNodeReader(istream& in,const char * fileName);
00284 ~skTreeNodeReader();
00290 skTreeNode* read();
00291 private:
00292 class P_TreeNodeReader* pimp;
00293 };
00297 class skTreeNodeReaderException {
00298 public:
00302 skTreeNodeReaderException(const skString& fileName,const skString& msg)
00303 : m_FileName(fileName),m_Msg(msg){
00304 }
00308 skString toString(){
00309 return m_FileName+":"+m_Msg;
00310 }
00311 private:
00312 skString m_FileName;
00313 skString m_Msg;
00314 };
00315
00316 #endif
00317
00318
00319
00320
00321
00322
00323
00324
00325