Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/IniFile.h

Go to the documentation of this file.
00001 #ifndef INIFILE_H
00002 #define INIFILE_H
00003 
00004 #ifdef WIN32
00005   // disable some annoying warnings
00006   //   C4503: decorated name length exceeded, name was truncated.
00007   //   C4786: identifier was truncated to '255' characters in the browser information.
00008   //
00009 # pragma warning(disable:4503)
00010 # pragma warning(disable:4786)
00011 #endif
00012 
00013 #include <map>
00014 #include <string>
00015 
00016 using namespace std;
00017 
00018 class IniFile {
00019   private:
00020     struct lt_nocase {
00021       inline bool operator()(const string &x, const string &y) const
00022       {
00023         return stricmp(x.c_str(), y.c_str()) < 0;
00024       }
00025     };
00026     
00027     typedef  map<string, string, lt_nocase>  Keys;
00028     typedef  map<string, Keys,   lt_nocase>  Sections;
00029 
00030     Sections sections;
00031 
00032   public:
00033     IniFile();
00034     IniFile(const char *filename);
00035 
00036     bool   load(const char *filename);
00037     bool   save(const char *filename) const;
00038     
00039     void   removeKey(const char *section, const char *key);
00040 
00041     const char *getString(const char *section, const char *key, const char *def = "") const;
00042     int    getInt   (const char *section, const char *key, int def = 0) const;
00043     double getDouble(const char *section, const char *key, double def = 0) const;
00044     bool   getBool  (const char *section, const char *key, bool def = false) const;
00045     
00046     void   setString(const char *section, const char *key, const char *val);
00047     void   setInt   (const char *section, const char *key, int val);
00048     void   setDouble(const char *section, const char *key, double val);
00049     void   setBool  (const char *section, const char *key, bool val);
00050 };
00051 
00052 #endif
00053 
00054 /**
00055  * Change log:
00056  *
00057  * $Log: IniFile.h,v $
00058  * Revision 1.1.1.1  2004/05/22 17:35:53  cvsadm
00059  * created new repository GT2004_WM
00060  *
00061  * Revision 1.1  2004/04/13 23:35:16  kindler
00062  * initial import
00063  *
00064  */

Generated on Thu Sep 23 19:57:38 2004 for GT2004 by doxygen 1.3.6