7 #include "arg_router/parsing/token_type.hpp"
8 #include "arg_router/utility/tree_recursor.hpp"
26 }
else if (b.size() == 0) {
30 const auto n =
count(b);
33 std::iota(costs.begin(), costs.end(), 0);
35 auto i = std::size_t{0};
40 auto j = std::size_t{0};
42 const auto upper = costs[j + 1];
44 costs[j + 1] = corner;
46 auto t = std::min(upper, corner);
47 costs[j + 1] = std::min(costs[j], t) + 1;
69 template <
typename Node>
73 static_assert(std::tuple_size_v<typename Node::children_type> > 0,
74 "Node must have at least one child");
77 auto best_score = std::numeric_limits<std::size_t>::max();
85 [&](
const auto& child,
const auto&... parents) {
87 if constexpr (
sizeof...(parents) > 0) {
88 using child_type = std::decay_t<decltype(child)>;
89 using parents_type_without_root =
90 boost::mp11::mp_pop_back<std::tuple<std::decay_t<decltype(parents)>...>>;
97 [&](
auto... parents_without_root) {
101 std::remove_pointer_t<decltype(parents_without_root)>>>()...};
103 boost::mp11::mp_transform<std::add_pointer_t, parents_type_without_root>{});
115 if constexpr (traits::has_long_name_method_v<child_type>) {
118 if (score < best_score) {
120 append_parents({parsing::prefix_type::long_, child.long_name()});
124 if constexpr (traits::has_short_name_method_v<child_type>) {
127 if (score < best_score) {
133 if constexpr (traits::has_none_name_method_v<child_type>) {
136 if (score < best_score) {
constexpr static range_t range(std::string_view str) noexcept
bool is_runtime_disabled(const Node &node, const Parents &... parents) noexcept
token_type get_token_type(std::string_view token)
constexpr token_type node_token_type() noexcept
std::size_t levenshtein_distance(std::string_view a, std::string_view b)
vector< parsing::token_type > closest_matching_child_node(const Node &node, parsing::token_type token)
constexpr std::size_t count(std::string_view str) noexcept
constexpr void tree_recursor(Visitor visitor, const Root &root)
std::vector< T, config::allocator< T > > vector
std::string_view name
Token name, stripped of prefix (if any)
prefix_type prefix
Prefix type.