4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt::options::commands< OptionsParser, SubParsers > Class Template Reference

Detailed Description

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

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

using variant_result = fcppt::variant::object<fcppt::options::result_of<SubCommands>...>
 
using result_type
 

Public Member Functions

template<typename OptionsParserArg , typename... SubCommandsArgs>
requires (std::conjunction_v< std::is_same<OptionsParser, std::remove_cvref_t<OptionsParserArg>>, std::is_same<SubCommands, std::remove_cvref_t<SubCommandsArgs>>...>)
 commands (OptionsParserArg &&, SubCommandsArgs &&...)
 Constructs a commands parser.
 
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::options::usage usage () const
 

Member Typedef Documentation

◆ result_type

template<typename OptionsParser , typename... SubParsers>
using fcppt::options::commands< OptionsParser, SubParsers >::result_type
Initial value:
fcppt::record::
element<fcppt::options::options_label, fcppt::options::result_of<OptionsParser>>,

◆ variant_result

template<typename OptionsParser , typename... SubParsers>
using fcppt::options::commands< OptionsParser, SubParsers >::variant_result = fcppt::variant::object<fcppt::options::result_of<SubCommands>...>

Constructor & Destructor Documentation

◆ commands()

template<typename OptionsParser , typename... SubParsers>
template<typename OptionsParserArg , typename... SubCommandsArgs>
requires (std::conjunction_v< std::is_same<OptionsParser, std::remove_cvref_t<OptionsParserArg>>, std::is_same<SubCommands, std::remove_cvref_t<SubCommandsArgs>>...>)
fcppt::options::commands< OptionsParser, SubParsers >::commands ( OptionsParserArg && ,
SubCommandsArgs && ... )
explicit

Constructs a commands parser.

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

Member Function Documentation

◆ flag_names()

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

◆ option_names()

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

◆ parse()

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

◆ usage()

template<typename OptionsParser , typename... SubParsers>
fcppt::options::usage fcppt::options::commands< OptionsParser, SubParsers >::usage ( ) const
nodiscard