aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/GlobalSettingStation.h
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-08 09:26:41 +0000
committersaturneric <[email protected]>2024-01-08 09:26:41 +0000
commit5222a2fd1ba372f6eb67dc8fa71e334f1ff10bbb (patch)
tree7a868b8f56986083d5e0aa4c64cb74c34cdbf73f /src/core/function/GlobalSettingStation.h
parentfeat: remove save keys checked function (diff)
downloadGpgFrontend-5222a2fd1ba372f6eb67dc8fa71e334f1ff10bbb.tar.gz
GpgFrontend-5222a2fd1ba372f6eb67dc8fa71e334f1ff10bbb.zip
fix: solve compile issue
Diffstat (limited to 'src/core/function/GlobalSettingStation.h')
-rw-r--r--src/core/function/GlobalSettingStation.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h
index 5582562a..06f37264 100644
--- a/src/core/function/GlobalSettingStation.h
+++ b/src/core/function/GlobalSettingStation.h
@@ -168,6 +168,26 @@ class GPGFRONTEND_CORE_EXPORT GlobalSettingStation
return value;
}
+ /**
+ * @brief Looks up a setting by path.
+ * @param path The path to the setting.
+ * @param default_value The default value to return if setting is not found.
+ * @return The setting value.
+ */
+ template <typename T>
+ auto SaveSettings(std::string path, libconfig::Setting::Type type,
+ T value) noexcept -> T {
+ try {
+ if (!GetMainSettings().exists(path)) {
+ // TODO
+ GetMainSettings().add(path, type);
+ }
+ } catch (...) {
+ GF_CORE_LOG_WARN("setting not found: {}", path);
+ }
+ return value;
+ }
+
private:
class Impl;
SecureUniquePtr<Impl> p_;