diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-23 18:34:18 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-23 18:34:18 +0100 |
| commit | 32b4443ba2ec5c3f7c09221ab9b21911a3126ef9 (patch) | |
| tree | cb6346997078626dc512e5e46e95796e375690ee /nihil.config/option.ccm | |
| parent | d5963532328ce5f1c9f266bf7e760b7d18a60c15 (diff) | |
| download | nihil-32b4443ba2ec5c3f7c09221ab9b21911a3126ef9.tar.gz nihil-32b4443ba2ec5c3f7c09221ab9b21911a3126ef9.tar.bz2 | |
add separate module implementation files
Diffstat (limited to 'nihil.config/option.ccm')
| -rw-r--r-- | nihil.config/option.ccm | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/nihil.config/option.ccm b/nihil.config/option.ccm index 1be542e..c6a8329 100644 --- a/nihil.config/option.ccm +++ b/nihil.config/option.ccm @@ -4,11 +4,9 @@ module; -#include <iostream> +#include <iosfwd> #include <string> -#include <ucl++.h> - export module nihil.config:option; import nihil.ucl; @@ -23,34 +21,17 @@ namespace nihil::config { export struct option { // Short name of this option. - auto name(this option const &self) noexcept -> std::string_view - { - return self._name; - } + auto name(this option const &self) noexcept -> std::string_view; // Human-readable description of this option. - auto description(this option const &self) noexcept -> std::string_view - { - return self._description; - } + auto description(this option const &self) noexcept -> std::string_view; // If true, this option is set to its default value. - auto is_default(this option const &self) noexcept -> bool - { - return self._is_default; - } + auto is_default(this option const &self) noexcept -> bool; // Get or set this option as a string. - auto string(this option const &self) -> std::string - { - return self.get_string(); - } - - void string(this option &self, std::string_view value) - { - self.set_string(value); - self._is_default = false; - } + auto string(this option const &self) -> std::string; + auto string(this option &self, std::string_view value) -> void; /* * Return this object as a UCL object. This is used when writing the @@ -69,17 +50,9 @@ export struct option auto operator=(option const &) -> option& = delete; protected: - option(std::string_view name, - std::string_view description) - : _name(name) - , _description(description) - { - } - - auto is_default(bool b) -> void - { - _is_default = b; - } + option(std::string_view name, std::string_view description); + + auto is_default(bool b) -> void; /* * Get or set this option as a string. @@ -96,9 +69,6 @@ private: /* * Make options printable. This is mostly useful for testing. */ -export auto operator<<(std::ostream &strm, option const &opt) -> std::ostream & -{ - return strm << "<" << opt.name() << "=" << opt.string() << ">"; -} +export auto operator<<(std::ostream &strm, option const &opt) -> std::ostream &; } // namespace nihil |
