diff options
| author | Rutger Broekhoff | 2026-08-29 12:01:42 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-08-29 12:01:42 +0200 |
| commit | 52b3cd46c76fd4be18aeb8422a08a073484b9fad (patch) | |
| tree | b4f23957c096e6bce5369bb94a4e8e23de71761a /server/src/problem.cppm | |
| parent | 35878b76049b9c3e752480e9f298b7e2da6fdf1f (diff) | |
| download | routemon-52b3cd46c76fd4be18aeb8422a08a073484b9fad.tar.gz routemon-52b3cd46c76fd4be18aeb8422a08a073484b9fad.zip | |
More module implementation partition units
Diffstat (limited to 'server/src/problem.cppm')
| -rw-r--r-- | server/src/problem.cppm | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/server/src/problem.cppm b/server/src/problem.cppm index 37e6257..18c2fe2 100644 --- a/server/src/problem.cppm +++ b/server/src/problem.cppm | |||
| @@ -22,39 +22,14 @@ export struct details | |||
| 22 | std::optional<blocale::message> detail = std::nullopt; | 22 | std::optional<blocale::message> detail = std::nullopt; |
| 23 | std::optional<std::string> instance = std::nullopt; | 23 | std::optional<std::string> instance = std::nullopt; |
| 24 | 24 | ||
| 25 | auto set_detail(blocale::message detail) -> details& | 25 | auto set_detail(blocale::message detail) -> details&; |
| 26 | { | 26 | auto set_instance(std::string&& instance) -> details&; |
| 27 | this->detail = detail; | 27 | auto set_instance(std::string_view instance) -> details&; |
| 28 | return *this; | ||
| 29 | } | ||
| 30 | |||
| 31 | auto set_instance(std::string&& instance) -> details& | ||
| 32 | { | ||
| 33 | this->instance = instance; | ||
| 34 | return *this; | ||
| 35 | } | ||
| 36 | auto set_instance(std::string_view instance) -> details& | ||
| 37 | { | ||
| 38 | this->instance = std::string{instance}; | ||
| 39 | return *this; | ||
| 40 | } | ||
| 41 | }; | 28 | }; |
| 42 | 29 | ||
| 43 | export auto tag_invoke( | 30 | auto tag_invoke( |
| 44 | json::value_from_tag, json::value& jv, details const& details, | 31 | json::value_from_tag, json::value& jv, details const& details, |
| 45 | std::locale locale) -> void | 32 | std::locale locale) -> void; |
| 46 | { | ||
| 47 | auto obj = json::object{ | ||
| 48 | {"type", details.type_uri}, | ||
| 49 | {"title", details.title.str(locale)}, | ||
| 50 | {"status", static_cast<unsigned>(details.status)}, | ||
| 51 | }; | ||
| 52 | if (details.detail) | ||
| 53 | obj["detail"] = details.detail->str(locale); | ||
| 54 | if (details.instance) | ||
| 55 | obj["instance"] = *details.instance; | ||
| 56 | jv = obj; | ||
| 57 | } | ||
| 58 | 33 | ||
| 59 | export struct tpl | 34 | export struct tpl |
| 60 | { | 35 | { |
| @@ -62,10 +37,7 @@ export struct tpl | |||
| 62 | blocale::message title; | 37 | blocale::message title; |
| 63 | std::string_view type_uri; | 38 | std::string_view type_uri; |
| 64 | 39 | ||
| 65 | auto instantiate() const -> details | 40 | auto instantiate() const -> details; |
| 66 | { | ||
| 67 | return details{status, title, type_uri}; | ||
| 68 | } | ||
| 69 | }; | 41 | }; |
| 70 | 42 | ||
| 71 | } // namespace routemon::problem | 43 | } // namespace routemon::problem |