-
Notifications
You must be signed in to change notification settings - Fork 0
/
inirw.h
92 lines (57 loc) · 1.21 KB
/
inirw.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// author:[email protected]
//
#ifndef MOMPARE_SHFE_INIRW_H
#define MOMPARE_SHFE_INIRW_H
#include <algorithm>
#include <functional>
#include <cctype>
#include <locale>
#include <fcntl.h>
#include <unistd.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
std::string &trim(std::string &s);
typedef enum SECTION_TYPE_t{
INI_GLOBAL=0,
INI_LOCAL=1,
}SECTION_TYPE;
typedef struct KeyValue_t{
string key;
string value;
}KeyValue;
typedef struct Section_t{
string section;
vector<KeyValue> kv;
SECTION_TYPE type;
}Section;
class INIsword{
public:
INIsword(string file_name):file_name(file_name){
int ret;
ret=this->init();
//add exception
if(ret)
{
throw "ERROR:init failed!\n";
}
};
vector<Section> getSection(string section_name);
string getValue(Section &sc,string key);
string getGlobalValue(string key);
void release();
~INIsword(){
release();
};
private:
int init();
int readlines();
void parse_ini();
private:
string file_name;
vector<string *> lines;
vector<Section> m_sc;
};
#endif //MOMPARE_SHFE_INIRW_H