work on settings (set and show), perf improvement when adding row into table
This commit is contained in:
13
settings.cpp
13
settings.cpp
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user