-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIniFile.h
More file actions
64 lines (52 loc) · 1.98 KB
/
IniFile.h
File metadata and controls
64 lines (52 loc) · 1.98 KB
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
/**
* @file
* @brief initialization file read and write API
* @author Deng Yangjun
* @date 2007-12-9
* @version 0.2
* (C)2007 Midapex
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* Modified by Xishan Sun 4-2011
* Double float type read and write added
*
*/
#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;
bool write(const string &key, double value) const;
string readStr(const string &key,const string &default_value) const;
int readInt(const string &key, int default_value) const;
double readDouble(const string &key, double 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 double read_profile_double(const char *section, const char *key, double 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