-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigparser.cpp
More file actions
35 lines (27 loc) · 987 Bytes
/
Copy pathconfigparser.cpp
File metadata and controls
35 lines (27 loc) · 987 Bytes
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
#include "configparser.hpp"
void add_section::operator()(char const* p, char const* q) const {
string s(p,q);
boost::algorithm::trim(s);
data_.push_back(Section(s, Entries()));
}
void add_key::operator()(char const* p, char const* q) const {
string s(p,q);
boost::algorithm::trim(s);
data_.back().second.push_back(Entry(s, string()));
}
void add_value::operator()(char const* p, char const* q) const {
data_.back().second.back().second.assign(p,q);
}
bool is_comment::operator()(string const& s) const {
return s[0] == '\n' || s[0] == ';';
}
bool find_value(IniData const& ini, string const& s, string const& p, string & res) {
IniData::const_iterator sit = find_if(ini.begin(), ini.end(), first_is(s));
if (sit == ini.end())
return false;
Entries::const_iterator it = find_if(sit->second.begin(), sit->second.end(), first_is(p));
if (it == sit->second.end())
return false;
res = it->second;
return true;
}