00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef INI_H
00029 #define INI_H
00030
00031 #include "FlyLegacy.h"
00032 #include <map>
00033 #include <string>
00034
00035
00036 typedef enum {
00037 INI_UNKNOWN_SETTING,
00038 INI_FLOAT_SETTING,
00039 INI_INT_SETTING,
00040 INI_STRING_SETTING
00041 } EIniSettingType;
00042
00043
00044
00045
00046
00047
00048 class CIniSetting {
00049 public:
00050
00051 CIniSetting (const char* key);
00052
00053
00054 void Set (float f);
00055 void Set (int i);
00056 void Set (const char* s);
00057 void Get (float* f);
00058 void Get (int* i);
00059 void Get (char* s, int maxLength);
00060 void Save (FILE *f);
00061
00062 public:
00063 EIniSettingType type;
00064 char key[64];
00065 float value;
00066 char s_value[64];
00067 };
00068
00069
00070
00071
00072
00073
00074 class CIniSection {
00075 public:
00076
00077 CIniSection (const char* section);
00078 ~CIniSection (void);
00079
00080
00081 void Set (const char* key, float f);
00082 void Set (const char* key, int i);
00083 void Set (const char* key, const char* s);
00084 void Get (const char* key, float *f);
00085 void Get (const char* key, int *i);
00086 void Get (const char* key, char *s, int maxLength);
00087 void Save (FILE *f);
00088 void Remove (const char* key);
00089
00090 protected:
00091
00092 CIniSetting* FindSetting (const char* key);
00093 void Clear (void);
00094
00095 public:
00096 char section[64];
00097 std::map<std::string,CIniSetting*> setting;
00098 };
00099
00100
00101
00102
00103
00104
00105 class CIniFile {
00106 public:
00107
00108 CIniFile (void);
00109 CIniFile (const char* iniFilename);
00110 ~CIniFile (void);
00111
00112
00113 int Load (const char* iniFilename);
00114 int Merge (const char* iniFilename);
00115 int Save (const char* iniFilename);
00116 void Set (const char* section, const char* key, float f);
00117 void Set (const char* section, const char* key, int i);
00118 void Set (const char* section, const char* key, const char* s);
00119 void Get (const char* section, const char* key, float* f);
00120 void Get (const char* section, const char* key, int* i);
00121 void Get (const char* section, const char* key, char* s, int maxLength);
00122 void Remove (const char* section, const char* key);
00123 int GetNumSections (void);
00124 char* GetSectionName (int i);
00125
00126 protected:
00127
00128 CIniSection* FindSection (const char* sectname);
00129 void Clear (void);
00130
00131 protected:
00132 std::map<std::string,CIniSection*> section;
00133 };
00134
00135 #endif // INI_H