-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIniFile.h
48 lines (37 loc) · 1.35 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
#ifndef INI_FILE_CPP_H_
#define INI_FILE_CPP_H_
#include <string>
using namespace std;
class IniFile
{
public:
IniFile(const string & fileName);
public:
virtual ~IniFile(void);
const string & getFileName() const;
const string &getSection() const;
void setSection(const string §ion);
bool write(const string &key, const string & value) const ;
bool write(const string &key, int value) const ;
string readStr(const string &key,const string &default_value) const;
int readInt(const string &key, int default_value) const;
public:
static int read_profile_string( const char *section, const char *key,char *value,
int size, const char *default_value, const char *file);
static int read_profile_int( const char *section, const char *key,int default_value,
const char *file);
static int write_profile_string(const char *section, const char *key,
const char *value, const char *file);
private:
static int load_ini_file(const char *file, char *buf,int *file_size);
static int newline(char c);
static int end_of_string(char c);
static int left_barce(char c);
static int right_brace(char c );
static int parse_file(const char *section, const char *key, const char *buf,int *sec_s,int *sec_e,
int *key_s,int *key_e, int *value_s, int *value_e);
private:
string m_fileName;
string m_section;
};
#endif