4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
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

using active_value = fcppt::options::active_value<Type>
 
using inactive_value = fcppt::options::inactive_value<Type>
 
using element_type = fcppt::record::element<Label, Type>
 
using result_type = fcppt::record::object<element_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.
 
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
 
fcppt::options::optional_short_name const & short_name () const
 
fcppt::options::long_name const & long_name () const
 
fcppt::options::optional_help_text const & help_text () const
 

Member Typedef Documentation

◆ active_value

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

◆ element_type

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

◆ inactive_value

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

◆ result_type

template<typename Label , typename Type >
using fcppt::options::flag< Label, Type >::result_type = fcppt::record::object<element_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
nodiscard

◆ help_text()

template<typename Label , typename Type >
fcppt::options::optional_help_text const & fcppt::options::flag< Label, Type >::help_text ( ) const
nodiscard

◆ long_name()

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

◆ option_names()

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

◆ 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
nodiscard

◆ short_name()

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

◆ usage()

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