7 #include "arg_router/policy/description.hpp"
8 #include "arg_router/policy/long_name.hpp"
9 #include "arg_router/policy/min_max_count.hpp"
10 #include "arg_router/policy/multi_stage_value.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"
29 template <
typename T,
typename... Policies>
31 public tree_node<policy::multi_stage_value<T, bool>,
32 policy::min_max_count_t<traits::integral_constant<std::size_t{0}>,
33 traits::integral_constant<std::size_t{0}>>,
34 std::decay_t<Policies>...>
37 "Counting flags must only contain policies (not other nodes)");
38 static_assert(traits::has_long_name_method_v<counting_flag_t> ||
39 traits::has_short_name_method_v<counting_flag_t>,
40 "Counting flag must have a long and/or short name policy");
41 static_assert(!traits::has_display_name_method_v<counting_flag_t>,
42 "Counting flag must not have a display name policy");
43 static_assert(!traits::has_none_name_method_v<counting_flag_t>,
44 "Counting flag must not have a none name policy");
45 static_assert(traits::supports_static_cast_conversion_v<T, std::size_t>,
46 "T must be explicitly convertible to std::size_t");
52 std::decay_t<Policies>...>;
61 template <
bool Flatten>
62 using help_data_type =
typename parent_type::template default_leaf_help_data_type<Flatten>;
72 std::move(policies)...}
76 template <
typename Validator,
bool HasTarget,
typename... Parents>
77 [[nodiscard]] std::optional<parsing::parse_target> pre_parse(
78 parsing::pre_parse_data<Validator, HasTarget> pre_parse_data,
79 const Parents&... parents)
const
92 template <
typename... Parents>
94 [[maybe_unused]]
const Parents&... parents)
const noexcept
105 "Counting flag does not support policies with parse or routing phases "
106 "(e.g. custom_parser)");
109 constexpr
static void merge_impl(std::optional<value_type>& result,
bool ) noexcept
116 *result =
static_cast<value_type>(
static_cast<std::size_t
>(*result) + 1);
143 template <
typename T,
typename... Policies>
147 [](
auto... converted_policies) {
150 constexpr
auto has_short_name =
151 boost::mp11::mp_any_of<std::tuple<std::decay_t<decltype(converted_policies)>...>,
156 std::decay_t<decltype(converted_policies)>...>{
158 std::move(converted_policies)...};
160 return counting_flag_t<T, std::decay_t<decltype(converted_policies)>...>{
161 std::move(converted_policies)...};
168 std::move(policies)...));
bool parse([[maybe_unused]] parsing::parse_target &&target, [[maybe_unused]] const Parents &... parents) const noexcept
typename parent_type::template default_leaf_help_data_type< Flatten > help_data_type
constexpr counting_flag_t(Policies... policies) noexcept
constexpr static bool any_phases_v
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 counting_flag(Policies... policies) noexcept