-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathIniValue.h
60 lines (49 loc) · 1.06 KB
/
IniValue.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
/*
* IniValue class header file
* Author: Sun Junwen
* Version: 1.0
*/
#ifndef _INI_VALUE_H_
#define _INI_VALUE_H_
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
class IniValue
{
public:
typedef map<string, string> StrMap;
/*
* Constructors
* Default is string value
*/
IniValue(bool bStr = true)
:bStr(bStr)
{};
IniValue(const string& strValue)
:bStr(true), strValue(strValue)
{};
// Get map value
StrMap GetMapValue() const;
// Set map value
void SetMapValue(const StrMap& map);
// Get string value
string GetStrValue() const;
// Set string value
void SetStrValue(const string& str);
// Is string value or not
inline bool IsStrValue() const
{ return bStr; }
// Set value mode, true is string, false is not string
inline void SetMode(bool bStr)
{ this->bStr = bStr; }
// Put key-value pair into map value
void Put(const string& key, const string& value);
// Convert string value or map value to string
string ToString() const;
private:
bool bStr;
string strValue;
IniValue::StrMap mapValue;
};
#endif