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
00036 class CLASSEXPORT skTreeNodeListIterator
00037 {
00038 public:
00042 skTreeNodeListIterator(const skTreeNode&);
00046 ~skTreeNodeListIterator();
00050 skTreeNode * operator ()();
00054 void reset();
00055 private:
00056 const skTreeNode& m_Node;
00057 USize m_Index;
00058 };
00059
00065 class CLASSEXPORT skTreeNode
00066 {
00067 public:
00071 skTreeNode();
00075 virtual ~skTreeNode();
00079 skTreeNode(const skTreeNode& );
00083 skTreeNode(const skString& label);
00087 skTreeNode(const skString& label,const skString& data);
00091 skTreeNode(const skString& label,bool data);
00095 skTreeNode(const skString& label,int data);
00099 skTreeNode(const skString& label,float data);
00103 skTreeNode& operator=(const skTreeNode& );
00107 skString label() const;
00111 void label(const skString& s);
00115 skString data() const;
00119 void data(const skString& s);
00123 bool boolData() const;
00127 void boolData(bool);
00131 int intData() const;
00135 void intData(int);
00139 float floatData() const;
00143 void floatData(float);
00147 void prependChild(skTreeNode*);
00151 void addChild(skTreeNode*);
00155 void setChild(skTreeNode*);
00159 void deleteChild(skTreeNode*);
00163 bool containsChild(skTreeNode*);
00168 skTreeNode* findChild(const skString& label) const;
00173 skTreeNode* findChild(const skString& label,const skString& data) const;
00180 skString findChildData(const skString& label,const skString& defaultVal=skString()) const;
00187 bool findChildboolData(const skString& label, bool defaultVal=false) const;
00194 int findChildIntData(const skString& label, int defaultVal=0) const;
00201 float findChildFloatData(const skString& label, float defaultVal=0.0f) const;
00205 skString nthChildData(USize index) const;
00209 int nthChildIntData(USize index) const;
00210 #ifdef STREAMS_ENABLED
00211
00214 void write(ostream& out,USize tabstops) const;
00215 #endif
00216
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();
00250 static skTreeNode * read(const skString& file,skExecutableContext& ctxt);
00251 friend class skTreeNodeList;
00252 friend class skTreeNodeListIterator;
00253
00254 private:
00258 skString m_Label;
00262 skString m_Data;
00266 skTreeNodeList * m_Items;
00267 };
00271 class CLASSEXPORT skTreeNodeReader
00272 {
00273 public:
00274 #ifdef STREAMS_ENABLED
00275
00278 skTreeNodeReader(istream& in);
00282 skTreeNodeReader(istream& in,skString fileName);
00283 #else
00284
00287 skTreeNodeReader(FILE * in);
00291 skTreeNodeReader(FILE * in,skString fileName);
00292 #endif
00293
00296 ~skTreeNodeReader();
00303 skTreeNode* read(skExecutableContext& ctxt);
00304 private:
00305 class P_TreeNodeReader* pimp;
00306 };
00307
00311 class CLASSEXPORT skTreeNodeReaderException : public skException
00312 {
00313 public:
00317 skTreeNodeReaderException(const skString& fileName,const skString& msg)
00318 : m_FileName(fileName),m_Msg(msg){
00319 }
00323 skString toString() const{
00324 return m_FileName+skSTR(":")+m_Msg;
00325 }
00326 private:
00327 skString m_FileName;
00328 skString m_Msg;
00329 };
00330
00331 #endif
00332
00333
00334
00335
00336
00337
00338
00339
00340