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

skTreeNode.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019  * $Id: skTreeNode_8h-source.html,v 1.5 2003/01/23 15:31:03 simkin_cvs Exp $
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 

Generated on Thu Jan 23 15:25:39 2003 for Simkin by doxygen1.3-rc1