aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.config/string.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-23 18:34:18 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-23 18:34:18 +0100
commit32b4443ba2ec5c3f7c09221ab9b21911a3126ef9 (patch)
treecb6346997078626dc512e5e46e95796e375690ee /nihil.config/string.ccm
parentd5963532328ce5f1c9f266bf7e760b7d18a60c15 (diff)
downloadnihil-32b4443ba2ec5c3f7c09221ab9b21911a3126ef9.tar.gz
nihil-32b4443ba2ec5c3f7c09221ab9b21911a3126ef9.tar.bz2
add separate module implementation files
Diffstat (limited to 'nihil.config/string.ccm')
-rw-r--r--nihil.config/string.ccm42
1 files changed, 6 insertions, 36 deletions
diff --git a/nihil.config/string.ccm b/nihil.config/string.ccm
index 57770ae..ae5efb9 100644
--- a/nihil.config/string.ccm
+++ b/nihil.config/string.ccm
@@ -9,10 +9,8 @@ module;
export module nihil.config:string;
-import nihil;
import nihil.ucl;
import :option;
-import :store;
namespace nihil::config {
@@ -20,43 +18,15 @@ export struct string final : option
{
string(std::string &storage,
std::string_view name,
- std::string_view description) noexcept
- : option(name, description)
- , _storage(storage)
- {
- store::get().register_option(this);
- }
+ std::string_view description) noexcept;
- ~string()
- {
- store::get().unregister_option(this);
- }
+ ~string();
- auto get_string() const -> std::string override
- {
- return _storage;
- };
+ auto get_string() const -> std::string override;
+ auto set_string(std::string_view new_value) -> void override;
- auto set_string(std::string_view new_value) -> void override
- {
- _storage = new_value;
- }
-
- auto to_ucl() const -> ucl::object override
- {
- return ucl::string(_storage);
- }
-
- auto from_ucl(ucl::object const &uclobj) -> void override
- {
- try {
- _storage = object_cast<ucl::string>(uclobj).value();
- is_default(false);
- } catch (ucl::type_mismatch const &exc) {
- throw error(std::format("'{}': expected string, not {}",
- name(), str(exc.actual_type())));
- }
- }
+ auto to_ucl() const -> ucl::object override;
+ auto from_ucl(ucl::object const &uclobj) -> void override;
private:
std::string &_storage;