args-parser 6.3.6
Loading...
Searching...
No Matches
Args::MultiArg Class Reference

MultiArg is a class that presents argument in the command line taht can be presented more than once or can have more than one value. More...

#include <multi_arg.hpp>

Inheritance diagram for Args::MultiArg:
Collaboration diagram for Args::MultiArg:

Public Member Functions

template<typename T>
 MultiArg (Char flag, T &&name, bool isWithValue=false, bool isRequired=false)
 Construct argument with flag and name.
 MultiArg (Char flag, bool isWithValue=false, bool isRequired=false)
 Construct argument only with flag, without name.
template<typename T>
 MultiArg (T &&name, bool isWithValue=false, bool isRequired=false)
 Construct argument only with name, without flag.
virtual ~MultiArg ()
ArgType type () const override
const Stringvalue () const override
MultiArgsetValue (const String &v) override
 Set value.
virtual const StringListvalues () const
size_t count () const
const StringdefaultValue () const override
MultiArgsetDefaultValue (const String &v) override
 Set default value.
const StringListdefaultValues () const
MultiArgsetDefaultValues (const StringList &v)
 Set default values.
void clear () override
 Clear state of the argument.
Public Member Functions inherited from Args::Arg
template<typename T>
 Arg (Char flag, T &&name, bool isWithValue=false, bool isRequired=false)
 Construct argument with flag and name.
 Arg (Char flag, bool isWithValue=false, bool isRequired=false)
 Construct argument only with flag, without name.
template<typename T>
 Arg (T &&name, bool isWithValue=false, bool isRequired=false)
 Construct argument only with name, without flag.
virtual ~Arg ()
String name () const override
bool isWithValue () const override
ArgsetWithValue (bool on=true)
 Set is this argument with value.
bool isRequired () const override
ArgsetRequired (bool on=true)
 Set required.
bool isDefined () const override
ArgsetDefined (bool on=true)
 Set defined.
const Stringflag () const override
ArgsetFlag (Char f)
 Set flag.
const StringargumentName () const override
ArgsetArgumentName (const String &name)
 Set argument name.
const StringvalueSpecifier () const override
ArgsetValueSpecifier (const String &vs)
 Set value specifier.
const Stringdescription () const override
ArgsetDescription (const String &desc)
 Set description.
const StringlongDescription () const override
ArgsetLongDescription (const String &desc)
 Set long description.
bool isMisspelledName (const String &name, StringList &possibleNames) const override
Public Member Functions inherited from Args::ArgIface
 ArgIface ()
virtual ~ArgIface ()
CmdLinecmdLine () const

Protected Member Functions

void process (Context &context) override
 Process argument's staff, for example take values from context.
Protected Member Functions inherited from Args::Arg
ArgIfacefindArgument (const String &name) override
void checkCorrectnessBeforeParsing (StringList &flags, StringList &names) const override
 Check correctness of the argument before parsing.
void checkCorrectnessAfterParsing () const override
 Check correctness of the argument after parsing.
Protected Member Functions inherited from Args::ArgIface
virtual void setCmdLine (CmdLine *cmdLine)
 Set command line parser.

Detailed Description

MultiArg is a class that presents argument in the command line taht can be presented more than once or can have more than one value.

Definition at line 33 of file multi_arg.hpp.

Constructor & Destructor Documentation

◆ MultiArg() [1/3]

template<typename T>
Args::MultiArg::MultiArg ( Char flag,
T && name,
bool isWithValue = false,
bool isRequired = false )

Construct argument with flag and name.

Parameters
flagFlag for this argument.
nameName for this argument.
isWithValueIs this argument with value?
isRequiredIs this argument required?

Definition at line 155 of file multi_arg.hpp.

◆ MultiArg() [2/3]

Args::MultiArg::MultiArg ( Char flag,
bool isWithValue = false,
bool isRequired = false )
inlineexplicit

Construct argument only with flag, without name.

Parameters
flagFlag for this argument.
isWithValueIs this argument with value?
isRequiredIs this argument required?

Definition at line 167 of file multi_arg.hpp.

◆ MultiArg() [3/3]

template<typename T>
Args::MultiArg::MultiArg ( T && name,
bool isWithValue = false,
bool isRequired = false )
explicit

Construct argument only with name, without flag.

Parameters
nameName for this argument.
isWithValueIs this argument with value?
isRequiredIs this argument required?

Definition at line 178 of file multi_arg.hpp.

◆ ~MultiArg()

Args::MultiArg::~MultiArg ( )
inlinevirtual

Definition at line 188 of file multi_arg.hpp.

Member Function Documentation

◆ clear()

void Args::MultiArg::clear ( )
inlineoverridevirtual

Clear state of the argument.

Reimplemented from Args::Arg.

Definition at line 122 of file multi_arg.hpp.

◆ count()

size_t Args::MultiArg::count ( ) const
inline
Returns
Count of times that this argument was presented in the command line if argument without value or count of values if argument is with values.

Definition at line 218 of file multi_arg.hpp.

◆ defaultValue()

const String & Args::MultiArg::defaultValue ( ) const
inlineoverridevirtual
Returns
Default value.

Reimplemented from Args::Arg.

Definition at line 91 of file multi_arg.hpp.

◆ defaultValues()

const StringList & Args::MultiArg::defaultValues ( ) const
inline
Returns
Default values.

Definition at line 109 of file multi_arg.hpp.

◆ process()

void Args::MultiArg::process ( Context & context)
inlineoverrideprotectedvirtual

Process argument's staff, for example take values from context.

This method invokes exactly at that moment when parser has found this argument.

Parameters
contextContext of the command line.

Reimplemented from Args::Arg.

Definition at line 229 of file multi_arg.hpp.

◆ setDefaultValue()

MultiArg & Args::MultiArg::setDefaultValue ( const String & v)
inlineoverridevirtual

Set default value.

Note
Value will be pushed back to the list of default values.

Reimplemented from Args::Arg.

Definition at line 102 of file multi_arg.hpp.

◆ setDefaultValues()

MultiArg & Args::MultiArg::setDefaultValues ( const StringList & v)
inline

Set default values.

Definition at line 115 of file multi_arg.hpp.

◆ setValue()

MultiArg & Args::MultiArg::setValue ( const String & v)
inlineoverridevirtual

Set value.

Note
Value will be pushed back to the list of values.

Reimplemented from Args::Arg.

Definition at line 203 of file multi_arg.hpp.

◆ type()

ArgType Args::MultiArg::type ( ) const
inlineoverridevirtual
Returns
Type of the argument.

Reimplemented from Args::Arg.

Definition at line 70 of file multi_arg.hpp.

◆ value()

const String & Args::MultiArg::value ( ) const
inlineoverridevirtual
Returns
First value of this argument.

Reimplemented from Args::Arg.

Definition at line 192 of file multi_arg.hpp.

◆ values()

const StringList & Args::MultiArg::values ( ) const
inlinevirtual
Returns
All values for this argument.

Definition at line 209 of file multi_arg.hpp.


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