-
Notifications
You must be signed in to change notification settings - Fork 15
/
IniValue.cpp
63 lines (53 loc) · 937 Bytes
/
IniValue.cpp
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
/*
* IniValue class implementation file
* Author: Sun Junwen
* Version: 1.0
*/
#include <cstdlib>
#include <string>
#include <map>
#include "IniValue.h"
using namespace std;
IniValue::StrMap IniValue::GetMapValue() const
{
return mapValue;
}
void IniValue::SetMapValue(const IniValue::StrMap& map)
{
mapValue = map;
}
string IniValue::GetStrValue() const
{
return strValue;
}
void IniValue::SetStrValue(const string& str)
{
strValue = str;
}
void IniValue::Put(const string& key, const string& value)
{
mapValue[key] = value;
}
string IniValue::ToString() const
{
string ret("");
if(bStr)
{
ret.append(strValue);
ret.append("\n");
}
else
{
IniValue::StrMap::const_iterator itr = mapValue.begin();
for(; itr != mapValue.end(); ++itr)
{
string line("");
line.append((*itr).first);
line.append("=");
line.append((*itr).second);
line.append("\n");
ret.append(line);
}
}
return ret;
}