2.10.0
Freundlich's C++ toolkit
Public Types | Public Member Functions
fcppt::options::commands< OptionsParser, SubCommands > Class Template Reference

Detailed Description

template<typename OptionsParser, typename... SubCommands>
class fcppt::options::commands< OptionsParser, SubCommands >

A parser for multiple sub commands.

A commands parser parses multiple sub commands. Each sub command consists of a parser and a name, i.e. (name_1, parser_1), ..., (name_n, parser_n). The parser first searches for the first argument, ignoring all option names from OptionsParser. If none is found, the parser fails. Otherwise, the first argument is arg, which is then compared to name_1, ..., name_n. If none of these is equal to arg, the parser fails. Otherwise, let arg = name_i, then the OptionsParser is used to parse everything up to the first argument, and parser_i is used to parse everything after.

Warning
Be careful not to include anything other than options or flags in OptionsParser, because otherwise this may lead to very confusing results.
Template Parameters
OptionsParserA parser that should only parse options.

Public Types

typedef fcppt::variant::variadic< fcppt::options::result_of< SubCommands >... > variant_result
 
typedef fcppt::record::variadic< fcppt::record::element< fcppt::options::options_label, fcppt::options::result_of< OptionsParser > >, fcppt::record::element< fcppt::options::sub_command_label, variant_result > > result_type
 

Public Member Functions

template<typename OptionsParserArg , typename... SubCommandsArgs>
 commands (OptionsParserArg &&, SubCommandsArgs &&...)
 Constructs a commands parser. More...
 
 commands (commands const &)
 
 commands (commands &&)
 
commandsoperator= (commands const &)
 
commandsoperator= (commands &&)
 
 ~commands ()
 
fcppt::options::parse_result< result_typeparse (fcppt::options::state &&, fcppt::options::parse_context const &) const
 
fcppt::options::flag_name_set flag_names () const
 
fcppt::options::option_name_set option_names () const
 
fcppt::string usage () const
 

Member Typedef Documentation

◆ result_type

template<typename OptionsParser , typename... SubCommands>
typedef fcppt::record::variadic< fcppt::record::element< fcppt::options::options_label, fcppt::options::result_of< OptionsParser > >, fcppt::record::element< fcppt::options::sub_command_label, variant_result > > fcppt::options::commands< OptionsParser, SubCommands >::result_type

◆ variant_result

template<typename OptionsParser , typename... SubCommands>
typedef fcppt::variant::variadic< fcppt::options::result_of< SubCommands >... > fcppt::options::commands< OptionsParser, SubCommands >::variant_result

Constructor & Destructor Documentation

◆ commands() [1/3]

template<typename OptionsParser , typename... SubCommands>
template<typename OptionsParserArg , typename... SubCommandsArgs>
fcppt::options::commands< OptionsParser, SubCommands >::commands ( OptionsParserArg &&  ,
SubCommandsArgs &&  ... 
)
explicit

Constructs a commands parser.

Template Parameters
OptionsParserArgA cv-ref to OptionsParser
SubCommandsArgsCv-refs to SubCommands

◆ commands() [2/3]

template<typename OptionsParser , typename... SubCommands>
fcppt::options::commands< OptionsParser, SubCommands >::commands ( commands< OptionsParser, SubCommands > const &  )

◆ commands() [3/3]

template<typename OptionsParser , typename... SubCommands>
fcppt::options::commands< OptionsParser, SubCommands >::commands ( commands< OptionsParser, SubCommands > &&  )

◆ ~commands()

template<typename OptionsParser , typename... SubCommands>
fcppt::options::commands< OptionsParser, SubCommands >::~commands ( )

Member Function Documentation

◆ flag_names()

template<typename OptionsParser , typename... SubCommands>
fcppt::options::flag_name_set fcppt::options::commands< OptionsParser, SubCommands >::flag_names ( ) const

◆ operator=() [1/2]

template<typename OptionsParser , typename... SubCommands>
commands& fcppt::options::commands< OptionsParser, SubCommands >::operator= ( commands< OptionsParser, SubCommands > const &  )

◆ operator=() [2/2]

template<typename OptionsParser , typename... SubCommands>
commands& fcppt::options::commands< OptionsParser, SubCommands >::operator= ( commands< OptionsParser, SubCommands > &&  )

◆ option_names()

template<typename OptionsParser , typename... SubCommands>
fcppt::options::option_name_set fcppt::options::commands< OptionsParser, SubCommands >::option_names ( ) const

◆ parse()

template<typename OptionsParser , typename... SubCommands>
fcppt::options::parse_result< result_type > fcppt::options::commands< OptionsParser, SubCommands >::parse ( fcppt::options::state &&  ,
fcppt::options::parse_context const &   
) const

◆ usage()

template<typename OptionsParser , typename... SubCommands>
fcppt::string fcppt::options::commands< OptionsParser, SubCommands >::usage ( ) const