00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _Inifile_H
00019 #define _Inifile_H
00020
00021 #include <iostream>
00022 #include <vector>
00023 #include <string>
00024 #include <stdio.h>
00025
00026
00027
00028
00061 class IniFile
00062 {
00063 public:
00064
00068 IniFile();
00069
00074 IniFile(std::string fileName);
00075 ~IniFile();
00076
00086 int SetFileName(std::string fileName, std::string strIniFileUsedBy = "", bool bCreate = false);
00087
00088
00098 int WriteKeyString(const char* pSect, const char* pKey, const std::string* pStrToWrite, bool bWarnIfNotfound = true);
00099
00109 int WriteKeyInt(const char* pSect,const char* pKey,int nValue, bool bWarnIfNotfound = true);
00110
00121 int WriteKeyDouble(const char* pSect,const char* pKey,double dValue,int StringLen=12,int decimals=5, bool bWarnIfNotfound = true);
00122
00132 int WriteKeyBool(const char* pSect, const char* pKey, bool bValue, bool bWarnIfNotfound = true);
00133
00142 int GetKeyString(const char* pSect,const char* pKey, std::string* pStrToRead,
00143 bool bWarnIfNotfound = true);
00144
00149 int GetKeyInt(const char* pSect,const char* pKey,int* pValue,
00150 bool bWarnIfNotfound = true);
00151
00155 int GetKeyLong(const char* pSect,const char* pKey,long* pValue,
00156 bool bWarnIfNotfound = true);
00157
00166 int GetKeyBool(const char* pSect, const char* pKey, bool* pValue,
00167 bool bWarnIfNotfound = true);
00168
00177 int GetKeyDouble(const char* pSect,const char* pKey,double* pValue,
00178 bool bWarnIfNotfound = true);
00179
00188 int GetKeyDouble(const char* pSect,const char* pKey,double* pValue, double dDefault,
00189 bool bWarnIfNotfound = true);
00190
00199 int GetKey(const char* pSect,const char* pKey, std::string* pStrToRead, bool bWarnIfNotfound = true);
00200
00205 int GetKey(const char* pSect,const char* pKey,int* pValue, bool bWarnIfNotfound = true);
00206
00215 int GetKey(const char* pSect, const char* pKey, bool* pValue, bool bWarnIfNotfound = true);
00216
00225 int GetKey(const char* pSect,const char* pKey,double* pValue, bool bWarnIfNotfound = true);
00226
00235 int FindNextSection(std::string* pSect, std::string prevSect, bool bWarnIfNotfound = true);
00236
00237 private:
00238
00239 int FindSection(const char* sect, bool bWarnIfNotfound = true);
00240 int FindKey(const char* skey, bool bWarnIfNotfound = true);
00241 int FindNextLine(std::vector<char>& NewLine, int& CharInd);
00242
00251 int WriteKeyValue(const char* pSect,const char* pKey,const char* pBuf, bool bWarnIfNotfound = true);
00252
00264 int GetKeyValue(const char* pSect,const char* pKey, char* pBuf, int lenBuf,
00265 bool bWarnIfNotfound = true);
00266
00272 int SkipLineUntil(FILE* pFile, const char EndChar);
00273
00280 int ReadLineUntil(FILE* pFile, const char EndChar, std::string& ReadIntoStr);
00281
00282 bool m_bFileOK;
00283
00287 std::vector<char> m_CurLine;
00288
00292 const int m_vectorSize;
00293
00297 int m_CurCharInd;
00298
00299 std::string m_fileName;
00300 std::string m_strIniFileUsedBy;
00301 FILE* f;
00302 };
00303
00304 #endif
00305