26 using std::invalid_argument::invalid_argument;
31inline auto split_key(std::string_view full,
char tok =
'.') {
32 auto tok_pos = full.find(tok);
33 if (tok_pos == full.npos)
34 return std::make_tuple(full, std::string_view{});
35 std::string_view key{full.begin(), full.begin() + tok_pos};
36 std::string_view rem{full.begin() + tok_pos + 1, full.end()};
37 return std::make_tuple(key, rem);
49 T &t, std::string_view prefix, std::span<const std::string_view> options,
50 std::optional<std::span<bool>> used = std::nullopt) {
53 for (
const auto &kv : options) {
56 auto curr_index = index++;
60 (*used)[curr_index] =
true;
61 set_param(t, {.full_key = kv, .key = remainder, .value = value});
void set_param(bool &b, ParamString s)
void set_params(T &t, std::string_view prefix, std::span< const std::string_view > options, std::optional< std::span< bool > > used=std::nullopt)
Overwrites t based on the options that start with prefix.
std::string_view key
The subkey to resolve next.
std::string_view full_key
Full key string, used for diagnostics.
auto split_key(std::string_view full, char tok='.')
Split the string full on the first occurrence of tok.
std::string_view value
The value of the parameter to store.
Represents a parameter value encoded as a string in the format abc.def.key=value.
Custom parameter parsing exception.