Skip to content

Commit 32d2752

Browse files
committed
SimpCfg:Make str_trim flexible, use to trim , wrt value
Now one can pass the list/string of chars to trim at either end.
1 parent 96068d9 commit 32d2752

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/simpcfg.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ bool sc_get_bool(std::string &group, std::string &key) {
4444
return gm[key];
4545
}
4646

47-
std::string str_trim(std::string sin) {
48-
sin.erase(sin.find_last_not_of(" \t\n")+1);
49-
sin.erase(0, sin.find_first_not_of(" \t\n"));
47+
std::string str_trim(std::string sin, std::string trimChars=" \t\n") {
48+
sin.erase(sin.find_last_not_of(trimChars)+1);
49+
sin.erase(0, sin.find_first_not_of(trimChars));
5050
return sin;
5151
}
5252

@@ -91,12 +91,15 @@ void sc_load(std::string &fname) {
9191
key = str_trim(key);
9292
std::string value = curL.substr(dPos+1);
9393
value = str_trim(value);
94-
LOG_TEELN("DBUG:%s:kv:%s:%s:%s", __func__, group.c_str(), key.c_str(), value.c_str());
94+
value = str_trim(value, ",");
95+
std::string vtype = "bool";
9596
if ((value == "true") || (value == "false")) {
9697
sc_set_bool(group, key, value == "true" ? true : false);
9798
} else {
99+
vtype = "string";
98100
sc_set_string(group, key, value);
99101
}
102+
LOG_TEELN("DBUG:%s:kv:%s:%s:%s:%s", __func__, group.c_str(), key.c_str(), vtype.c_str(), value.c_str());
100103
}
101104
}
102105

0 commit comments

Comments
 (0)