clipp::parameter Class Reference

command line parameter that can match one or many arguments. More...

#include <clipp.h>

Inheritance diagram for clipp::parameter:
Collaboration diagram for clipp::parameter:

Public Member Functions

 parameter ()
 makes default parameter, that will match nothing More...
 
template<class... Strings>
 parameter (arg_string str, Strings &&... strs)
 makes "flag" parameter More...
 
 parameter (const arg_list &flaglist)
 makes "flag" parameter from range of strings More...
 
 parameter (match_predicate filter)
 makes "value" parameter with custom match predicate (= yes/no matcher) More...
 
 parameter (match_function filter)
 makes "value" parameter with custom match function (= partial matcher) More...
 
bool required () const noexcept
 returns if a parameter is required More...
 
parameterrequired (bool yes) noexcept
 determines if a parameter is required More...
 
const doc_stringlabel () const
 returns parameter label; will be used for documentation, if flags are empty More...
 
parameterlabel (const doc_string &lbl)
 sets parameter label; will be used for documentation, if flags are empty More...
 
parameterlabel (doc_string &&lbl)
 sets parameter label; will be used for documentation, if flags are empty More...
 
subrange match (const arg_string &arg) const
 returns either longest matching prefix of 'arg' in any of the flags or the result of the custom match operation More...
 
const arg_listflags () const noexcept
 access range of flag strings More...
 
const match_functionmatcher () const noexcept
 access custom match operation More...
 
- Public Member Functions inherited from clipp::detail::token< parameter >
const doc_stringdoc () const noexcept
 returns documentation string More...
 
parameterdoc (const doc_string &txt)
 sets documentations string More...
 
parameterdoc (doc_string &&txt)
 sets documentations string More...
 
bool repeatable () const noexcept
 returns if a group/parameter is repeatable More...
 
parameterrepeatable (bool yes) noexcept
 sets repeatability of group/parameter More...
 
bool blocking () const noexcept
 returns if a group/parameter is blocking/positional More...
 
parameterblocking (bool yes) noexcept
 determines, if a group/parameter is blocking/positional More...
 
- Public Member Functions inherited from clipp::detail::action_provider< parameter >
parametercall (arg_action a)
 adds an action that has an operator() that is callable with a 'const char*' argument More...
 
parametercall (simple_action a)
 adds an action that has an operator()() More...
 
parameteroperator() (arg_action a)
 adds an action that has an operator() that is callable with a 'const char*' argument More...
 
parameteroperator() (simple_action a)
 adds an action that has an operator()() More...
 
parameterset (Target &t)
 adds an action that will set the value of 't' from a 'const char*' arg More...
 
parameterset (Target &t, Value &&v)
 adds an action that will set the value of 't' to 'v' More...
 
parameterif_repeated (simple_action a)
 adds an action that will be called if a parameter matches an argument for the 2nd, 3rd, 4th, ... More...
 
parameterif_repeated (index_action a)
 adds an action that will be called with the argument's index if a parameter matches an argument for the 2nd, 3rd, 4th, ... More...
 
parameterif_missing (simple_action a)
 adds an action that will be called if a required parameter is missing More...
 
parameterif_missing (index_action a)
 adds an action that will be called if a required parameter is missing; the action will get called with the index of the command line argument where the missing event occured first More...
 
parameterif_blocked (simple_action a)
 adds an action that will be called if a parameter was matched, but was unreachable in the current scope More...
 
parameterif_blocked (index_action a)
 adds an action that will be called if a parameter was matched, but was unreachable in the current scope; the action will be called with the index of the command line argument where the problem occured More...
 
parameterif_conflicted (simple_action a)
 adds an action that will be called if a parameter match was in conflict with a different alternative parameter More...
 
parameterif_conflicted (index_action a)
 adds an action that will be called if a parameter match was in conflict with a different alternative paramete; the action will be called with the index of the command line argument where the problem occuredr More...
 
parametertarget (T &&t, Ts &&... ts)
 adds targets = either objects whose values should be set by command line arguments or actions that should be called in case of a match More...
 
parametertarget (T &&t)
 adds action that should be called in case of a match More...
 
parametertarget (T &t)
 adds object whose value should be set by command line arguments More...
 
parametertarget ()
 
void execute_actions (const arg_string &arg) const
 executes all argument actions More...
 
void notify_repeated (arg_index idx) const
 executes repeat actions More...
 
void notify_missing (arg_index idx) const
 executes missing error actions More...
 
void notify_blocked (arg_index idx) const
 executes blocked error actions More...
 
void notify_conflict (arg_index idx) const
 executes conflict error actions More...
 

Friends

parameterwith_prefix (const arg_string &prefix, parameter &p)
 prepend prefix to each flag More...
 
parameterwith_prefixes_short_long (const arg_string &shortpfx, const arg_string &longpfx, parameter &p)
 prepend prefix to each flag More...
 

Additional Inherited Members

- Public Types inherited from clipp::detail::token< parameter >
using doc_string = clipp::doc_string
 

Detailed Description

command line parameter that can match one or many arguments.

Definition at line 1828 of file clipp.h.

Constructor & Destructor Documentation

◆ parameter() [1/5]

clipp::parameter::parameter ( )
inline

makes default parameter, that will match nothing

Definition at line 1848 of file clipp.h.

◆ parameter() [2/5]

template<class... Strings>
clipp::parameter::parameter ( arg_string  str,
Strings &&...  strs 
)
inlineexplicit

makes "flag" parameter

Definition at line 1857 of file clipp.h.

◆ parameter() [3/5]

clipp::parameter::parameter ( const arg_list flaglist)
inlineexplicit

makes "flag" parameter from range of strings

Definition at line 1867 of file clipp.h.

◆ parameter() [4/5]

clipp::parameter::parameter ( match_predicate  filter)
inlineexplicit

makes "value" parameter with custom match predicate (= yes/no matcher)

Definition at line 1880 of file clipp.h.

◆ parameter() [5/5]

clipp::parameter::parameter ( match_function  filter)
inlineexplicit

makes "value" parameter with custom match function (= partial matcher)

Definition at line 1890 of file clipp.h.

Member Function Documentation

◆ flags()

const arg_list& clipp::parameter::flags ( ) const
inlinenoexcept

access range of flag strings

Definition at line 1964 of file clipp.h.

◆ label() [1/3]

const doc_string& clipp::parameter::label ( ) const
inline

returns parameter label; will be used for documentation, if flags are empty

Definition at line 1917 of file clipp.h.

◆ label() [2/3]

parameter& clipp::parameter::label ( const doc_string lbl)
inline

sets parameter label; will be used for documentation, if flags are empty

Definition at line 1925 of file clipp.h.

◆ label() [3/3]

parameter& clipp::parameter::label ( doc_string &&  lbl)
inline

sets parameter label; will be used for documentation, if flags are empty

Definition at line 1934 of file clipp.h.

◆ match()

subrange clipp::parameter::match ( const arg_string arg) const
inline

returns either longest matching prefix of 'arg' in any of the flags or the result of the custom match operation

Definition at line 1945 of file clipp.h.

◆ matcher()

const match_function& clipp::parameter::matcher ( ) const
inlinenoexcept

access custom match operation

Definition at line 1970 of file clipp.h.

◆ required() [1/2]

bool clipp::parameter::required ( ) const
inlinenoexcept

returns if a parameter is required

Definition at line 1900 of file clipp.h.

◆ required() [2/2]

parameter& clipp::parameter::required ( bool  yes)
inlinenoexcept

determines if a parameter is required

Definition at line 1906 of file clipp.h.

Friends And Related Function Documentation

◆ with_prefix

parameter& with_prefix ( const arg_string prefix,
parameter p 
)
friend

prepend prefix to each flag

Definition at line 1978 of file clipp.h.

◆ with_prefixes_short_long

parameter& with_prefixes_short_long ( const arg_string shortpfx,
const arg_string longpfx,
parameter p 
)
friend

prepend prefix to each flag

Definition at line 1992 of file clipp.h.


The documentation for this class was generated from the following file: