Evo C++ Library v0.5.1
Public Member Functions | List of all members
CommandLineT< ConsoleT >::Option Struct Referenceabstract

#include <evo/commandline.h>

Detailed Description

template<class ConsoleT = Console>
struct evo::CommandLineT< ConsoleT >::Option

Used to set additional option/argument information.

Public Member Functions

virtual ~Option ()
 Destructor. More...
 
virtual Optionaddchoice (const SubString &value)=0
 Add one or more preset choices. More...
 
template<class T >
Optionaddchoices (const T &values)
 Add one or more preset choices from string list. More...
 
virtual Optiondefault_value (const String &value)=0
 Set default value for option. More...
 
virtual Optionmaxlen (uint len)=0
 Set maximum value length, or max digits if required to be numeric. More...
 
virtual Optionmulti (bool val=true)=0
 Allow multiple values for option/argument. More...
 
virtual Optionnumeric ()=0
 Require option/argument value to be numeric. More...
 
virtual Optionrequired (bool val=true)=0
 Make this option/argument required. More...
 

Constructor & Destructor Documentation

◆ ~Option()

virtual ~Option ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ addchoice()

virtual Option& addchoice ( const SubString value)
pure virtual

Add one or more preset choices.

  • This limits the option/argument value to one of the given choices – any other value will give an error
Parameters
valueChoice values, separated by semi-colon (;)
Returns
This

◆ addchoices()

Option& addchoices ( const T &  values)
inline

Add one or more preset choices from string list.

Template Parameters
TString list type (List, SubList, etc), inferred from argument
Parameters
valuesList of string values to add as choices
Returns
This

◆ default_value()

virtual Option& default_value ( const String value)
pure virtual

Set default value for option.

  • The default value is used when this option/argument is not given
  • The default is automatically appended to option/argument usage help
    • Usage help may contain ${default} to control where the default value is shown, otherwise the default is appended to it
Returns
This

◆ maxlen()

virtual Option& maxlen ( uint  len)
pure virtual

Set maximum value length, or max digits if required to be numeric.

  • Any value that exceeds this max length will give an error
Parameters
lenMaximum value length allowed, or max digits allowed if required to be numeric
Returns
This

◆ multi()

virtual Option& multi ( bool  val = true)
pure virtual

Allow multiple values for option/argument.

  • For options, the values will accumulate when the option is repeated (instead of replace the previous value)
  • For arguments, the values will accumulate with each argument
Parameters
valWhether to allow multiple values, false for single value
Returns
This

◆ numeric()

virtual Option& numeric ( )
pure virtual

Require option/argument value to be numeric.

  • Any value that isn't numeric (digits 0-9 only) will give an error
Returns
This

◆ required()

virtual Option& required ( bool  val = true)
pure virtual

Make this option/argument required.

  • If a required option/argument is missing an error is given
Parameters
valWhether required, false to make optional
Returns
This

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