added specialisation for get for strings

This commit is contained in:
Bob Polis 2021-12-02 18:13:45 +01:00
parent 8230ca77ec
commit b39c02d1ec
2 changed files with 11 additions and 0 deletions

View File

@ -26,3 +26,12 @@ std::string sc::config_file::path_for_file_name(const std::string& 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";
}
std::string sc::config_file::get(const std::string& key,
const std::string& default_value) const {
auto it = _cfg.find(key);
if (it == _cfg.end()) {
return default_value;
}
return it->second;
}

View File

@ -22,6 +22,8 @@ namespace sc {
return sc::from_string<T>(it->second);
}
std::string get(const std::string& key,
const std::string& default_value) const;
bool get(const std::string& key, bool default_value) const;
private: