arg_router  1.4.0
C++ command line argument parsing and routing
arg_router::parsing::pre_parse_data< Validator, bool > Class Template Reference

Detailed Description

template<typename Validator, bool>
class arg_router::parsing::pre_parse_data< Validator, bool >

A simple wrapper struct over non-parent data used by the node's pre_parse(..) method.

As each tree_node derived type must reimplement the pre_parse(..) method to at least add a reference to themselves, then overloads cause a lot of extra boilerplate. By wrapping the arg variations for each of those overloads into another type (this one), the user will only need to change a single overload with any variation of compile-time switchable.

There are two specialisations of pre_parse_data, one that carries a parse_target reference and one that doesn't. The difference is invisible at construction, but changes how it is used:

auto args = std::vector<parsing::token_type>{"-f"};
auto ppd = parsing::pre_parse_data{args};
...
auto target = parsing::parse_target{node, parents...};
if constexpr (ppd.has_target) { // In this example, this is false
target = ppd.target(); // Must be wrapped in if, as target() does not exist is
// non-target constructed version
}
Template Parameters
ValidatorValidation checker type, see specialisation documentation for more info

Definition at line 90 of file pre_parse_data.hpp.


The documentation for this class was generated from the following file: