aboutsummaryrefslogtreecommitdiff
path: root/lib/settings/configuration.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-03 22:29:17 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-03 22:29:17 +0100
commit1e57c2b3f6bd2a4f1756150e669eedffc29cf13d (patch)
tree01f22e47b85e556cd4fae4431f578f9c38bb12ca /lib/settings/configuration.h
parentUpdated PKGBUILD (diff)
downloadsmolbote-1e57c2b3f6bd2a4f1756150e669eedffc29cf13d.tar.xz
Fixed crash with Settings dialog
- User Configuration gets completely written, instead of being just overrides
Diffstat (limited to 'lib/settings/configuration.h')
-rw-r--r--lib/settings/configuration.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/settings/configuration.h b/lib/settings/configuration.h
index 1909eb8..b258cb3 100644
--- a/lib/settings/configuration.h
+++ b/lib/settings/configuration.h
@@ -25,9 +25,11 @@ public:
~Configuration();
bool readUserConfiguration(const std::string &path);
+ bool parse(const std::string &contents);
bool writeUserConfiguration(const std::string &path);
+ bool writeIfNeeded();
- bool readDefaultConfiguration(const std::string &data);
+ bool parseDefaultConfiguration(const std::string &contents);
std::vector<std::string> childrenSettings(const char *name = "");
std::vector<std::string> childrenGroups(const char *name = "");
@@ -38,14 +40,12 @@ public:
std::optional<T> value(const char* path) const;
template<typename T>
- void setValue(std::string path, const T &val);
+ bool setValue(std::string path, const T &val);
private:
- libconfig::Config* getConfig(const char* path) const;
-
+ bool changed = false;
std::string m_userCfgPath;
- libconfig::Config *m_userCfg;
- libconfig::Config *m_defaultCfg;
+ libconfig::Config *m_userCfg, *m_defaultCfg;
};
// replace ~ with home
@@ -71,19 +71,19 @@ extern template std::optional<bool> Configuration::value<bool>(const char* path)
extern template std::optional<std::string> Configuration::value<std::string>(const char* path) const;
// Settings::setValue<>
-extern template void Configuration::setValue<int>(std::string path, const int &val);
-extern template void Configuration::setValue<unsigned int>(std::string path, const unsigned int &val);
-extern template void Configuration::setValue<long>(std::string path, const long &val);
-extern template void Configuration::setValue<unsigned long>(std::string path, const unsigned long &val);
+extern template bool Configuration::setValue<int>(std::string path, const int &val);
+extern template bool Configuration::setValue<unsigned int>(std::string path, const unsigned int &val);
+extern template bool Configuration::setValue<long>(std::string path, const long &val);
+extern template bool Configuration::setValue<unsigned long>(std::string path, const unsigned long &val);
-extern template void Configuration::setValue<long long>(std::string path, const long long &val);
-extern template void Configuration::setValue<unsigned long long>(std::string path, const unsigned long long &val);
+extern template bool Configuration::setValue<long long>(std::string path, const long long &val);
+extern template bool Configuration::setValue<unsigned long long>(std::string path, const unsigned long long &val);
-extern template void Configuration::setValue<float>(std::string path, const float &val);
-extern template void Configuration::setValue<double>(std::string path, const double &val);
+extern template bool Configuration::setValue<float>(std::string path, const float &val);
+extern template bool Configuration::setValue<double>(std::string path, const double &val);
-extern template void Configuration::setValue<bool>(std::string path, const bool &val);
+extern template bool Configuration::setValue<bool>(std::string path, const bool &val);
-extern template void Configuration::setValue<std::string>(std::string path, const std::string &val);
+extern template bool Configuration::setValue<std::string>(std::string path, const std::string &val);
#endif // CONFIGURATION_H