00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef _Inifile_H
00055 #define _Inifile_H
00056
00057 #include <iostream>
00058 #include <vector>
00059 #include <string>
00060 #include <stdio.h>
00061
00062
00063
00064
00097 class IniFile
00098 {
00099 public:
00100
00104 IniFile();
00105
00110 IniFile(std::string fileName);
00111 ~IniFile();
00112
00122 int SetFileName(std::string fileName, std::string strIniFileUsedBy = "", bool bCreate = false);
00123
00124
00134 int WriteKeyString(const char* pSect, const char* pKey, const std::string* pStrToWrite, bool bWarnIfNotfound = true);
00135
00145 int WriteKeyInt(const char* pSect,const char* pKey,int nValue, bool bWarnIfNotfound = true);
00146
00157 int WriteKeyDouble(const char* pSect,const char* pKey,double dValue,int StringLen=12,int decimals=5, bool bWarnIfNotfound = true);
00158
00168 int WriteKeyBool(const char* pSect, const char* pKey, bool bValue, bool bWarnIfNotfound = true);
00169
00178 int GetKeyString(const char* pSect,const char* pKey, std::string* pStrToRead,
00179 bool bWarnIfNotfound = true);
00180
00185 int GetKeyInt(const char* pSect,const char* pKey,int* pValue,
00186 bool bWarnIfNotfound = true);
00187
00191 int GetKeyLong(const char* pSect,const char* pKey,long* pValue,
00192 bool bWarnIfNotfound = true);
00193
00202 int GetKeyBool(const char* pSect, const char* pKey, bool* pValue,
00203 bool bWarnIfNotfound = true);
00204
00213 int GetKeyDouble(const char* pSect,const char* pKey,double* pValue,
00214 bool bWarnIfNotfound = true);
00215
00224 int GetKeyDouble(const char* pSect,const char* pKey,double* pValue, double dDefault,
00225 bool bWarnIfNotfound = true);
00226
00235 int GetKey(const char* pSect,const char* pKey, std::string* pStrToRead, bool bWarnIfNotfound = true);
00236
00241 int GetKey(const char* pSect,const char* pKey,int* pValue, bool bWarnIfNotfound = true);
00242
00251 int GetKey(const char* pSect, const char* pKey, bool* pValue, bool bWarnIfNotfound = true);
00252
00261 int GetKey(const char* pSect,const char* pKey,double* pValue, bool bWarnIfNotfound = true);
00262
00271 int FindNextSection(std::string* pSect, std::string prevSect, bool bWarnIfNotfound = true);
00272
00273 private:
00274
00275 int FindSection(const char* sect, bool bWarnIfNotfound = true);
00276 int FindKey(const char* skey, bool bWarnIfNotfound = true);
00277 int FindNextLine(std::vector<char>& NewLine, int& CharInd);
00278
00287 int WriteKeyValue(const char* pSect,const char* pKey,const char* pBuf, bool bWarnIfNotfound = true);
00288
00300 int GetKeyValue(const char* pSect,const char* pKey, char* pBuf, int lenBuf,
00301 bool bWarnIfNotfound = true);
00302
00308 int SkipLineUntil(FILE* pFile, const char EndChar);
00309
00316 int ReadLineUntil(FILE* pFile, const char EndChar, std::string& ReadIntoStr);
00317
00318 bool m_bFileOK;
00319
00323 std::vector<char> m_CurLine;
00324
00328 const int m_vectorSize;
00329
00333 int m_CurCharInd;
00334
00335 std::string m_fileName;
00336 std::string m_strIniFileUsedBy;
00337 FILE* f;
00338 };
00339
00340 #endif
00341