00001 #ifndef INIFILE_H
00002 #define INIFILE_H
00003
00004 #ifdef WIN32
00005
00006
00007
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
00056
00057
00058
00059
00060
00061
00062
00063
00064