arg_router  1.4.0
C++ command line argument parsing and routing
arg_router::policy::custom_parser< T > Class Template Reference

#include <arg_router/policy/custom_parser.hpp>

Public Types

using value_type = T
 
using parser_type = std::function< value_type(std::string_view)>
 

Public Member Functions

constexpr custom_parser (parser_type p) noexcept
 
template<typename ValueType , typename... Parents>
constexpr ValueType parse_phase (std::string_view token, [[maybe_unused]] const Parents &... parents) const
 

Detailed Description

template<typename T>
class arg_router::policy::custom_parser< T >

Provides the ability for an argument to have a user-provided value parser.

Template Parameters
TArgument's value type i.e. the type the parser needs to return

Definition at line 20 of file custom_parser.hpp.

Member Typedef Documentation

◆ parser_type

template<typename T >
using arg_router::policy::custom_parser< T >::parser_type = std::function<value_type(std::string_view)>

Parser signature.

Definition at line 27 of file custom_parser.hpp.

◆ value_type

template<typename T >
using arg_router::policy::custom_parser< T >::value_type = T

Alias of T.

Definition at line 24 of file custom_parser.hpp.

Constructor & Destructor Documentation

◆ custom_parser()

template<typename T >
constexpr arg_router::policy::custom_parser< T >::custom_parser ( parser_type  p)
inlineexplicitconstexprnoexcept

Constructor.

Parameters
pCustom parser

Definition at line 33 of file custom_parser.hpp.

Member Function Documentation

◆ parse_phase()

template<typename T >
template<typename ValueType , typename... Parents>
constexpr ValueType arg_router::policy::custom_parser< T >::parse_phase ( std::string_view  token,
[[maybe_unused] ] const Parents &...  parents 
) const
inlineconstexpr

Parse str to produce an equivalent instance of value_type.

Template Parameters
ValueTypeParsed value type, must be implicity convertible from value_type
ParentsPack of parent tree nodes in ascending ancestry order
Parameters
tokenToken to parse
parentsParents instances pack
Returns
Parsed value
Exceptions
multi_lang_exceptionThrown if parsing failed

Definition at line 45 of file custom_parser.hpp.


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