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

Detailed Description

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

A flag parser.

A flag parser matches the next command-line parameter that is equal to its short name ("-f") or its long name ("--flag"). If there is such a command-line parameter, then the flag is on, otherwise it is off. The result of a flag is a record that has a single element with label Label and type Type. In case the flag is off, the result will be the flag's inactive value, otherwise it will be that flag's active value.

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

Public Types

typedef fcppt::options::active_value< Type > active_value
 
typedef fcppt::options::inactive_value< Type > inactive_value
 
typedef fcppt::record::element< Label, Type > element_type
 
typedef fcppt::record::variadic< element_typeresult_type
 

Public Member Functions

 flag (fcppt::options::optional_short_name &&short_name, fcppt::options::long_name &&long_name, active_value &&active, inactive_value &&inactive, fcppt::options::optional_help_text &&help_text)
 Constructs a flag 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
 
fcppt::options::optional_short_name const & short_name () const
 
fcppt::options::long_name const & long_name () const
 

Member Typedef Documentation

◆ active_value

template<typename Label, typename Type>
typedef fcppt::options::active_value< Type > fcppt::options::flag< Label, Type >::active_value

◆ element_type

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

◆ inactive_value

template<typename Label, typename Type>
typedef fcppt::options::inactive_value< Type > fcppt::options::flag< Label, Type >::inactive_value

◆ result_type

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

Constructor & Destructor Documentation

◆ flag()

template<typename Label, typename Type>
fcppt::options::flag< Label, Type >::flag ( fcppt::options::optional_short_name &&  short_name,
fcppt::options::long_name &&  long_name,
active_value &&  active,
inactive_value &&  inactive,
fcppt::options::optional_help_text &&  help_text 
)

Constructs a flag parser.

Note
The active and the inactive value must be different.
Parameters
short_nameAn optional short name ("-f") this parser will match.
long_nameThe long name ("--flag") this parser will match.
activeThe value of the parser in case its flag is encountered.
inactiveThe value of the parser in case its flag is not encountered.
help_textOptional help text for this flag.

Member Function Documentation

◆ flag_names()

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

◆ long_name()

template<typename Label, typename Type>
fcppt::options::long_name const& fcppt::options::flag< Label, Type >::long_name ( ) const

◆ option_names()

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

◆ parse()

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

◆ short_name()

template<typename Label, typename Type>
fcppt::options::optional_short_name const& fcppt::options::flag< Label, Type >::short_name ( ) const

◆ usage()

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