aboutsummaryrefslogtreecommitdiff
path: root/src/settings.h.in
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-06-23 17:16:35 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-06-23 17:16:35 +0300
commitdd277842571ade5f78b33171648356a56fec400a (patch)
treee046e3d73a6bf8af173f34de59e1a20b96fd3504 /src/settings.h.in
parentenable smolblok (diff)
downloadsmolbote-dd277842571ade5f78b33171648356a56fec400a.tar.xz
Fix compiler warnings in Configuration
Diffstat (limited to 'src/settings.h.in')
-rw-r--r--src/settings.h.in29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/settings.h.in b/src/settings.h.in
index 88fbcf5..605288e 100644
--- a/src/settings.h.in
+++ b/src/settings.h.in
@@ -4,29 +4,28 @@
#include <configuration.h>
#include <fstream>
-inline const std::string init_conf(const std::string &path)
+inline auto init_conf(const std::string &path)
{
- auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({
+ struct {
+ std::string path;
+ std::unique_ptr<Configuration> ptr;
+ } conf;
+
+ conf.ptr = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({
@__DEFAULT_CFG__
});
- const std::string cfgpath = [&]() {
- if(path.empty())
- return value_map->value<std::string>("poi.cfg.path").value();
-
- auto p = path;
- if(p.front() == '~')
- p.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString());
- return p;
- }();
+ conf.path = path.empty() ? conf.ptr->value<std::string>("poi.cfg.path").value() : path;
+ if(conf.path.front() == '~') {
+ conf.path.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString());
+ };
std::fstream fs;
- fs.open(cfgpath, std::fstream::in);
+ fs.open(conf.path, std::fstream::in);
if(fs.is_open()) {
- value_map->read(fs);
+ conf.ptr->read(fs);
fs.close();
}
- Configuration::move_global(std::move(value_map));
- return cfgpath;
+ return conf;
}