-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng_config.cpp
executable file
·77 lines (64 loc) · 1.33 KB
/
ng_config.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <string>
#include "ng_config.h"
config* config::getInstance()
{
if (pinstance == nullptr)
pinstance = new config();
return pinstance;
}
config::config()
{
}
config::~config()
{
}
bool config::set(const std::string& k, std::string v)
{
this->config_str[k] = v; //.insert( config_str_t::value_type(std::string(k), std::string(v)) );
return true;
}
bool config::setInt(const std::string& k, int v)
{
this->config_int[k] = v; //.insert( config_int_t::value_type(k, v) );
return true;
}
bool config::get(const std::string& k, std::string *t)
{
t->clear();
config_str_t::iterator it;
it = this->config_str.find( k );
if (it != this->config_str.end()) {
t->assign(it->second);
return true;
}
return false;
}
bool config::getInt(const std::string& k, int *t)
{
config_int_t::iterator it;
it = this->config_int.find( k );
if (it != this->config_int.end()) {
*t = it->second;
return true;
}
return false;
}
std::string config::get(const std::string& k, std::string def)
{
config_str_t::iterator it;
it = this->config_str.find( k );
if (it != this->config_str.end()) {
return it->second;
}
return def;
}
int config::getInt(const std::string& k, int def)
{
config_int_t::iterator it;
it = this->config_int.find( k );
if (it != this->config_int.end()) {
return it->second;
}
return def;
}