7 #include "arg_router/policy/min_max_count.hpp"
8 #include "arg_router/tree_node.hpp"
24 template <
typename T, std::size_t MinCount,
typename... Policies>
28 "Arg must only contain policies (not other nodes)");
32 template <std::
size_t N>
33 constexpr
static bool has_fixed_count = []() {
34 return (parent_type::minimum_count() == N) && (parent_type::maximum_count() == N);
37 static_assert(!has_fixed_count<0>,
"Cannot have a fixed count of zero");
38 static_assert(has_fixed_count<1> || traits::has_push_back_method_v<T>,
39 "value_type must have a push_back() method");
41 static_assert(traits::has_long_name_method_v<multi_arg_base_t> ||
42 traits::has_short_name_method_v<multi_arg_base_t> ||
43 traits::has_none_name_method_v<multi_arg_base_t> ||
44 traits::has_display_name_method_v<multi_arg_base_t>,
48 using typename parent_type::policies_type;
54 template <
bool Flatten>
55 using help_data_type =
typename parent_type::template default_leaf_help_data_type<Flatten>;
64 std::enable_if_t<has_min_max>* =
nullptr) noexcept :
65 parent_type{std::move(policies)...}
69 template <
auto has_min_max = add_missing_min_max_policy<MinCount, Policies...>::has_min_max>
72 std::enable_if_t<!has_min_max>* =
nullptr) noexcept :
73 parent_type{policy::min_max_count_t<
74 traits::integral_constant<MinCount>,
75 traits::integral_constant<std::numeric_limits<std::size_t>::max()>>{},
76 std::move(policies)...}
80 template <
typename Validator,
bool HasTarget,
typename... Parents>
81 [[nodiscard]] std::optional<parsing::parse_target> pre_parse(
82 parsing::pre_parse_data<Validator, HasTarget> pre_parse_data,
83 const Parents&... parents)
const
85 return parent_type::pre_parse(pre_parse_data, *
this, parents...);
97 template <
typename... Parents>
101 if constexpr (traits::has_push_back_method_v<value_type> &&
102 !traits::is_specialisation_of_v<value_type, std::basic_string> &&
103 !std::is_same_v<T, string>) {
104 for (
auto token : target.
tokens()) {
106 parent_type::template parse<value_type>(token.name, *
this, parents...));
108 }
else if (!target.
tokens().empty()) {
109 result = parent_type::template parse<value_type>(target.
tokens().front().name,
116 [&](
auto&&... ancestors) {
117 utility::tuple_type_iterator<policies_type>([&](
auto i) {
118 using policy_type = std::tuple_element_t<i, policies_type>;
119 if constexpr (policy::has_validation_phase_method_v<policy_type, value_type>) {
120 this->policy_type::validation_phase(result, ancestors.get()...);
127 using routing_policy =
128 typename parent_type::template phase_finder_t<policy::has_routing_phase_method>;
129 if constexpr (!std::is_void_v<routing_policy>) {
130 this->routing_policy::routing_phase(std::move(result));
value_type parse(parsing::parse_target target, const Parents &... parents) const
constexpr multi_arg_base_t(Policies... policies, std::enable_if_t< has_min_max > *=nullptr) noexcept
typename parent_type::template default_leaf_help_data_type< Flatten > help_data_type
vector< token_type > & tokens() noexcept
constexpr auto clean_node_ancestry_list(const BaseNode &base_node, const DerivedAndParents &... derived_and_parents)
constexpr auto is_all_policies_v