00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00021 #ifndef __ze_zconfigfile_h__
00022 #define __ze_zconfigfile_h__
00023
00024 #include "ZE_ZEngine.h"
00025
00026 namespace ZE
00027 {
00028
00037 class ZConfigFile
00038 {
00039 private:
00040
00041
00042
00049 class ZCF_Variable
00050 {
00051 public:
00053 std::string var;
00055 std::string val;
00056 };
00057
00063 class ZCF_Section
00064 {
00065 public:
00067 std::string section;
00069 std::list<ZCF_Variable> varList;
00070 };
00071
00072 protected:
00074 std::list<ZCF_Section> rFileLayout;
00076 std::string rFilename;
00077
00085 std::string CleanString(std::string str) const;
00086
00094 bool Exists(std::string sec) const;
00095
00104 bool Exists(std::string sec, std::string var) const;
00105
00114 void SetVariable(std::string sec, std::string var, std::string val);
00115
00125 std::string GetVariable(std::string sec, std::string var, std::string defVal) const;
00126
00127 public:
00128
00134 ZConfigFile();
00135
00142 ZConfigFile(std::string filename);
00143
00149 virtual ~ZConfigFile();
00150
00157 void Process(std::string filename);
00158
00169 float GetFloat(std::string section, std::string var, float defVal) const;
00170
00180 int GetInt(std::string section, std::string var, int defVal) const;
00181
00192 bool GetBool(std::string section, std::string var, bool defVal) const;
00193
00203 std::string GetString(std::string section, std::string var, std::string defVal) const;
00204
00215 void SetFloat(std::string section, std::string var, float val);
00216
00226 void SetInt(std::string section, std::string var, int val);
00227
00237 void SetBool(std::string section, std::string var, bool val);
00238
00248 void SetString(std::string section, std::string var, std::string val);
00249
00255 void Flush();
00256
00262 void Close();
00263 };
00264
00265 }
00266
00267 #endif //__ze_zconfigfile_h__