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.cc | |
| parent | d5963532328ce5f1c9f266bf7e760b7d18a60c15 (diff) | |
| download | nihil-32b4443ba2ec5c3f7c09221ab9b21911a3126ef9.tar.gz nihil-32b4443ba2ec5c3f7c09221ab9b21911a3126ef9.tar.bz2 | |
add separate module implementation files
Diffstat (limited to 'nihil.config/option.cc')
| -rw-r--r-- | nihil.config/option.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/nihil.config/option.cc b/nihil.config/option.cc new file mode 100644 index 0000000..9bf77c9 --- /dev/null +++ b/nihil.config/option.cc @@ -0,0 +1,67 @@ +/* + * This source code is released into the public domain. + */ + +module; + +#include <iostream> +#include <string> + +module nihil.config; + +namespace nihil::config { + +auto option::name(this option const &self) noexcept +-> std::string_view +{ + return self._name; +} + +// Human-readable description of this option. +auto option::description(this option const &self) noexcept +-> std::string_view +{ + return self._description; +} + +// If true, this option is set to its default value. +auto option::is_default(this option const &self) noexcept +-> bool +{ + return self._is_default; +} + +// Get or set this option as a string. +auto option::string(this option const &self) +-> std::string +{ + return self.get_string(); +} + +auto option::string(this option &self, std::string_view value) +-> void +{ + self.set_string(value); + self._is_default = false; +} + +option::option(std::string_view name, + std::string_view description) + : _name(name) + , _description(description) +{ +} + +auto option::is_default(bool b) +-> void +{ + _is_default = b; +} + +auto operator<<(std::ostream &strm, option const &opt) +-> std::ostream & +{ + return strm << "<" << opt.name() << "=" << opt.string() << ">"; +} + +} // namespace nihil |
