aboutsummaryrefslogtreecommitdiff
path: root/src/settings.h.in
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-01-03 18:04:08 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-01-03 20:24:29 +0200
commit23a7f3baa33265519840609dc54e950615ec39b1 (patch)
treeff2737f76b63a2acf5f8a9fffd5c15e3eb4c46c8 /src/settings.h.in
parentWebProfile refactoring (diff)
downloadsmolbote-23a7f3baa33265519840609dc54e950615ec39b1.tar.xz
Merge some QoL improvements from staging branch
- Build executable in top-level buildroot - Use meson sourceset - Pull in poi-crash and poi-update from staging - Remove extraneous scripts in tools/ - Pull in configure scripts in scripts/
Diffstat (limited to 'src/settings.h.in')
-rw-r--r--src/settings.h.in29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/settings.h.in b/src/settings.h.in
new file mode 100644
index 0000000..a4b5159
--- /dev/null
+++ b/src/settings.h.in
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <QStandardPaths>
+#include <configuration.h>
+#include <fstream>
+
+inline void init_conf(const std::string &path)
+{
+
+ const std::string cfgpath = [&]() {
+ auto p = path;
+ if(p.front() == '~')
+ p.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString());
+ return p;
+ }();
+
+ auto value_map = std::make_unique<Configuration, std::initializer_list<std::pair<std::string, conf_value_t>>>({
+ @__DEFAULT_CFG__
+ });
+
+ std::fstream fs;
+ fs.open(path, std::fstream::in);
+ if(fs.is_open()) {
+ value_map->read(fs);
+ fs.close();
+ }
+
+ Configuration::move_global(std::move(value_map));
+}