From 0c1d1a0f24655c22a373c19aac90a6a225a353e6 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sat, 8 Dec 2018 10:43:50 +0100 Subject: wanda: reformat source code --- src/setting.hpp | 134 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 68 deletions(-) (limited to 'src/setting.hpp') diff --git a/src/setting.hpp b/src/setting.hpp index 6e10a8a..997109a 100644 --- a/src/setting.hpp +++ b/src/setting.hpp @@ -23,46 +23,44 @@ namespace wanda { + struct setting; -struct setting; - -/** - * @brief A convenience type to represent setting keys - */ -using key = type_wrapper; + /** + * @brief A convenience type to represent setting keys + */ + using key = type_wrapper; -namespace literals -{ -/** - * @brief UDL to create setting keys - */ -key operator""_key(char const *str, std::size_t len); + namespace literals + { + /** + * @brief UDL to create setting keys + */ + key operator""_key(char const * str, std::size_t len); -/** - * @brief UDL to create setting schemas - */ -std::optional operator""_setting(char const *str, std::size_t lent); -} // namespace literals + /** + * @brief UDL to create setting schemas + */ + std::optional operator""_setting(char const * str, std::size_t lent); + } // namespace literals -/** - * @brief A simple wrapper for GSettings Schemas - */ -struct setting -{ - struct entry + /** + * @brief A simple wrapper for GSettings Schemas + */ + struct setting { + struct entry + { + using value_type = std::variant>; - using value_type = std::variant>; - - value_type operator*() const; + value_type operator*() const; - template - bool operator=(Type value) - { - struct setting_applier + template + bool operator=(Type value) { - setting_applier(GSettings *setting, gchar const *key, Type value) noexcept - : m_result{[&] { + struct setting_applier + { + setting_applier(GSettings * setting, gchar const * key, Type value) noexcept + : m_result{[&] { if constexpr (std::is_same_v) { return g_settings_set_boolean(setting, key, value); @@ -94,7 +92,7 @@ struct setting else if constexpr (std::is_same_v>) { auto temp = std::vector{value.size() + 1}; - std::transform(value.begin(), value.end(), temp.begin(), [](auto const &str) { return str.c_str(); }); + std::transform(value.begin(), value.end(), temp.begin(), [](auto const & str) { return str.c_str(); }); return g_settings_set_strv(setting, key, temp.data()); } else @@ -102,53 +100,53 @@ struct setting static_assert(deferred_failure{}, "Invalid argument type!"); } }()} - { - } + { + } - ~setting_applier() - { - g_settings_sync(); - } + ~setting_applier() + { + g_settings_sync(); + } - operator bool() const - { - return m_result; - } + operator bool() const + { + return m_result; + } - private: - gboolean const m_result; - }; + private: + gboolean const m_result; + }; - return setting_applier{m_settings.get(), m_key.get().c_str(), value}; - } + return setting_applier{m_settings.get(), m_key.get().c_str(), value}; + } - private: - entry(setting const &schema, key key); + private: + entry(setting const & schema, key key); - std::unique_ptr m_settings; + std::unique_ptr m_settings; - key m_key; + key m_key; - friend setting; - }; + friend setting; + }; - /** - * @brief Get the entry for the given key - * - * @return An std::optional wrapping the entry associated with - * the given key, or an empty std::optional if the desired key - * does not exist in the setting's schema. - */ - std::optional operator[](key key) const; + /** + * @brief Get the entry for the given key + * + * @return An std::optional wrapping the entry associated with + * the given key, or an empty std::optional if the desired key + * does not exist in the setting's schema. + */ + std::optional operator[](key key) const; -private: - explicit setting(GSettingsSchema *schema); + private: + explicit setting(GSettingsSchema * schema); - std::unique_ptr m_schema; + std::unique_ptr m_schema; - friend std::optional literals::operator""_setting(char const *, std::size_t); -}; + friend std::optional literals::operator""_setting(char const *, std::size_t); + }; -} // namespace wanda +} // namespace wanda #endif \ No newline at end of file -- cgit v1.2.3