35 #include <glog/logging.h>
52 Status UtilsIni::getKeyValuePairsFromIni(
const string &iniFileName,
53 map<string, string> &iniKeyValPairs) {
55 ifstream iniStream(iniFileName);
56 if (!iniStream.is_open()) {
57 LOG(
ERROR) <<
"Failed to open: " << iniFileName;
58 return Status::UNREACHABLE;
61 iniKeyValPairs.clear();
64 while (getline(iniStream, line)) {
65 size_t equalPos = line.find(
'=');
66 if (equalPos == string::npos) {
67 LOG(
WARNING) <<
"Unexpected format on this line:\n"
68 << line <<
"\nExpecting 'key=value' format";
71 string key = line.substr(0, equalPos);
72 string value = line.substr(equalPos + 1);
85 Status UtilsIni::getKeyValuePairsFromString(
87 std::map<std::string, std::string> &iniKeyValPairs) {
88 iniKeyValPairs.clear();
89 stringstream ss(iniStr);
91 char delimiter =
'\n';
92 while (getline(ss, line, delimiter)) {
93 size_t equalPos = line.find(
'=');
94 if (equalPos == string::npos) {
95 LOG(
WARNING) <<
"Unexpected format on this line:\n"
96 << line <<
"\nExpecting 'key=value' format";
99 string key = line.substr(0, equalPos);
100 string value = line.substr(equalPos + 1);
101 if (!
value.empty()) {