Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

conf.h

00001 /***************************************************************************
00002                         conf.h    -  description
00003                             -------------------
00004     begin                : august 1st, 2004
00005     copyright            : (C) 2004-2006 by Duong-Khang NGUYEN
00006     email                : neoneurone @ users sourceforge net
00007 
00008     $Id: conf.h 84 2006-11-06 18:58:40Z neoneurone $
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *   This program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   any later version.                                                    *
00017  *                                                                         *
00018  ***************************************************************************/
00019 
00020 #ifndef _OPENCITY_CONF_H_
00021 #define _OPENCITY_CONF_H_ 1
00022 
00023 #include "main.h"
00024 
00025 //#include <ext/hash_map>           // for parameters stockage
00026 #include <map>
00027 
00028 using std::map;
00029 
00030 
00031 #define OC_MAX_CONF_LINE    1024
00032 
00033 //========================================================================
00055 class Conf {
00056 public:
00057     Conf() { OPENCITY_DEBUG("ctor"); }
00058     ~Conf() { OPENCITY_DEBUG("dtor"); }
00059 
00060 
00061 //========================================================================
00067     const OPENCITY_ERR_CODE
00068     Open(
00069         const string& fname );
00070 
00071     void
00072     Close();
00073 
00074 
00075 //========================================================================
00082     const string&
00083     GetValue(
00084         const string& key,
00085         const string def = "");
00086 
00087 //========================================================================
00097     const OPENCITY_ERR_CODE
00098     GetBool(
00099         const string& key,
00100         bool& rbool,
00101         const bool def = false );
00102 
00103 
00104 //========================================================================
00108     const OPENCITY_ERR_CODE
00109     GetLint(
00110         const string& key,
00111         OC_LINT& rlint,
00112         const OC_LINT def = 0 );
00113 
00114 
00115 //========================================================================
00119     const OPENCITY_ERR_CODE
00120     GetFloat(
00121         const string& key,
00122         float& rfloat,
00123         const float def = 0 );
00124 
00125 
00126 //========================================================================
00129     static OC_CHAR* const
00130     RTrim( OC_CHAR* const str );
00131 
00132     static OC_CHAR* const
00133     LTrim( OC_CHAR* const str );
00134 
00135 
00136 private:
00137 /* TOKILL, kept for future reference
00138 //========================================================================
00139 This is our hash function. In fact, it's just a wrapper
00140     for the standard hash<const char*>
00141 
00142     struct myHash : public std::unary_function< const string &, size_t >
00143     {
00144     public:
00145         size_t operator()( const string & x ) const
00146         {
00147             return stdHash( x.c_str() );
00148         }
00149 
00150     private:
00151         __gnu_cxx::hash<const char*> stdHash;
00152     };
00153 
00154 
00155     __gnu_cxx::hash_map<string, string, myHash> mapData;
00156 */
00157 
00158     map<string, string> _mapData;
00159 };
00160 
00161 #endif
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 

Generated on Sat Nov 11 10:21:09 2006 for OpenCity by  doxygen 1.4.2