MikroCAD SDK Library
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
IniFiles.h
Go to the documentation of this file.
1 /**
2 * @file IniFiles.h
3 * @brief Ini File functions
4 *
5 * @author LMI Technologies
6 */
7 
8 #ifndef _IniFiles_h
9 #define _IniFiles_h
10 
11 #include "windows.h"
12 #include <string>
13 #include <vector>
14 
15 using namespace std;
16 
17 /**
18 Ini file class
19 */
20 class CIniFile
21 {
22 public:
23 
24  CIniFile(wstring stFileName);
25 
26  virtual ~CIniFile();
27 
28  wstring ReadString(wstring stSec, wstring stKey, wstring stDefault);
29 
30  double ReadFloat(wstring stSec, wstring stKey, double dDefault);
31 
32  int ReadInteger(wstring stSec, wstring stKey, int nDefault);
33 
34  bool ReadBool(wstring stSec, wstring stKey, bool bDefault);
35 
36  void WriteString(wstring stSec, wstring stKey, wstring stValue);
37 
38  void WriteFloat(wstring stSec, wstring stKey, double dValue);
39 
40  void WriteInteger(wstring stSec, wstring stKey, int nValue);
41 
42  void WriteBool(wstring stSec, wstring stKey, bool bValue);
43 
44  bool ReadSection(wstring stSec, vector<wstring>& stItemList);
45 
46  bool ReadSectionValues(wstring stSec, vector<wstring>& stItemList);
47 
48  bool ReadSections(vector<wstring>& stItemList);
49 
50  void DeleteKey(wstring stSec, wstring stKey);
51 
52  void EraseSection(wstring stSec);
53 
54 private:
55 
56  long ReadIniFile(PBYTE& pbyBuffer);
57 
58  void WriteIniFile(BYTE* pbyBuffer, long lBufferSize);
59 
60  wstring GetLine(BYTE* pbyBuffer, long lBufferSize, long& lLength);
61 
62  long GetSection(BYTE* pbyBuffer, long lBufferSize, wstring stSec, bool bAfter);
63 
64  long GetNextSection(BYTE* pbyBuffer, long lBufferSize, long lIndexStart);
65 
66  bool GetKeyLine(BYTE* pbyBuffer, long lBufferSize, wstring stKey, long& lIndexStart, long& lIndexEnd);
67 
68  wstring StringToWString(string stString);
69 
70 private:
71 
72  wstring m_stFileName;
73  wchar_t *m_pszBuffer;
74  vector<wstring> m_stStringList;
75 };
76 
77 #endif // _IniFiles_h
Ini file class.
Definition: IniFiles.h:20