global.h

Go to the documentation of this file.
00001 /* Parser global settings.
00002  *
00003  * PegSoft configuration parser library (c) 2004 PegSoft
00004  * Contact us at pegsoft@pegsoft.net
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License version 2 as
00008  * published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software (the COPYING file); if not, write to the
00017  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
00018  * USA.
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         /* Don't let anyone use these two. */
00210         ConfGlobal(ConfGlobal const &);
00211         ConfGlobal &operator=(ConfGlobal const &right);
00212         
00213         void add_default();
00214 };
00215 
00216 /*************************************************************************/
00217 
00218 } /* namespace conf */
00219 
00220 /*************************************************************************/
00221 
00222 #endif /* CONF_GLOBAL_H */

Generated on Wed Aug 15 00:37:22 2007 for Epona API by  doxygen 1.5.2