13 #define PM_LIFT(mem_fn) [&](auto... args) { return mem_fn(args...); } 14 #define PM_PREREQ(...) [&] { __VA_ARGS__ return DependsOutcome::SUCCESS; } 18 template <
typename Flag>
19 constexpr
const auto getFlag = [](
const rapidjson::Value& json_flag,
auto error) {
20 if (
auto v = Flag::from_string({json_flag.GetString(), json_flag.GetStringLength()}); v)
21 return std::optional{*v};
22 return error(301), std::optional<Flag>{std::nullopt};
24 template <
class F>
auto getCombinedFlags(
const rapidjson::Value& json_flag,
JsonRes& json_res) noexcept -> std::optional<F> {
25 auto error = [&](
auto... args) {
return json_res.error(args...), std::nullopt; };
28 if (json_flag.IsArray()) {
29 const auto json_arr = json_flag.GetArray();
31 for (
const auto& json_str : json_arr) {
32 const auto v = getFlag<F>(json_str, error);
38 if (json_arr.Size() > 1)
40 return {json_arr.Empty() ? F{} : getFlag<F>(json_arr[0], error)};
42 }
else if (json_flag.IsString()) {
43 const auto v = getFlag<F>(json_flag, error);
52 using Arr = std::array<std::function<DependsOutcome()>,
sizeof...(actions)>;
53 for (
auto&& action : Arr{actions...}) {
61 [[nodiscard]] constexpr
auto keys()
const noexcept ->
auto& {
return static_cast<const CRTP&
>(*this).keys; }
62 [[nodiscard]] constexpr
auto fcns()
const noexcept ->
auto& {
return static_cast<const CRTP&
>(*this).fcns; }
65 constexpr Hdl
operator[](std::string_view sv)
const noexcept {
66 const auto it =
cexpr::find(keys().begin(), keys().end(), sv);
67 if (it == keys().end())
69 const auto idx = std::distance(keys().begin(), it);
#define UNREACHABLE
Definition: utility.hpp:19
constexpr Hdl operator[](std::string_view sv) const noexcept
Definition: actions_table.hpp:65
auto getCombinedFlags(const rapidjson::Value &json_flag, JsonRes &json_res) noexcept-> std::optional< F >
Definition: actions_table.hpp:24
Definition: json_utils.hpp:21
constexpr auto action_scope
Definition: actions_table.hpp:51
constexpr auto test_sfinae(Lambda lambda, Ts &&...) -> decltype(lambda(std::declval< Ts >()...), bool
Definition: utility.hpp:37
constexpr InputIt find(InputIt first, InputIt last, const T &value)
Definition: cexpr_algs.hpp:4
constexpr const auto getFlag
Definition: actions_table.hpp:19
Definition: actions_table.hpp:60