00001 #if !defined( __CFG_HANDLER_H__ )
00002 #define __CFG_HANDLER_H__
00003
00004 namespace Cfg {
00005
00006
00007
00008 class Handler {
00009 private:
00010
00011 string CfgFile , cfgPath;
00012
00013 map<icstring , vector<string> > vList;
00014
00015 bool dirty;
00016 unsigned long cnt;
00017
00018 public:
00019
00020
00021
00022
00023 Handler( const string &aFile = "" );
00024
00025
00026
00027 virtual ~Handler( void );
00028
00030 unsigned long GetSize( void ) const { return cnt; }
00031
00033 const string &GetFilename( void ) const { return CfgFile; }
00034
00036 const string &GetPath( void ) const { return cfgPath; }
00037
00039 void SetData( const string &aData );
00040
00042 void Flush( const string &aFilename = "" );
00043
00044 int GetCfgInt( const string &aSection , const string &aId , const int aDefaultValue = 0 );
00045 int GetCfgHex( const string &aSection , const string &aId , const int aDefaultValue = 0 );
00046 double GetCfgDbl( const string &aSection , const string &aId , const double aDefaultValue = 0.0 );
00047 vector<double> &GetCfgDbl( const string &aSection , const string &aId , vector<double> &ans );
00048 string GetCfgString( const string &aSection , const string &aId , const string &aDefaultValue = "" );
00049 string GetCfgFile( const string &aSection , const string &aId , const string &aDefaultValue = "" );
00050 Ars::RGBColor GetCfgColorHex( const string &aSection , const string &aId , const Ars::RGBColor c );
00051
00052 void SetCfgInt( const string &aSection , const string &aId , const int aValue );
00053 void SetCfgHex( const string &aSection , const string &aId , const int aValue );
00054 void SetCfgDbl( const string &aSection , const string &aId , const double aValue );
00055 void SetCfgString( const string &aSection , const string &aId , const string &aValue );
00056 void SetCfgFile( const string &aSection , const string &aId , const string &aValue );
00057 void SetCfgColorHex( const string &aSection , const string &aId , const Ars::RGBColor c );
00058
00059 const bool IsTheFile( const char *aFile ) const { return CfgFile == aFile; }
00060 const bool operator==( const Handler &h ) const { return h.IsTheFile( CfgFile.c_str() ); }
00061
00062 protected:
00063
00064 string GetCdr( const icstring &aSection , const string &aId );
00065 map<icstring, vector<string> >::iterator AddLine( map<icstring, vector<string> >::iterator pos , const string &aline );
00066
00067 private:
00068 };
00069
00070 void Push( Handler *aCfg );
00071 Handler &Push( string aFile );
00072
00073 void Pop( void );
00074 void Pop( const Handler &aCfg );
00075
00076 const bool Empty( void );
00077 Handler &GetCfg( string aFile = "Ars.Cfg" );
00078 }
00079
00080 #endif
00081
00082