3.8.0
Freundlich's C++ toolkit
Classes | Typedefs | Functions
fcppt::options Namespace Reference

Library for command-line options. More...

Classes

struct  active_value_tag
 The tag of strong typedefs for active values. More...
 
class  argument
 An argument parser. More...
 
class  base
 The base class for parsers with a given result type. More...
 
class  commands
 A parser for multiple sub commands. More...
 
struct  default_value_tag
 The tag of strong typedefs for default values. More...
 
class  duplicate_names
 
class  exception
 
class  flag
 A flag parser. More...
 
struct  inactive_value_tag
 The tag of strong typedefs for inactive values. More...
 
class  many
 A parser for zero or more elements. More...
 
class  missing_error
 A string type representing a missing error. More...
 
class  option
 An option parser. More...
 
class  option_name
 An option name that may be for a short or long option. More...
 
class  optional
 An optional parser. More...
 
class  parse_context
 
struct  pretty_type_impl< Enum, std::enable_if_t< std::is_enum_v< Enum > > >
 Specialization for enums that uses fcppt::enum_::names.
 
struct  pretty_type_impl
 
class  product
 A product of two parsers. More...
 
class  state
 A parse state. More...
 
class  state_with_value
 A parse state together with a value. More...
 
class  sub_command
 A sub command consists of a command name and a parser. More...
 
class  sum
 A sum of two parsers. More...
 
class  switch_
 A switch parser. More...
 
class  unit
 A parser that succeeds when provided with no arguments. More...
 
class  unit_switch
 A required switch. More...
 

Typedefs

template<typename Type >
using active_value = fcppt::strong_typedef< Type, fcppt::options::active_value_tag >
 A strong typedef used as a parser's active value. More...
 
template<typename Result >
using base_unique_ptr = fcppt::unique_ptr< fcppt::options::base< Result > >
 A unique pointer for fcppt::options::base. More...
 
template<typename Type >
using default_value = fcppt::strong_typedef< Type, fcppt::options::default_value_tag >
 A strong typedef used as a parser's default value. More...
 
template<typename Parser >
using deref_type = fcppt::type_traits::remove_cv_ref_t< fcppt::deref_type< Parser > >
 The dereferenced type of a parser. More...
 
using error = fcppt::strong_typedef< fcppt::string,_ >
 The error type retuned. More...
 
using flag_name = fcppt::strong_typedef< fcppt::string,_ >
 
using flag_name_set = std::set< fcppt::options::flag_name >
 The set of flag names. More...
 
template<typename Result >
using help_result = fcppt::variant::object< fcppt::options::result< Result >, fcppt::options::help_text >
 The result of invoking a regular parser and a help parser. More...
 
using help_switch = fcppt::options::unit_switch< fcppt::options::detail::help_label >
 The type of a help parser. More...
 
using help_text = fcppt::strong_typedef< fcppt::string,_ >
 A string type representing a help text. More...
 
template<typename Type >
using inactive_value = fcppt::strong_typedef< Type, fcppt::options::inactive_value_tag >
 A strong typedef used as a parser's inactive value. More...
 
using indentation = fcppt::strong_typedef< unsigned,_ >
 An indentation level. More...
 
template<typename Type >
using left = fcppt::strong_typedef< Type, fcppt::options::detail::left_tag >
 The left result type of a sum parser. More...
 
using long_name = fcppt::strong_typedef< fcppt::string,_ >
 A string type representing a long name. More...
 
using option_name_set = std::set< fcppt::options::option_name >
 The set of option names. More...
 
using optional_help_text = fcppt::optional::object< fcppt::options::help_text >
 An optional help text. More...
 
using optional_short_name = fcppt::optional::object< fcppt::options::short_name >
 An optional short name. More...
 
using other_error = fcppt::strong_typedef< fcppt::string,_ >
 A string type representing other errors. More...
 
using parse_error = fcppt::variant::object< fcppt::options::missing_error, fcppt::options::other_error >
 The error type returned by parsers. More...
 
template<typename T >
using parse_result = fcppt::either::object< fcppt::options::parse_error, fcppt::options::state_with_value< T > >
 The result of a parser. More...
 
template<typename T >
using result = fcppt::either::object< fcppt::options::error, T >
 The result of a parse operation. More...
 
template<typename Parser >
using result_of = typename fcppt::options::deref_type< Parser >::result_type
 The result of a parser type. More...
 
template<typename Type >
using right = fcppt::strong_typedef< Type, fcppt::options::detail::right_tag >
 The right result type of a sum parser. More...
 
using short_name = fcppt::strong_typedef< fcppt::string,_ >
 A string type representing a short name. More...
 

Functions

template<typename... Parsers>
auto apply (Parsers &&..._parsers)
 Combines two or more parsers. More...
 
FCPPT_OPTIONS_DETAIL_SYMBOL fcppt::options::help_switch default_help_switch ()
 The default help switch. More...
 
template<typename Parser >
decltype(auto) deref (Parser const &_parser)
 Dereferences a parser. More...
 
FCPPT_OPTIONS_DETAIL_SYMBOL fcppt::string indent (fcppt::string &&)
 Indents every line of a string once. More...
 
FCPPT_OPTIONS_DETAIL_SYMBOL bool is_option (fcppt::string_view const &)
 Checks if a string is an option. More...
 
template<typename Type >
fcppt::options::active_value< fcppt::type_traits::remove_cv_ref_t< Type > > make_active_value (Type &&_value)
 Creates an active value. More...
 
template<typename Result , typename Parser >
fcppt::options::base_unique_ptr< Result > make_base (Parser &&_parser)
 Creates an fcppt::options::base. More...
 
template<typename OptionsParser , typename... SubCommands>
fcppt::options::commands< fcppt::type_traits::remove_cv_ref_t< OptionsParser >, fcppt::type_traits::remove_cv_ref_t< SubCommands >... > make_commands (OptionsParser &&_options_parser, SubCommands &&..._sub_commands)
 Makes a commands parser. More...
 
template<typename Type >
fcppt::options::default_value< fcppt::type_traits::remove_cv_ref_t< Type > > make_default_value (Type &&_value)
 Creates a default value. More...
 
template<typename Type >
fcppt::options::inactive_value< fcppt::type_traits::remove_cv_ref_t< Type > > make_inactive_value (Type &&_value)
 Creates an inactive value. More...
 
template<typename Type >
fcppt::options::left< fcppt::type_traits::remove_cv_ref_t< Type > > make_left (Type &&_value)
 Creates an fcppt::options::left. More...
 
template<typename Parser >
fcppt::options::many< fcppt::type_traits::remove_cv_ref_t< Parser > > make_many (Parser &&_parser)
 Turns a parser into a many parser. More...
 
template<typename Parser >
fcppt::options::optional< fcppt::type_traits::remove_cv_ref_t< Parser > > make_optional (Parser &&_parser)
 Turns a parser into an optional parser. More...
 
template<typename Type >
fcppt::options::right< fcppt::type_traits::remove_cv_ref_t< Type > > make_right (Type &&_value)
 Creates an fcppt::options::right. More...
 
template<typename Tag , typename Parser >
fcppt::options::sub_command< Tag, fcppt::type_traits::remove_cv_ref_t< Parser > > make_sub_command (fcppt::string &&_name, Parser &&_parser, fcppt::options::optional_help_text &&_help_text)
 Makes a sub command. More...
 
template<typename Type >
fcppt::options::result< fcppt::type_traits::remove_cv_ref_t< Type > > make_success (Type &&_value)
 Creates a success value. More...
 
template<typename Label , typename Left , typename Right >
fcppt::options::sum< Label, fcppt::type_traits::remove_cv_ref_t< Left >, fcppt::type_traits::remove_cv_ref_t< Right > > make_sum (Left &&_left, Right &&_right)
 Creates the sum of two parsers. More...
 
template<typename Type >
fcppt::options::default_value< fcppt::optional::object< Type > > no_default_value ()
 Creates an empty default value. More...
 
FCPPT_OPTIONS_DETAIL_SYMBOL bool operator== (fcppt::options::option_name const &, fcppt::options::option_name const &)
 
FCPPT_OPTIONS_DETAIL_SYMBOL bool operator< (fcppt::options::option_name const &, fcppt::options::option_name const &)
 
 FCPPT_RECORD_MAKE_LABEL (options_label)
 The options label name in fcppt::options::commands. More...
 
template<typename Parser >
fcppt::options::result< fcppt::options::result_of< Parser > > parse (Parser const &_parser, fcppt::args_vector const &_args)
 Parse a command-line. More...
 
template<typename Parser >
fcppt::options::help_result< fcppt::options::result_of< Parser > > parse_help (fcppt::options::help_switch const &_help, Parser const &_parser, fcppt::args_vector const &_args)
 Parse a command-line with a help parser. More...
 
template<typename Type >
fcppt::string pretty_type ()
 Returns a pretty type used for help texts. More...
 
 FCPPT_RECORD_MAKE_LABEL (sub_command_label)
 The sub-command label name in fcppt::options::commands. More...
 

Detailed Description

Library for command-line options.

Typedef Documentation

◆ flag_name

◆ help_result

The result of invoking a regular parser and a help parser.

A help result is either a regular result or a help text.

Function Documentation

◆ operator<()

FCPPT_OPTIONS_DETAIL_SYMBOL bool fcppt::options::operator< ( fcppt::options::option_name const &  ,
fcppt::options::option_name const &   
)

◆ operator==()

FCPPT_OPTIONS_DETAIL_SYMBOL bool fcppt::options::operator== ( fcppt::options::option_name const &  ,
fcppt::options::option_name const &   
)