blob: a4b5159fd4579b2b290abbbd4052a2c5d55974c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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));
}
|