From 90aa957ca9b7c217af7569009d1675e0f3ff8e9b Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Thu, 26 Jun 2025 20:47:45 +0100 Subject: ucl, config: use monadic error handling more --- nihil.config/string.ccm | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'nihil.config/string.ccm') diff --git a/nihil.config/string.ccm b/nihil.config/string.ccm index ae5efb9..b6a7e05 100644 --- a/nihil.config/string.ccm +++ b/nihil.config/string.ccm @@ -4,16 +4,21 @@ module; +#include #include #include export module nihil.config:string; +import nihil; import nihil.ucl; import :option; namespace nihil::config { +/* + * A string option. The backing type is std::string. + */ export struct string final : option { string(std::string &storage, @@ -22,14 +27,31 @@ export struct string final : option ~string(); - auto get_string() const -> std::string override; - auto set_string(std::string_view new_value) -> void override; - - auto to_ucl() const -> ucl::object override; - auto from_ucl(ucl::object const &uclobj) -> void override; + /* + * Get this option as a string; simply returns the storage. + */ + [[nodiscard]] auto get_string() const -> std::string override; + + /* + * Set this option to a string value; assigns to the storage. + */ + [[nodiscard]] auto set_string(std::string_view new_value) + -> std::expected override; + + /* + * Convert this option to a UCL object. + */ + [[nodiscard]] auto get_ucl() const + -> std::expected override; + + /* + * Set this option from a UCL object. + */ + [[nodiscard]] auto set_ucl(ucl::object const &uclobj) + -> std::expected override; private: - std::string &_storage; + std::string &m_storage; }; } // namespace nihil::config -- cgit v1.2.3