00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __WVHCONF_H
00009 #define __WVHCONF_H
00010
00011 #include "wvhashtable.h"
00012 #include "wvstringlist.h"
00013
00014 class WvStream;
00015 class WvHConf;
00016 class WvHConfDict;
00017
00022 class WvHConfKey : public WvStringList
00023 {
00024 public:
00025 WvHConfKey();
00026 WvHConfKey(const char *key);
00027 WvHConfKey(const WvString &key);
00028 WvHConfKey(const WvString §ion, const WvString &entry);
00029 WvHConfKey(const WvHConfKey &key, int offset = 0);
00030
00031 WvString printable() const;
00032 operator WvString () const { return printable(); }
00033
00034 WvHConfKey skip(int offset) const
00035 { return WvHConfKey(*this, offset); }
00036 };
00037
00038
00044 class WvHConfGen
00045 {
00046 public:
00047 WvHConfGen() {}
00048 virtual ~WvHConfGen();
00049
00050
00051
00052 virtual WvHConf *make_tree(WvHConf *parent, const WvHConfKey &key);
00053 virtual WvHConf *make_obj(WvHConf *parent, const WvString &name);
00054
00055 virtual void update(WvHConf *h);
00056
00057
00058
00059 virtual void load();
00060 virtual void save();
00061 };
00062
00063
00072 class WvHConf
00073 {
00074 public:
00075 WvHConf *parent;
00076 WvString name;
00077 private:
00078 WvString value;
00079 public:
00080 WvHConfDict *children;
00081 WvHConf *defaults;
00082 WvHConfGen *generator;
00083
00084 public:
00085 bool
00086
00087
00088 child_dirty:1,
00089 dirty:1,
00090
00091
00092
00093 child_notify:1,
00094 notify:1,
00095
00096
00097
00098 child_obsolete:1,
00099 obsolete:1;
00100
00101
00102 WvHConf();
00103 WvHConf(WvHConf *_parent, const WvString &_name);
00104 ~WvHConf();
00105 void init();
00106
00107 WvHConf *top();
00108 WvHConfKey full_key() const;
00109
00110 WvHConf *gen_top();
00111 WvHConfKey gen_full_key() const;
00112
00113 WvHConf *find(const WvHConfKey &key);
00114 WvHConf *find_make(const WvHConfKey &key);
00115 WvHConf &operator[](const WvHConfKey &key) { return *find_make(key); }
00116
00117 WvHConf *find_default(WvHConfKey *_k = NULL) const;
00118
00119
00120
00121 WvHConf &get(const WvHConfKey &key)
00122 { return *find_make(key); }
00123
00124
00125
00126 void set(const WvHConfKey &key, const WvString &v)
00127 { get(key).set(v); }
00128
00129
00130 void set_without_notify(const WvString &s);
00131 void set(const WvString &s);
00132 void do_notify();
00133 const WvHConf &operator= (const WvString &s) { set(s); return *this; }
00134 const WvHConf &operator= (const WvHConf &s) { set(s); return *this; }
00135
00136
00137
00138 const WvString& printable() const;
00139 operator const WvString& () const { return printable(); }
00140 bool operator! () const { return !printable(); }
00141 int num() const { return printable().num(); }
00142
00143
00144
00145 void load();
00146 void save();
00147
00148
00149 void dump(WvStream &s);
00150 };
00151
00152 DeclareWvDict(WvHConf, WvString, name);
00153
00154
00155 #endif // __WVHCONF_H