quick.h

Go to the documentation of this file.
00001 /* Quick configuration parser setup.
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_QUICK_H
00028 #define CONF_QUICK_H
00029 
00030 /*************************************************************************/
00031 
00032 #include <iosfwd>
00033 #include <string>
00034 
00035 #include <misc/misc.h>
00036 #include <conf/parser.h>
00037 #include <conf/global.h>
00038 
00039 namespace conf
00040 {
00041 
00042 /*************************************************************************/
00043 
00045 
00053 class ConfGlobalQ
00054 {
00055     public:
00057 
00061         ConfGlobalQ(ConfLogger &logger) : m_gconf(logger),
00062                 m_global(m_gconf), m_setup(false) { }
00064         virtual ~ConfGlobalQ() { }
00065         
00067 
00076         virtual bool setup() { return (m_setup = true); }
00077         
00079         Conf &gconf() { return m_gconf; }
00081         ConfGlobal &global() { return m_global; }
00082         
00084         bool is_setup() const { return m_setup; }
00085     protected:
00087         Conf m_gconf;
00089         ConfGlobal m_global;
00090     private:
00091         bool m_setup;
00092         
00093         ConfGlobalQ(ConfGlobalQ const &);
00094         ConfGlobalQ &operator=(ConfGlobalQ const &);
00095 };
00096 
00097 /*************************************************************************/
00098 
00100 
00107 class ConfQ
00108 {
00109     public:
00111 
00115         ConfQ(ConfLogger &logger) : m_conf(logger), m_setup(false) { }
00117         ConfQ(ConfQ const &cq) : m_conf(cq.m_conf), m_setup(cq.m_setup) { }
00119         virtual ConfQ &operator=(ConfQ const &right);
00121         virtual ~ConfQ() { }
00122         
00124 
00134         virtual bool setup() { return (m_setup = true); }
00135         
00137 
00154         bool parse(ConfGlobalQ &cgq, bool reload, std::istream &is,
00155                 std::string const &context);
00157 
00172         bool parse_file(ConfGlobalQ &cgq, bool reload,
00173                 std::string const &filename);
00175 
00192         bool parse_string(ConfGlobalQ &cgq, bool reload,
00193                 std::string const &str, std::string const &context);
00194         
00196         Conf &conf() { return m_conf; }
00198         bool is_setup() const { return m_setup; }
00199     protected:
00201         Conf m_conf;
00202     private:
00203         bool m_setup;
00204 };
00205 
00206 /*************************************************************************/
00207 
00209 
00216 class DirectivesQ
00217 {
00218     public:
00219         /* Classes */
00220         
00222 
00229         class DConfQ : public ConfQ
00230         {
00231             public:
00233                 DConfQ(ConfLogger &logger, DirectivesQ &directives) :
00234                         ConfQ(logger), m_directives(&directives) { }
00236                 DConfQ(DConfQ const &dcq) : ConfQ(dcq),
00237                         m_directives(dcq.m_directives) { }
00239                 DConfQ &operator=(DConfQ const &right);
00240                 
00242                 virtual bool setup();
00243             protected:
00244                 DirectivesQ *m_directives;
00245         };
00246         
00247         /* Functions */
00248         
00250 
00253         DirectivesQ(ConfLogger &logger) : m_parser(logger, *this) { }
00255         DirectivesQ(DirectivesQ const &d) : m_parser(d.m_parser) { }
00257         DirectivesQ &operator=(DirectivesQ const &right);
00259         virtual ~DirectivesQ() { }
00260         
00262 
00267         virtual bool add(Conf &conf) = 0;
00268         
00270         DConfQ &parser() { return m_parser; }
00271     protected:
00273         DConfQ m_parser;
00274 };
00275 
00276 /*************************************************************************/
00277 
00278 } /* namespace conf */
00279 
00280 /*************************************************************************/
00281 
00282 #endif /* CONF_QUICK_H */

Generated on Sun May 20 21:32:14 2007 for Epona API by  doxygen 1.4.6