Config.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 #ifndef _EYEDB_CONFIG_H
00025 #define _EYEDB_CONFIG_H
00026 
00027 #include <map>
00028 
00029 namespace eyedb {
00030 
00039   class Config {
00040 
00041   public:
00042     typedef std::map<std::string, bool> VarMap;
00043 
00049     Config(const std::string &name);
00050 
00057     Config(const std::string &name, const VarMap &var_map);
00058 
00064     Config(const Config &config);
00065 
00070     std::string getName() const {return name;}
00071 
00072     struct Item {
00073       char *name;
00074       char *value;
00075 
00076       Item();
00077       Item(const char *name, const char *value);
00078       Item(const Item &item);
00079       Item& operator=(const Item &item);
00080       ~Item();
00081     };
00082 
00088     bool add(const char *file, bool quietFileNotFoundError = false);
00089 
00097     void loadConfigFile( const std::string& configFilename, const char* envVariable, const char* defaultFilename);
00098 
00104     const char *getValue(const char *name) const;
00105 
00112     void setValue(const char *name, const char *value);
00113 
00119     Item *getValues(unsigned int &item_cnt, bool expand_vars = false) const;
00120 
00125     static void init();
00126 
00131     static void _release();
00132 
00133     static bool isBuiltinVar(const char *name);
00134 
00135     static bool isUserVar(const char *name);
00136 
00137     ~Config();
00138 
00139   private:
00140     friend class Object;
00141 
00142     Config();
00143     Config& operator=(const Config &config);
00144 
00145     VarMap *var_map;
00146 
00147     std::string name;
00148 
00149     void garbage();
00150 
00151     LinkedList list;
00152 
00153     friend std::ostream& operator<< (std::ostream&, const Config&);
00154 
00155     void checkIsIn(const char *name);
00156   };
00157 
00162   std::ostream& operator<< (std::ostream&os, const Config &config);
00163 }
00164 
00165 #endif

Generated on Mon Dec 22 18:15:53 2008 for eyedb by  doxygen 1.5.3