Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skTreeNode.h

00001 /*
00002   Copyright 1996-2001
00003   Simon Whiteside
00004 
00005  * $Id: skTreeNode_h-source.html,v 1.19 2001/11/05 19:22:33 sdw Exp $
00006 */
00007 
00008 
00009 #ifndef TREENODE_H
00010 #define TREENODE_H
00011 
00012 #include "skString.h"
00013 
00014 class  CLASSEXPORT skTreeNode;
00015 class  CLASSEXPORT skTreeNodeList;
00016 
00020 class  CLASSEXPORT 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  CLASSEXPORT 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,float data);
00086   skTreeNode& operator=(const skTreeNode& );
00090   skString label() const;
00094   void  label(const skString& s);
00098   skString data() const;
00102   void  data(const skString& s);
00106   bool  boolData() const;
00110   void  boolData(bool);
00114   int   intData() const;
00118   void  intData(int);
00122   float floatData() const;
00126   void  floatData(float);
00130   void  prependChild(skTreeNode*);
00134   void  addChild(skTreeNode*);
00138   void  setChild(skTreeNode*);  
00142   void  deleteChild(skTreeNode*);
00146   bool  containsChild(skTreeNode*);
00151   skTreeNode* findChild(const skString& label) const;
00156   skTreeNode* findChild(const skString& label,const skString& data) const;
00163   skString findChildData(const skString& label,const skString& defaultVal) const;
00170   bool  findChildboolData(const skString& label, bool defaultVal=false) const;
00177   int   findChildIntData(const skString& label, int defaultVal=0) const;
00184   float findChildFloatData(const skString& label, float defaultVal=0.0f) const;
00188   skString nthChildData(USize index) const;
00192   int   nthChildIntData(USize index) const;
00193 #ifdef STREAMS_ENABLED
00194 
00197   void  write(ostream& out,USize tabstops) const;
00198 #endif
00199 
00203   bool  write(const skString& file) const;
00210   skTreeNode *  nthChild(USize  i) const;
00214   USize numChildren() const;
00218   void  copyItems(skTreeNode& node);
00222   void  moveItemsFrom(skTreeNode& node);
00226   void  clear();
00231   static skTreeNode * read(const skString& file);
00232  
00233   friend class skTreeNodeList;
00234   friend class skTreeNodeListIterator;
00235 
00236  private:
00240   skString m_Label;
00244   skString m_Data;
00248   skTreeNodeList * m_Items;
00249 };
00253 class  CLASSEXPORT skTreeNodeReader 
00254 {
00255  public:
00256 #ifdef STREAMS_ENABLED
00257 
00260   skTreeNodeReader(istream& in);
00264   skTreeNodeReader(istream& in,const char *  fileName);
00265 #endif
00266 
00269   ~skTreeNodeReader();
00275   skTreeNode* read();
00276  private:
00277   class P_TreeNodeReader* pimp;
00278 };
00279 const int skTreeNodeReaderException_Code=4;
00280 
00284 class CLASSEXPORT  skTreeNodeReaderException {
00285  public:
00289   skTreeNodeReaderException(const skString& fileName,const skString& msg)
00290     : m_FileName(fileName),m_Msg(msg){
00291   }
00295   skString toString(){
00296     return m_FileName+skSTR(":")+m_Msg;
00297   }
00298  private:
00299   skString m_FileName;
00300   skString m_Msg;
00301 };
00302 
00303 #endif
00304                         
00305 
00306 
00307 
00308 
00309 
00310 
00311 
00312 

Generated at Mon Nov 5 19:22:25 2001 for Simkin by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000