arg_router  1.4.0
C++ command line argument parsing and routing
arg_router::dependency::alias_group_t< Params > Class Template Reference

#include <arg_router/dependency/alias_group.hpp>

Inherits arg_router::dependency::detail::basic_one_of_t< ParentDocName, Params >.

Classes

class  help_data_type
 

Public Types

using value_type = boost::mp11::mp_first< typename parent_type::basic_value_type >
 

Public Member Functions

constexpr alias_group_t (Params... params) noexcept
 
template<typename Validator , bool HasTarget, typename... Parents>
std::optional< parsing::parse_targetpre_parse (parsing::pre_parse_data< Validator, HasTarget > pre_parse_data, const Parents &... parents) const
 

Detailed Description

template<typename... Params>
class arg_router::dependency::alias_group_t< Params >

Groups child nodes so they all become aliases of a single output.

policy::alias_t defines input aliases, it works by duplicating the input tokens for the node for each of the aliased nodes. An implication of this is that all the aliased nodes need to have the same count and be able to parse the same input tokens, and each aliased node has an entry (but not the node the alias policy is attached to!) in the router arguments.

alias_group_t is almost the opposite of this; it defines output aliases where each child of the group independently parses the tokens it matches to (in the same way one_of_t does). However unlike policy::alias_t, there is only a single entry in the router arguments for the whole group, as such there is a compile-time check that all value_type types are the same (or ignored if policy::no_result_value is used). In other words, all the children of the group represent the same output.

You can think of policy::alias_t as defining a one-to-many alias, whilst alias_group_t is a many-to-one.

Template Parameters
ParamsPolicies and child node types for the mode

Definition at line 34 of file alias_group.hpp.

Member Typedef Documentation

◆ value_type

template<typename... Params>
using arg_router::dependency::alias_group_t< Params >::value_type = boost::mp11::mp_first<typename parent_type::basic_value_type>

The common output type of the all the children that support it.

Definition at line 43 of file alias_group.hpp.

Constructor & Destructor Documentation

◆ alias_group_t()

template<typename... Params>
constexpr arg_router::dependency::alias_group_t< Params >::alias_group_t ( Params...  params)
inlineexplicitconstexprnoexcept

Constructor.

Parameters
paramsPolicy and child instances

Definition at line 94 of file alias_group.hpp.

Member Function Documentation

◆ pre_parse()

template<typename... Params>
template<typename Validator , bool HasTarget, typename... Parents>
std::optional<parsing::parse_target> arg_router::dependency::alias_group_t< Params >::pre_parse ( parsing::pre_parse_data< Validator, HasTarget >  pre_parse_data,
const Parents &...  parents 
) const
inline

Propagates the pre-parse phase to the child, returns on a positive return from one of them.

Template Parameters
ValidatorValidator type
HasTargetTrue if pre_parse_data contains the parent's parse_target
ParentsPack of parent tree nodes in ascending ancestry order
Parameters
pre_parse_dataPre-parse data aggregate
parentsParent node instances
Returns
Non-empty if the leading tokens in args are consumable by this node
Exceptions
multi_lang_exceptionThrown if any of the child pre-parse implementations have returned an exception

Definition at line 112 of file alias_group.hpp.


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