7 #include "arg_router/policy/default_value.hpp"
8 #include "arg_router/policy/description.hpp"
9 #include "arg_router/policy/long_name.hpp"
10 #include "arg_router/policy/min_max_count.hpp"
11 #include "arg_router/policy/short_form_expander.hpp"
12 #include "arg_router/policy/short_name.hpp"
13 #include "arg_router/tree_node.hpp"
14 #include "arg_router/utility/string_to_policy.hpp"
28 template <
typename... Policies>
30 public tree_node<policy::default_value<bool>,
31 policy::min_max_count_t<traits::integral_constant<std::size_t{0}>,
32 traits::integral_constant<std::size_t{0}>>,
33 std::decay_t<Policies>...>
36 "Flags must only contain policies (not other nodes)");
42 std::decay_t<Policies>...>;
44 static_assert(traits::has_long_name_method_v<flag_t> || traits::has_short_name_method_v<flag_t>,
45 "Flag must have a long and/or short name policy");
46 static_assert(!traits::has_display_name_method_v<flag_t>,
47 "Flag must not have a display name policy");
48 static_assert(!traits::has_none_name_method_v<flag_t>,
"Flag must not have a none name policy");
57 template <
bool Flatten>
58 using help_data_type =
typename parent_type::template default_leaf_help_data_type<Flatten>;
64 constexpr
explicit flag_t(Policies... policies) noexcept :
68 std::move(policies)...}
72 template <
typename Validator,
bool HasTarget,
typename... Parents>
73 [[nodiscard]] std::optional<parsing::parse_target> pre_parse(
74 parsing::pre_parse_data<Validator, HasTarget> pre_parse_data,
75 const Parents&... parents)
const
89 template <
typename... Parents>
91 [[maybe_unused]]
const Parents&... parents)
const
94 const auto result =
true;
97 using routing_policy =
99 if constexpr (!std::is_void_v<routing_policy>) {
100 this->routing_policy::routing_phase(result);
110 "Flag does not support policies with parse or validation phases "
111 "(e.g. custom_parser or min_max_value)");
135 template <
typename... Policies>
136 [[nodiscard]] constexpr
auto flag(Policies... policies) noexcept
139 [](
auto... converted_policies) {
142 constexpr
auto has_short_name =
143 boost::mp11::mp_any_of<std::tuple<std::decay_t<decltype(converted_policies)>...>,
148 return flag_t{std::move(converted_policies)...};
155 std::move(policies)...));
value_type parse([[maybe_unused]] parsing::parse_target &&target, [[maybe_unused]] const Parents &... parents) const
typename parent_type::template default_leaf_help_data_type< Flatten > help_data_type
constexpr flag_t(Policies... policies) noexcept
constexpr static bool any_phases_v
typename phase_finder< PolicyChecker, Args... >::type phase_finder_t
boost::mp11::mp_filter< policy::is_policy, parameters_type > policies_type
std::optional< parsing::parse_target > pre_parse(parsing::pre_parse_data< Validator, HasTarget > pre_parse_data, const Node &node, const Parents &... parents) const
constexpr auto short_prefix
constexpr auto long_prefix
constexpr auto short_form_expander
constexpr auto is_all_policies_v
std::integral_constant< decltype(Value), Value > integral_constant
constexpr auto convert(Params &&... params) noexcept
constexpr auto flag(Policies... policies) noexcept