aboutsummaryrefslogtreecommitdiff
path: root/src/setting.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2018-11-24 20:38:48 +0100
committerFelix Morgner <felix.morgner@gmail.com>2018-11-24 20:38:48 +0100
commite70f0b4de81d24d22a29a2af03c669368fce6af2 (patch)
treef91dfd02434ce460e6120c7747aa0092cbd2327f /src/setting.cpp
downloadwanda-e70f0b4de81d24d22a29a2af03c669368fce6af2.tar.xz
wanda-e70f0b4de81d24d22a29a2af03c669368fce6af2.zip
wanda: initial commit
Diffstat (limited to 'src/setting.cpp')
-rw-r--r--src/setting.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/setting.cpp b/src/setting.cpp
new file mode 100644
index 0000000..9ddbfe8
--- /dev/null
+++ b/src/setting.cpp
@@ -0,0 +1,29 @@
+#include "setting.hpp"
+
+namespace wanda {
+
+namespace literals {
+ key operator""_key(char const * str, std::size_t len) {
+ return key{{str, len}};
+ }
+
+ std::optional<setting> operator""_setting(char const * str, std::size_t len) {
+ auto source = g_settings_schema_source_get_default();
+ auto schema = g_settings_schema_source_lookup(source, str, true);
+ if(schema) {
+ g_settings_schema_unref(schema);
+ return setting{::wanda::schema{{str, len}}};
+ }
+ return std::nullopt;
+ }
+}
+
+setting::setting(schema schema) : m_value{g_settings_new(schema.get().c_str())} { }
+
+setting::setting(setting const & other) : m_value{reinterpret_cast<GSettings *>(g_object_ref(other.m_value))} { }
+
+setting::~setting() {
+ g_clear_object(&m_value);
+}
+
+} \ No newline at end of file