diff options
Diffstat (limited to 'lib/settings/configuration.h')
-rw-r--r-- | lib/settings/configuration.h | 32 |
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 |