configtree.h
gehe zur Dokumentation dieser Datei
00001 
00040 #ifndef MUTABOR_CONFIGTREE_H
00041 #define MUTABOR_CONFIGTREE_H
00042 
00043 #include "Defs.h"
00044 #include "Route.h"
00045 #include "treestorage.h"
00046 #include <stack>
00047 
00048 class configtree:public tree_storage 
00049 {
00050         wxConfigBase * config; 
00051         bool deleteconfig; 
00052         
00054         struct state {
00055                 state() {
00056                         chdepth = 0;
00057                         leafid = wxNOT_FOUND;
00058                 }
00059                 int chdepth; 
00060                 long leafid; 
00061 #ifdef DEBUG
00062                 wxString oldpath; 
00063                 wxString group;
00064 #endif
00065         };
00066         std::stack<state> states;
00067 public:
00068         configtree(wxConfigBase * conf, bool ownconfig = false):config(conf),deleteconfig(ownconfig),states()
00069         {
00070         }
00071         
00072         virtual ~configtree() 
00073         {
00074                 if (deleteconfig) delete config;
00075         }
00076 
00077         virtual long Read(const mutStringRef key, long defval);
00078         virtual double Read(const mutStringRef key, double defval);
00079         virtual int Read(const mutStringRef key, int defval);
00080         virtual bool Read(const mutStringRef key, bool defval);
00081         virtual mutString Read(const mutStringRef key, const mutStringRef defval);
00082         
00083         virtual void Write (const mutStringRef key, long value);
00084         virtual void Write (const mutStringRef key, double value);
00085         virtual void Write (const mutStringRef key, int value);
00086         virtual void Write(const mutStringRef key, bool value);
00087         virtual void Write (const mutStringRef key, const mutStringRef value);
00088 
00089         virtual bool HasGroup(const mutStringRef subdir) const;
00090         virtual void toLeaf(const mutStringRef subdir);
00091         virtual void toLeaf(const mutStringRef name, int id);
00092         virtual int toFirstLeaf(const mutStringRef name)
00093         {
00094                 mutString id;
00095                 if (toFirstLeaf(name,id) == wxNOT_FOUND) 
00096                         return wxNOT_FOUND;
00097                 long i;
00098                 if (id.ToLong(&i)) return (int)i; 
00099                 else return wxNOT_FOUND;
00100         }
00101         virtual int toFirstLeaf(const mutStringRef name, mutStringRef id);
00102         virtual int toNextLeaf(const mutStringRef name)
00103         {
00104                 mutString id;
00105                 if (toNextLeaf(name,id) == wxNOT_FOUND)
00106                         return wxNOT_FOUND;
00107                 long i;
00108                 if (id.ToLong(&i)) return (int)i; 
00109                 else return wxNOT_FOUND;                
00110         }
00111         virtual int toNextLeaf(const mutStringRef name, mutStringRef id);
00112         virtual void toParent(unsigned int count = 1);
00113 
00114         virtual mutString GetPath();
00115         virtual void SetPath(const mutStringRef path);
00116         
00118 
00121         virtual void DeleteEntry(const mutStringRef path)
00122         {
00123                 config->DeleteEntry(path);
00124         }
00125         
00127 
00130         virtual void DeleteGroup(const mutStringRef path)
00131         {
00132                 config->DeleteGroup(path);
00133         }
00134 };
00135 
00136 inline void LoadRoutes(wxConfigBase * config)
00137 {
00138         configtree conf(config);
00139         LoadRoutes(conf);
00140 }
00141 
00142 inline void SaveRoutes(wxConfigBase * config)
00143 {
00144         configtree conf(config);
00145         SaveRoutes(conf);
00146 }
00147 
00148 #endif //MUTABOR_CONFIGTREE_H
00149 
00150 

Erzeugt am Sun Aug 21 2011 10:51:54 für Mutabor von doxygen 1.7.4