From e70f0b4de81d24d22a29a2af03c669368fce6af2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 24 Nov 2018 20:38:48 +0100 Subject: wanda: initial commit --- src/setting.hpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/setting.hpp (limited to 'src/setting.hpp') diff --git a/src/setting.hpp b/src/setting.hpp new file mode 100644 index 0000000..6293dd3 --- /dev/null +++ b/src/setting.hpp @@ -0,0 +1,48 @@ +#ifndef WANDA_setting_HPP +#define WANDA_setting_HPP + +#include + +#include +#include +#include +#include + +#include "type_wrapper.hpp" +#include "variant.hpp" +#include + +namespace wanda { + +struct setting; +using schema = type_wrapper; +using key = type_wrapper; + +namespace literals { +key operator""_key(char const * str, std::size_t len); +std::optional operator""_setting(char const * str, std::size_t len); +} + +struct setting { + ~setting(); + + setting(setting const & other); + + template std::optional get(key key) const { + auto value = variant{g_settings_get_value(m_value, key.get().c_str())}; + return value.get(); + } + +private: + explicit setting(schema schema); + + GSettings * m_value; + + friend std::optional literals::operator""_setting(char const *, std::size_t); +}; + + +} + + +#endif \ No newline at end of file -- cgit v1.2.3