blob: b6a7e05a7358094611a9505a1ac43193e8ddf13f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* This source code is released into the public domain.
*/
module;
#include <expected>
#include <format>
#include <string>
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,
std::string_view name,
std::string_view description) noexcept;
~string();
/*
* 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<void, error> override;
/*
* Convert this option to a UCL object.
*/
[[nodiscard]] auto get_ucl() const
-> std::expected<ucl::object, error> override;
/*
* Set this option from a UCL object.
*/
[[nodiscard]] auto set_ucl(ucl::object const &uclobj)
-> std::expected<void, error> override;
private:
std::string &m_storage;
};
} // namespace nihil::config
|