#pragma once #include #include #include inline auto init_conf(const std::string &path) { struct { std::string path; std::unique_ptr ptr; } conf; conf.ptr = std::make_unique>>({ @__DEFAULT_CFG__ }); conf.path = path.empty() ? conf.ptr->value("poi.cfg.path").value() : path; if(conf.path.front() == '~') { conf.path.replace(0, 1, QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString()); }; std::fstream fs; fs.open(conf.path, std::fstream::in); if(fs.is_open()) { conf.ptr->read(fs); fs.close(); } return conf; }