arg_router
1.4.0
C++ command line argument parsing and routing
|
#include <arg_router/tree_node.hpp>
Classes | |
class | any_phases |
class | default_leaf_help_data_type |
struct | phase_finder |
Public Types | |
using | parameters_type = std::tuple< std::decay_t< Params >... > |
using | policies_type = boost::mp11::mp_filter< policy::is_policy, parameters_type > |
using | priority_ordered_policies_type = boost::mp11::mp_sort< policies_type, priority_order > |
using | children_type = boost::mp11::mp_filter< is_tree_node, std::decay_t< decltype(list_expander(std::declval< std::decay_t< Params > >()...))> > |
template<template< typename... > typename PolicyChecker, typename... Args> | |
using | phase_finder_t = typename phase_finder< PolicyChecker, Args... >::type |
Public Member Functions | |
children_type & | children () noexcept |
constexpr const children_type & | children () const noexcept |
Static Public Attributes | |
constexpr static auto | is_named |
template<typename ValueType , template< typename... > typename... PolicyCheckers> | |
constexpr static bool | any_phases_v = any_phases<ValueType, PolicyCheckers...>::value |
Protected Member Functions | |
constexpr | tree_node (Params... params) noexcept |
template<typename Validator , bool HasTarget, typename Node , typename... Parents> | |
std::optional< parsing::parse_target > | pre_parse (parsing::pre_parse_data< Validator, HasTarget > pre_parse_data, const Node &node, const Parents &... parents) const |
template<typename ValueType , typename Node , typename... Parents> | |
auto | parse (std::string_view token, const Node &node, const Parents &... parents) const |
Base type of all nodes of a parse tree, not including policies.
Params | Parameter types |
Definition at line 25 of file tree_node.hpp.
using arg_router::tree_node< Params >::children_type = boost::mp11::mp_filter< is_tree_node, std::decay_t<decltype(list_expander(std::declval<std::decay_t<Params> >()...))> > |
A tuple of all the child tree node types in parameters_type, with any lists expanded.
Definition at line 57 of file tree_node.hpp.
using arg_router::tree_node< Params >::parameters_type = std::tuple<std::decay_t<Params>...> |
The policies and child node types.
Definition at line 48 of file tree_node.hpp.
using arg_router::tree_node< Params >::phase_finder_t = typename phase_finder<PolicyChecker, Args...>::type |
Helper alias for phase_finder.
PolicyChecker | Policy predicate, use one of policy::has_*_phase_method |
Args | Auxiliary arguments to pass to PolicyChecker |
Definition at line 97 of file tree_node.hpp.
using arg_router::tree_node< Params >::policies_type = boost::mp11::mp_filter<policy::is_policy, parameters_type> |
A tuple of all the policy types in parameters_type.
Definition at line 51 of file tree_node.hpp.
using arg_router::tree_node< Params >::priority_ordered_policies_type = boost::mp11::mp_sort<policies_type, priority_order> |
policies_type ordered by priority
Definition at line 54 of file tree_node.hpp.
|
inlineexplicitconstexprprotectednoexcept |
Constructor.
params | Policy and child instances |
Definition at line 435 of file tree_node.hpp.
|
inlineconstexprnoexcept |
|
inlinenoexcept |
|
inlineprotected |
Generic parse call, uses a policy that supports the parse phase if present, or the global parser.
ValueType | Parsed type |
Node | This node's derived type |
Parents | Pack of parent tree nodes in ascending ancestry order |
token | Token to parse |
node | This node instance |
parents | Parents instances pack |
multi_lang_exception | Thrown if parsing failed |
Definition at line 488 of file tree_node.hpp.
|
inlineprotected |
Default pre-parse implementation.
This implementation simply iterates over the pre-parse phase implementing policies, and uses the results to update args and generate a parse_target.
The validator is called just before args is updated, and allows the caller to run a custom verification the on the node and parents. If the validator returns true then the result is kept, otherwise an empty result is returned from this method.
*this
into parents, so derived types are expected to reimplement this so @ node is the correct type (remember there are no virtual methods in this library) Validator | Validator type |
HasTarget | True if pre_parse_data contains the parent's parse_target |
Node | This node's derived type |
Parents | Pack of parent tree nodes in ascending ancestry order |
pre_parse_data | Pre-parse data aggregate |
node | This node instance |
parents | Parent node instances |
multi_lang_exception | Thrown if any of the policies' pre-parse implementations have returned an exception |
Definition at line 465 of file tree_node.hpp.
|
staticconstexpr |
Helper alias for has_phases.
ValueType | Some policy checkers require a value type template parameter, if a particular policy doesn't need it then it is not used |
PolicyCheckers | Parameter pack type of policy predicates, use policy::has_*_phase_method |
Definition at line 142 of file tree_node.hpp.
|
staticconstexpr |
Evaluates to true if this node has a name token that appears on the command line.
Definition at line 68 of file tree_node.hpp.