7 #include "arg_router/parsing/parse_target.hpp"
8 #include "arg_router/parsing/parsing.hpp"
9 #include "arg_router/policy/policy.hpp"
10 #include "arg_router/utility/compile_time_optional.hpp"
34 "Value separator must only be one character");
36 "Value separator character must not be whitespace");
43 constexpr
static auto priority = std::size_t{1000};
55 [[nodiscard]] constexpr
static std::string_view
value_separator() noexcept {
return S::get(); }
69 template <
typename ProcessedTarget,
typename... Parents>
74 [[maybe_unused]]
const Parents&... parents)
const
76 static_assert((
sizeof...(Parents) >= 1),
77 "At least one parent needed for value_separator_t");
79 using owner_type = boost::mp11::mp_first<std::tuple<Parents...>>;
81 static_assert(traits::has_minimum_count_method_v<owner_type> &&
82 traits::has_maximum_count_method_v<owner_type>,
83 "Value separator support requires an owning node to have "
84 "minimum and maximum count policies");
85 static_assert((owner_type::minimum_count() == 1) && (owner_type::maximum_count() == 1),
86 "Value separator support requires an owning node to have "
87 "a fixed count of 1");
93 auto first = tokens.
begin();
94 const auto first_token = *first;
97 const auto separator_index = first_token.name.find_first_of(
value_separator());
98 if (separator_index == std::string_view::npos) {
101 auto processed_token = first_token;
105 if (parsing::match<owner_type>(processed_token)) {
107 parsing::node_token_type<owner_type>()};
113 const auto value_arg = first_token.name.substr(separator_index + S::get().size());
114 if (value_arg.empty()) {
122 const auto label_arg = first_token.name.substr(0, separator_index);
123 first.
set({first_token.prefix, label_arg});
140 template <
typename S>
143 template <
typename S>
144 struct is_policy<value_separator_t<S>> : std::true_type {
void set(value_type value)
iterator insert(iterator it, value_type value)
constexpr static std::string_view value_separator() noexcept
constexpr static auto priority
parsing::pre_parse_result pre_parse_phase(parsing::dynamic_token_adapter &tokens, [[maybe_unused]] utility::compile_time_optional< ProcessedTarget > processed_target, [[maybe_unused]] parsing::parse_target &target, [[maybe_unused]] const Parents &... parents) const
constexpr value_separator_t([[maybe_unused]] S str={}) noexcept
token_type get_token_type(std::string_view token)
constexpr auto value_separator
constexpr auto value_separator_utf8
constexpr bool is_whitespace(std::string_view str) noexcept
constexpr std::size_t count(std::string_view str) noexcept
@ missing_value_separator