3.0.0
Freundlich's C++ toolkit
Public Types | Public Member Functions
fcppt::options::option< Label, Type > Class Template Reference

Detailed Description

template<typename Label, typename Type>
class fcppt::options::option< Label, Type >

An option parser.

An option parser matches the next command-line parameter that follows after its short name ("-o") or its long name ("--option"), for example "--output log.txt". If there is no such pair of command-line parameters, then the option will use its default value if is has one. Otherwise, it will fail. The result of an option is a record that has a single element with label Label and type Type. In case reading the value into Type fails, the parser also fails.

Template Parameters
LabelAn fcppt::record::label.
TypeThe type of the flag's value.

Public Types

typedef fcppt::options::default_value< fcppt::optional::object< Type > > optional_default_value
 
typedef fcppt::record::element< Label, Type > element_type
 
typedef fcppt::record::variadic< element_typeresult_type
 

Public Member Functions

 option (fcppt::options::optional_short_name &&short_name, fcppt::options::long_name &&long_name, optional_default_value &&default_value, fcppt::options::optional_help_text &&help_text)
 Constructs an option parser. More...
 
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

◆ element_type

template<typename Label , typename Type >
typedef fcppt::record::element< Label, Type > fcppt::options::option< Label, Type >::element_type

◆ optional_default_value

template<typename Label , typename Type >
typedef fcppt::options::default_value< fcppt::optional::object< Type > > fcppt::options::option< Label, Type >::optional_default_value

◆ result_type

template<typename Label , typename Type >
typedef fcppt::record::variadic< element_type > fcppt::options::option< Label, Type >::result_type

Constructor & Destructor Documentation

◆ option()

template<typename Label , typename Type >
fcppt::options::option< Label, Type >::option ( fcppt::options::optional_short_name &&  short_name,
fcppt::options::long_name &&  long_name,
optional_default_value &&  default_value,
fcppt::options::optional_help_text &&  help_text 
)

Constructs an option parser.

Parameters
short_nameAn optional short name ("-o") this parser will match.
long_nameThe long name ("--option") this parser will match.
default_valueAn optional default value for this parser.
help_textOptional help text for this flag.

Member Function Documentation

◆ flag_names()

template<typename Label , typename Type >
fcppt::options::flag_name_set fcppt::options::option< Label, Type >::flag_names ( ) const

◆ option_names()

template<typename Label , typename Type >
fcppt::options::option_name_set fcppt::options::option< Label, Type >::option_names ( ) const

◆ parse()

template<typename Label , typename Type >
fcppt::options::parse_result< result_type > fcppt::options::option< Label, Type >::parse ( fcppt::options::state &&  ,
fcppt::options::parse_context const &   
) const

◆ usage()

template<typename Label , typename Type >
fcppt::string fcppt::options::option< Label, Type >::usage ( ) const