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

#include <arg_router/root.hpp>

Inherits detail::add_missing_exception_translator::type.

Classes

class  help_data_type
 

Public Types

using validator_type = std::tuple_element_t< validator_index, policies_type >
 

Public Member Functions

template<auto has_exception_translator = detail::add_missing_exception_translator<Params...>::has_exception_translator>
constexpr root_t (Params... params, std::enable_if_t< has_exception_translator > *=nullptr) noexcept
 
void parse (vector< parsing::token_type > args) const
 
template<typename Iter , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Iter>, int>>>
void parse (Iter begin, Iter end) const
 
template<typename Container , typename = std::enable_if_t< !std::is_same_v<std::decay_t<Container>, vector<parsing::token_type>>>>
void parse (const Container &c) const
 
void parse (int argc, char **argv) const
 
void help ([[maybe_unused]] std::ostream &stream) const
 
string help () const
 

Detailed Description

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

The root of the parse tree.

Template Parameters
ParamsThe top-level policies and child node types

Definition at line 54 of file root.hpp.

Member Typedef Documentation

◆ validator_type

template<typename... Params>
using arg_router::root_t< Params >::validator_type = std::tuple_element_t<validator_index, policies_type>

Validator type.

Definition at line 103 of file root.hpp.

Constructor & Destructor Documentation

◆ root_t()

template<typename... Params>
template<auto has_exception_translator = detail::add_missing_exception_translator<Params...>::has_exception_translator>
constexpr arg_router::root_t< Params >::root_t ( Params...  params,
std::enable_if_t< has_exception_translator > *  = nullptr 
)
inlineexplicitconstexprnoexcept

Constructor.

Parameters
paramsPolicy and child instances

Definition at line 122 of file root.hpp.

Member Function Documentation

◆ help() [1/2]

template<typename... Params>
string arg_router::root_t< Params >::help ( ) const
inline

Overload that writes into a string and returns it.

Returns
String holding the help output

Definition at line 278 of file root.hpp.

◆ help() [2/2]

template<typename... Params>
void arg_router::root_t< Params >::help ( [[maybe_unused] ] std::ostream &  stream) const
inline

Generates a root-level help string and writes it into stream.

Does nothing if a help node is not present.

Parameters
streamOutput stream to write into

Definition at line 239 of file root.hpp.

◆ parse() [1/4]

template<typename... Params>
template<typename Container , typename = std::enable_if_t< !std::is_same_v<std::decay_t<Container>, vector<parsing::token_type>>>>
void arg_router::root_t< Params >::parse ( const Container &  c) const
inline

Parse all std::string_view convertible elements in c.

The first element is not expected to be the executable name.

Note
This does not take part in overload resolution if c is a vector<parsing::token_type>
Template Parameters
Container
Parameters
cElements to parse

Definition at line 213 of file root.hpp.

◆ parse() [2/4]

template<typename... Params>
void arg_router::root_t< Params >::parse ( int  argc,
char **  argv 
) const
inline

Parse the raw command line arguments.

The first element is expected to be the executable name.

Parameters
argcNumber of arguments
argvArray of char pointers to the command line tokens
Exceptions
parse_exceptionThrown if parsing has failed

Definition at line 228 of file root.hpp.

◆ parse() [3/4]

template<typename... Params>
template<typename Iter , typename = std::enable_if_t<!std::is_same_v<std::decay_t<Iter>, int>>>
void arg_router::root_t< Params >::parse ( Iter  begin,
Iter  end 
) const
inline

Parse the std::string_view convertible elements between begin and end.

The first element is not expected to be the executable name.

Note
The strings must out live the parse process as they are not copied.
Template Parameters
IterIterator type to std::string_view convertible elements
Parameters
beginIterator to the first element
endIterator to the one-past-the-end element

Definition at line 191 of file root.hpp.

◆ parse() [4/4]

template<typename... Params>
void arg_router::root_t< Params >::parse ( vector< parsing::token_type args) const
inline

Parse the unprocessed token_types.

The first element is not expected to be the executable name.

Parameters
argsVector of tokens
Exceptions
parse_exceptionThrown if parsing has failed

Definition at line 147 of file root.hpp.


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