00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef CONF_GLOBAL_H
00028 #define CONF_GLOBAL_H
00029
00030
00031
00032 #include <list>
00033 #include <map>
00034 #include <string>
00035
00036 #include <misc/string.h>
00037
00038 namespace conf
00039 {
00040
00041
00042
00043 class Conf;
00044 class ConfElse;
00045 class ConfIfnset;
00046 class ConfIfset;
00047 class ConfInclude;
00048 class ConfPath;
00049 class ConfVarSet;
00050 class ConfUnset;
00051
00052
00053
00055
00072 class ConfGlobal
00073 {
00074 public:
00076 typedef std::list<std::string> PathList;
00078 typedef std::map<std::string, std::string, misc::insensitive_less>
00079 VarList;
00080
00081 friend class Conf;
00082
00084
00107 explicit ConfGlobal(Conf &conf) : m_refcount(0), m_directives(&conf),
00108 m_paths(), m_vars(), m_else(0), m_ifnset(0), m_ifset(0),
00109 m_include(0), m_path(0), m_set(0), m_unset(0)
00110 { add_default(); }
00112 ~ConfGlobal();
00113
00115
00120 Conf &directives() const { return *m_directives; }
00121
00123
00128 ConfElse &else_directive() const { return *m_else; }
00129
00131
00136 PathList const &incl_paths() const { return m_paths; }
00138
00149 bool incl_paths_add(std::string const &path,
00150 PathList::const_iterator *pi = 0);
00152
00157 bool incl_paths_remove(std::string const &path);
00158
00160
00167 bool var_get(std::string const &name, std::string *value = NULL) const;
00169
00176 bool var_set(std::string const &name, std::string const &value);
00178
00186 bool var_set(std::string const &assignment);
00188
00193 bool var_unset(std::string const &name);
00194 private:
00195 int m_refcount;
00196
00197 Conf *m_directives;
00198 PathList m_paths;
00199 VarList m_vars;
00200
00201 ConfElse *m_else;
00202 ConfIfnset *m_ifnset;
00203 ConfIfset *m_ifset;
00204 ConfInclude *m_include;
00205 ConfPath *m_path;
00206 ConfVarSet *m_set;
00207 ConfUnset *m_unset;
00208
00209
00210 ConfGlobal(ConfGlobal const &);
00211 ConfGlobal &operator=(ConfGlobal const &right);
00212
00213 void add_default();
00214 };
00215
00216
00217
00218 }
00219
00220
00221
00222 #endif