-
Notifications
You must be signed in to change notification settings - Fork 2
/
IniFile.h
67 lines (61 loc) · 1.66 KB
/
IniFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef _H_INIFILE_H_
#define _H_INIFILE_H_
#include <string>
#include <iostream>
using namespace std;
class IniFile
{
public:
// Ïî
class IniItem
{
public:
IniItem();
IniItem(const string& strItemName, const string& strItemValue);
~IniItem();
string m_strName;
string m_strValue;
IniItem* m_pNextIniItem;
};
// ¶Î
class IniField
{
public:
IniField();
IniField(const string& strName);
~IniField();
void Release();
IniItem* FindItem(const string& strItemName);
IniItem* NewItem(const string& strItemName, const string& strItemValue);
IniItem* SetItem(const string& item, const string& value);
string m_strName;
IniItem* m_pIniItemHead;
IniItem* m_pIniItemTail;
IniField* m_pNextIniField;
};
public:
IniFile();
IniFile(const string& strName);
int Open(const string& strName);
void Release();
IniItem* SetItem(const string& strFieldName, const string& strItemName, const string& strValue);
string GetItemString(const string& strFieldName, const string& strItemName);
int GetItemInt(const string& strFieldName, const string& strItemName);
double GetItemDouble(const string& strFieldName, const string& strItemName);
~IniFile();
void Show();
private:
int Open();
int Getline(FILE* fp, char* cBuff, int nBufLen, string& strLine);
int Save();
IniField* FindField(const string& strFieldName);
IniItem* FindItem(const string& strFieldName, const string& strItemName);
IniField* NewField(const string& strFiledName);
IniItem* NewItem(const string& strFieldName, const string& strItemName, const string& strValue);
string Trim(string s);
bool m_bModify;
string m_strName;
IniField* m_pIniFieldHead;
IniField* m_pIniFieldTail;
};
#endif