args-parser 6.3.3
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
 
void setValue (const String &v) override
 Set value.
 
virtual const StringListvalues () const
 
size_t count () const
 
const StringdefaultValue () const override
 
void setDefaultValue (const String &v) override
 
const StringListdefaultValues () const
 
void setDefaultValues (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
 
void setWithValue (bool on=true)
 Set is this argument with value.
 
bool isRequired () const override
 
void setRequired (bool on=true)
 Set required.
 
bool isDefined () const override
 
void setDefined (bool on=true)
 Set defined.
 
const Stringflag () const override
 
void setFlag (Char f)
 Set flag.
 
const StringargumentName () const override
 
void setArgumentName (const String &name)
 Set argument name.
 
const StringvalueSpecifier () const override
 
void setValueSpecifier (const String &vs)
 Set value specifier.
 
const Stringdescription () const override
 
void setDescription (const String &desc)
 Set description.
 
const StringlongDescription () const override
 
void setLongDescription (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 57 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 178 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 186 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 194 of file multi_arg.hpp.

◆ ~MultiArg()

Args::MultiArg::~MultiArg ( )
inlinevirtual

Definition at line 202 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 144 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 233 of file multi_arg.hpp.

◆ defaultValue()

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

Reimplemented from Args::Arg.

Definition at line 116 of file multi_arg.hpp.

◆ defaultValues()

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

Definition at line 132 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 244 of file multi_arg.hpp.

◆ setDefaultValue()

void 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 126 of file multi_arg.hpp.

◆ setDefaultValues()

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

Set default values.

Definition at line 138 of file multi_arg.hpp.

◆ setValue()

void 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 218 of file multi_arg.hpp.

◆ type()

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

Reimplemented from Args::Arg.

Definition at line 95 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 207 of file multi_arg.hpp.

◆ values()

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

Definition at line 224 of file multi_arg.hpp.


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