work on settings (set and show), perf improvement when adding row into table

This commit is contained in:
2021-08-09 14:15:42 +02:00
parent 474b789d12
commit 710531c455
13 changed files with 124 additions and 49 deletions

View File

@@ -20,11 +20,20 @@ std::string Settings::date_to_string(long date) {
return ::date_to_string(date, get_setting("DATE_FORMAT"));
}
std::basic_string<char> Settings::get_setting(const std::string &name) {
std::string Settings::get_setting(const std::string &name) {
for(const auto& pair : m_settings) {
if (pair.first == name) return pair.second;
}
// TODO exception
throw Exception("unsupported setting name: " + name);
}
void Settings::set_setting(const std::string &name, const std::string &value) {
for (auto it = begin(m_settings); it != end(m_settings); ++it) {
if (it->first == name) {
*it = std::make_pair(name, value);
return;
}
}
throw Exception("unsupported setting name: " + name);
}