57 std::vector<std::string> output;
59 std::map<std::string, std::string> conf;
60 std::ifstream file(this->
fpath);
65 while (std::getline(file, line))
70 if (line.empty() || line[0] ==
';')
continue;
72 std::istringstream iss(line);
75 if (std::getline(iss, key,
'=') && std::getline(iss, val))
77 key.erase(0, key.find_first_not_of(
" \t"));
78 key.erase(key.find_last_not_of(
" \t") + 1);
80 val.erase(0, val.find_first_not_of(
" \t"));
81 val.erase(val.find_last_not_of(
" \t") + 1);
83 if (conf.find(key) != conf.end())
85 output.emplace_back(std::string(
"ERR: LINE: " + std::to_string(lineNum)));
86 output.emplace_back(
"Duplicate member : " + line);
88 return { conf, output,
false };
96 output.emplace_back(std::string(
"ERR: LINE: " + std::to_string(lineNum)));
97 output.emplace_back(std::string(
"No equality operator to set value for `" + line +
"`"));
99 return { conf, output,
false };
103 return { conf, output,
true };
Parser(const std::string &_id, const std::string &_file, const std::string &_extension=".varpar")
Create the object, set errors if there are and set some configuration from the parameters.