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,v 1.12 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 
00049 class  CLASSEXPORT skTreeNode 
00050 {
00051  public:
00055   skTreeNode();
00059   virtual ~skTreeNode();
00063   skTreeNode(const skTreeNode& );
00067   skTreeNode(const skString& label); 
00071   skTreeNode(const skString& label,const skString& data);
00075   skTreeNode(const skString& label,bool data);
00079   skTreeNode(const skString& label,int  data);
00083   skTreeNode(const skString& label,float data);
00087   skTreeNode& operator=(const skTreeNode& );
00091   skString label() const;
00095   void  label(const skString& s);
00099   skString data() const;
00103   void  data(const skString& s);
00107   bool  boolData() const;
00111   void  boolData(bool);
00115   int   intData() const;
00119   void  intData(int);
00123   float floatData() const;
00127   void  floatData(float);
00131   void  prependChild(skTreeNode*);
00135   void  addChild(skTreeNode*);
00139   void  setChild(skTreeNode*);  
00143   void  deleteChild(skTreeNode*);
00147   bool  containsChild(skTreeNode*);
00152   skTreeNode* findChild(const skString& label) const;
00157   skTreeNode* findChild(const skString& label,const skString& data) const;
00164   skString findChildData(const skString& label,const skString& defaultVal) const;
00171   bool  findChildboolData(const skString& label, bool defaultVal=false) const;
00178   int   findChildIntData(const skString& label, int defaultVal=0) const;
00185   float findChildFloatData(const skString& label, float defaultVal=0.0f) const;
00189   skString nthChildData(USize index) const;
00193   int   nthChildIntData(USize index) const;
00194 #ifdef STREAMS_ENABLED
00198   void  write(ostream& out,USize tabstops) const;
00199 #endif
00204   bool  write(const skString& file) const;
00211   skTreeNode *  nthChild(USize  i) const;
00215   USize numChildren() const;
00219   void  copyItems(skTreeNode& node);
00223   void  moveItemsFrom(skTreeNode& node);
00227   void  clear();
00232   static skTreeNode * read(const skString& file);
00233  
00234   friend class skTreeNodeList;
00235   friend class skTreeNodeListIterator;
00236 
00237  private:
00241   skString m_Label;
00245   skString m_Data;
00249   skTreeNodeList * m_Items;
00250 };
00254 class  CLASSEXPORT skTreeNodeReader 
00255 {
00256  public:
00257 #ifdef STREAMS_ENABLED
00258 
00261   skTreeNodeReader(istream& in);
00265   skTreeNodeReader(istream& in,const char *  fileName);
00266 #endif
00267 
00270   ~skTreeNodeReader();
00276   skTreeNode* read();
00277  private:
00278   class P_TreeNodeReader* pimp;
00279 };
00280 const int skTreeNodeReaderException_Code=4;
00281 
00285 class CLASSEXPORT  skTreeNodeReaderException {
00286  public:
00290   skTreeNodeReaderException(const skString& fileName,const skString& msg)
00291     : m_FileName(fileName),m_Msg(msg){
00292   }
00296   skString toString(){
00297     return m_FileName+skSTR(":")+m_Msg;
00298   }
00299  private:
00300   skString m_FileName;
00301   skString m_Msg;
00302 };
00303 
00304 #endif
00305                         
00306 
00307 
00308 
00309 
00310 
00311 
00312 
00313 

Generated on Tue Nov 20 17:56:21 2001 for Simkin by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001