Fixed specialisation for getting a bool value

This commit is contained in:
Bob Polis 2021-07-07 16:28:02 +02:00
parent 4864ff8529
commit 7c77b590cb
2 changed files with 6 additions and 5 deletions

View File

@ -20,3 +20,7 @@ sc::config_file::config_file(const std::string& prog_name, bool has_dir)
std::string sc::config_file::path_for_file_name(const std::string& file_name) {
return _root + file_name;
}
bool sc::config_file::get(const std::string& key, bool default_value) const {
return get<std::string>(key, default_value ? "yes" : "no") == "yes";
}

View File

@ -14,7 +14,7 @@ namespace sc {
std::string path_for_file_name(const std::string& file_name);
template<typename T>
T get(const std::string& key, const T& default_value) {
T get(const std::string& key, const T& default_value) const {
auto it = _cfg.find(key);
if (it == _cfg.end()) {
return default_value;
@ -22,10 +22,7 @@ namespace sc {
return sc::from_string<T>(it->second);
}
bool get(const std::string& key, bool default_value) {
std::string val {get<std::string>(key, default_value ? "yes" : "no")};
return val == "yes";
}
bool get(const std::string& key, bool default_value) const;
private:
bool _has_dir {false};