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

#include <arg_router/mode.hpp>

Inherits detail::add_anonymous_error_name_to_mode::type.

Classes

class  help_data_type
 

Public Types

using value_type = boost::mp11::mp_transform< traits::get_value_type, boost::mp11::mp_remove_if< children_type, policy::has_no_result_value > >
 

Public Member Functions

template<auto has_none_or_error_name = add_missing_error_name_type::has_none_or_error_name>
constexpr mode_t (Params... params, std::enable_if_t< has_none_or_error_name > *=nullptr) 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
 
template<typename... Parents>
void parse (parsing::parse_target target, const Parents &... parents) const
 

Static Public Attributes

constexpr static bool is_anonymous = !traits::has_none_name_method_v<mode_t>
 

Detailed Description

template<typename... Params>
class arg_router::mode_t< Params >

Allows the grouping of nodes to define operational modes for a program.

If no none name policy is provided, then the node is regarded as 'anonymous', and there can only be one in the parse tree. Conversely, if any mode is named, then there can only be named modes in the parse tree.

A mode must have at least one child node.

Template Parameters
ParamsPolicies and child node types for the mode

Definition at line 56 of file mode.hpp.

Member Typedef Documentation

◆ value_type

template<typename... Params>
using arg_router::mode_t< Params >::value_type = boost::mp11::mp_transform< traits::get_value_type, boost::mp11::mp_remove_if<children_type, policy::has_no_result_value> >

Tuple of valid children value types.

Definition at line 99 of file mode.hpp.

Constructor & Destructor Documentation

◆ mode_t()

template<typename... Params>
template<auto has_none_or_error_name = add_missing_error_name_type::has_none_or_error_name>
constexpr arg_router::mode_t< Params >::mode_t ( Params...  params,
std::enable_if_t< has_none_or_error_name > *  = nullptr 
)
inlineexplicitconstexprnoexcept

Constructor.

Parameters
paramsPolicy and child instances

Definition at line 151 of file mode.hpp.

Member Function Documentation

◆ parse()

template<typename... Params>
template<typename... Parents>
void arg_router::mode_t< Params >::parse ( parsing::parse_target  target,
const Parents &...  parents 
) const
inline

Parse function.

This function will recurse into child nodes to find matching tokens, a mode must have a routing phase policy which is why this method does not return the parsed tuple.

Template Parameters
ParentsPack of parent tree nodes in ascending ancestry order
Parameters
targetParse target
parentsParents instances pack
Exceptions
multi_lang_exceptionThrown if parsing failed

Definition at line 204 of file mode.hpp.

◆ pre_parse()

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

Mode pre-parse implementation.

Delegates the pre-parsing to any matching child modes, otherwise iterates over the tokens dispatching to any matching children until the tokens are consumed or all of the children have been matched.

Template Parameters
ValidatorValidator type
HasTargetTrue if pre_parse_data contains the parent's parse_target. It is a static_assert failure is this true for a mode
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 a child node cannot be found, or a delegated child pre-parse policy throws

Definition at line 184 of file mode.hpp.

Member Data Documentation

◆ is_anonymous

template<typename... Params>
constexpr static bool arg_router::mode_t< Params >::is_anonymous = !traits::has_none_name_method_v<mode_t>
staticconstexpr

True if this mode is anonymous.

Definition at line 104 of file mode.hpp.


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