iRoCS Toolbox  1.1.0
Public Types | Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
CmdArgTypeFixedVector< T > Class Template Reference

The CmdArgTypeFixedVector<T> class is a CmdArg that takes a fixed size list of values of type T. More...

#include <CmdArgs.hh>

Inheritance diagram for CmdArgTypeFixedVector< T >:
Collaboration diagram for CmdArgTypeFixedVector< T >:

Public Types

enum  CmdLineFlags {
  GIVEN = 0x01, VALGIVEN = 0x02, OPTION = 0x04, KEYWORD = 0x08,
  POSITIONAL = 0x10, VALSEP = 0x20, ALLFLAGS = 0x3F
}
 Flags that say how the argument was specied on the command-line. More...
 
typedef CmdArgTypeFixedVector< T >::const_iterator const_iterator
 
enum  Syntax {
  isOPT = 0x000, isREQ = 0x001, isVALOPT = 0x002, isVALREQ = 0x004,
  isVALSEP = 0x008, isVALSTICKY = 0x010, isLIST = 0x020, isPOS = 0x040,
  isHIDDEN = 0x080, isFIXEDLIST = 0x100, isVALTAKEN = (isVALREQ | isVALOPT), isOPTVALOPT = (isOPT | isVALOPT),
  isOPTVALREQ = (isOPT | isVALREQ), isPOSVALOPT = (isPOS | isVALOPT), isPOSVALREQ = (isPOS | isVALREQ)
}
 Flags that define the argument syntax. More...
 

Public Member Functions

 CmdArgTypeFixedVector (char aShortName, const std::string aLongName, const std::string aValueName, const std::string aDescription, unsigned int aFixedSize, Syntax aSyntax=Syntax(isOPTVALREQ|isFIXEDLIST))
 Constructor. More...
 
 CmdArgTypeFixedVector (const std::string aValueName, const std::string aDescription, unsigned int aFixedSize, Syntax aSyntax=Syntax(isPOSVALREQ|isFIXEDLIST))
 Constructor. More...
 
virtual ~CmdArgTypeFixedVector ()
 Destructor. More...
 
void clearErrorMsg ()
 Clears the error message. More...
 
virtual void clearFixedList ()
 Clear all values. More...
 
const std::string description () const
 Get the description (help-message) of this argument. More...
 
const std::string errorMsg () const
 Returns error message of last parsing. More...
 
virtual unsigned int fixedSize () const
 Return the fixed size of the vector. More...
 
CmdArg::CmdLineFlags flags () const
 Retrieve the flags that say how this argument was specified. More...
 
virtual std::string getDefaultValueString () const
 Returns the default value as a string. More...
 
bool given () const
 Returns true if the argument was parsed in any of the parsing runs. More...
 
virtual bool hasDefaultValue () const
 Returns true if a default value was specified. More...
 
bool hasFlag (CmdArg::CmdLineFlags f) const
 Returns true if the argument's flags contain f. More...
 
bool hasSyntax (CmdArg::Syntax s) const
 Returns true if the argument's syntax flags contain s. More...
 
const std::string longName () const
 Returns the argument's long name. More...
 
bool modified () const
 Returns true if the argument was parsed at the last parsing run. More...
 
void modified (bool m)
 Sets the modified flag. More...
 
virtual bool parse (const char *arg, const char *&endptr, CmdLine &)
 Parse value string and append it to the vector. More...
 
virtual unsigned int remainingSize () const
 Return the number of remaining values. More...
 
unsigned int sequence () const
 Get the sequence number corresponding to the last time this argument was matched on the command-line. More...
 
virtual void setDefaultValue (const std::vector< T > &v)
 Specify default value. More...
 
void setErrorMsg (const std::string &msg)
 Sets the error message. More...
 
char shortName () const
 Returns the argument's short name. More...
 
const std::string synopsis (bool displayShort=true, bool displayLong=true) const
 Generates and returns the arguments synopsis. More...
 
CmdArg::Syntax syntax () const
 Retrieve the syntax flags for this argument. More...
 
virtual std::string valueAsString () const
 Return the value as a std::string. More...
 
const std::string valueName () const
 Returns the argument's value name. More...
 
virtual std::string valueTypeAsString () const
 Return the value type as a std::string. More...
 

Data Fields

elements
 STL member. More...
 

Protected Member Functions

void adjustSyntax ()
 Adjust and correct specified syntax flags. More...
 
void clearFlags (CmdArg::CmdLineFlags f=ALLFLAGS)
 Clears the specified flags. More...
 
void flags (CmdArg::CmdLineFlags f)
 Sets the argument's flags. More...
 
void sequence (unsigned int num)
 Sets the sequence number. More...
 
void setFlags (CmdArg::CmdLineFlags f)
 Toggles specified flags. More...
 

Protected Attributes

std::string pDescription
 
std::string pErrorMessage
 
CmdArg::CmdLineFlags pFlags
 
std::string pLongName
 
bool pModified
 
unsigned int pSequence
 
char pShortName
 
CmdArg::Syntax pSyntax
 
std::string pValueName
 

Detailed Description

template<typename T>
class CmdArgTypeFixedVector< T >

The CmdArgTypeFixedVector<T> class is a CmdArg that takes a fixed size list of values of type T.

Since it is derived from std::vector<T> you can use it like a std::vector<T>.

Definition at line 627 of file CmdArgs.hh.

Member Typedef Documentation

◆ const_iterator

Definition at line 631 of file CmdArgs.hh.

Member Enumeration Documentation

◆ Syntax

enum CmdArg::Syntax
inherited

Flags that define the argument syntax.

Enumerator
isOPT 

argument is optional

isREQ 

argument is required

isVALOPT 

argument value is optional

isVALREQ 

argument value is required

isVALSEP 

argument value must be in a separate token

isVALSTICKY 

argument value must be in the same token

isLIST 

argument is a list

isPOS 

argument is positional

isHIDDEN 

argument is not to be printed in usage

isFIXEDLIST 

argument value is a list of fixed size

isVALTAKEN 

argument takes a value

isOPTVALOPT 
isOPTVALREQ 
isPOSVALOPT 
isPOSVALREQ 

Definition at line 112 of file CmdArg.hh.

◆ CmdLineFlags

enum CmdArg::CmdLineFlags
inherited

Flags that say how the argument was specied on the command-line.

Enumerator
GIVEN 

argument was given

VALGIVEN 

argument value was given

OPTION 

item was matched as an option

KEYWORD 

item was matched as a keyword

POSITIONAL 

item was matched as a positional argument

VALSEP 

value was in a separate token

ALLFLAGS 

Definition at line 136 of file CmdArg.hh.

Constructor & Destructor Documentation

◆ CmdArgTypeFixedVector() [1/2]

template<typename T>
CmdArgTypeFixedVector< T >::CmdArgTypeFixedVector ( char  aShortName,
const std::string  aLongName,
const std::string  aValueName,
const std::string  aDescription,
unsigned int  aFixedSize,
Syntax  aSyntax = Syntax(isOPTVALREQ|isFIXEDLIST) 
)
inline

Constructor.

Creates a CmdArgTypeFixedVector with short and long name. By default the syntax flags are set so that the argument is optional and its values are required.

Parameters
aShortNameshort name of the argument
aLongNamelong name of the argument
aValueNamename of the agrument's value
aDescriptiondescription of the argument
aFixedSizesize of the vector. must not be 0.
aSyntaxsyntax flags
Exceptions
CmdLineSyntaxError

Definition at line 649 of file CmdArgs.hh.

◆ CmdArgTypeFixedVector() [2/2]

template<typename T>
CmdArgTypeFixedVector< T >::CmdArgTypeFixedVector ( const std::string  aValueName,
const std::string  aDescription,
unsigned int  aFixedSize,
Syntax  aSyntax = Syntax(isPOSVALREQ|isFIXEDLIST) 
)
inline

Constructor.

Creates a positional CmdArgTypeFixedVector. By default the syntax flags are set so that the argument's values are required.

Parameters
aValueNamename of the agrument's value
aDescriptiondescription of the argument
aFixedSizesize of the vector. must not be 0.
aSyntaxsyntax flags
Exceptions
CmdLineSyntaxError

Definition at line 686 of file CmdArgs.hh.

◆ ~CmdArgTypeFixedVector()

template<typename T>
virtual CmdArgTypeFixedVector< T >::~CmdArgTypeFixedVector ( )
inlinevirtual

Destructor.

Definition at line 711 of file CmdArgs.hh.

Member Function Documentation

◆ setDefaultValue()

template<typename T>
virtual void CmdArgTypeFixedVector< T >::setDefaultValue ( const std::vector< T > &  v)
inlinevirtual

Specify default value.

Parameters
vdefault value

Definition at line 723 of file CmdArgs.hh.

◆ hasDefaultValue()

template<typename T>
virtual bool CmdArgTypeFixedVector< T >::hasDefaultValue ( ) const
inlinevirtual

Returns true if a default value was specified.

Returns
true if a default value was specified

Reimplemented from CmdArg.

Definition at line 745 of file CmdArgs.hh.

◆ getDefaultValueString()

template<typename T>
virtual std::string CmdArgTypeFixedVector< T >::getDefaultValueString ( ) const
inlinevirtual

Returns the default value as a string.

Returns
default value as a string

Reimplemented from CmdArg.

Definition at line 759 of file CmdArgs.hh.

◆ parse()

template<typename T>
virtual bool CmdArgTypeFixedVector< T >::parse ( const char *  arg,
const char *&  endptr,
CmdLine  
)
inlinevirtual

Parse value string and append it to the vector.

If the given arg could not be parsed correctly a CmdLineSyntaxError exception is thrown.

Parameters
argthe string that is to be parsed
endptris set to the first unparsed character of arg
cmdreference to the CmdLine object that initiated the parsing (is ignored)
Exceptions
CmdLineSyntaxError
Returns
true if parsing was successful

Implements CmdArg.

Definition at line 791 of file CmdArgs.hh.

◆ fixedSize()

template<typename T>
virtual unsigned int CmdArgTypeFixedVector< T >::fixedSize ( ) const
inlinevirtual

Return the fixed size of the vector.

Returns
fixed size

Reimplemented from CmdArg.

Definition at line 837 of file CmdArgs.hh.

◆ remainingSize()

template<typename T>
virtual unsigned int CmdArgTypeFixedVector< T >::remainingSize ( ) const
inlinevirtual

Return the number of remaining values.

Returns
number of remaining values

Reimplemented from CmdArg.

Definition at line 851 of file CmdArgs.hh.

◆ clearFixedList()

template<typename T>
virtual void CmdArgTypeFixedVector< T >::clearFixedList ( )
inlinevirtual

Clear all values.

Reimplemented from CmdArg.

Definition at line 863 of file CmdArgs.hh.

◆ valueTypeAsString()

template<typename T>
virtual std::string CmdArgTypeFixedVector< T >::valueTypeAsString ( ) const
inlinevirtual

Return the value type as a std::string.

Returns
value type as a std::string

Implements CmdArg.

Definition at line 876 of file CmdArgs.hh.

◆ valueAsString()

template<typename T>
virtual std::string CmdArgTypeFixedVector< T >::valueAsString ( ) const
inlinevirtual

Return the value as a std::string.

Returns
value as a std::string

Implements CmdArg.

Definition at line 889 of file CmdArgs.hh.

◆ syntax()

CmdArg::Syntax CmdArg::syntax ( ) const
inherited

Retrieve the syntax flags for this argument.

◆ hasSyntax()

bool CmdArg::hasSyntax ( CmdArg::Syntax  s) const
inherited

Returns true if the argument's syntax flags contain s.

Parameters
ssyntax flag to be checked
Returns
true if the argument's syntax flags contain s

◆ flags() [1/2]

CmdArg::CmdLineFlags CmdArg::flags ( ) const
inherited

Retrieve the flags that say how this argument was specified.

◆ flags() [2/2]

void CmdArg::flags ( CmdArg::CmdLineFlags  f)
protectedinherited

Sets the argument's flags.

Parameters
fnew flags

◆ hasFlag()

bool CmdArg::hasFlag ( CmdArg::CmdLineFlags  f) const
inherited

Returns true if the argument's flags contain f.

Parameters
sflag to be checked
Returns
true if the argument's flags contain f

◆ sequence() [1/2]

unsigned int CmdArg::sequence ( ) const
inherited

Get the sequence number corresponding to the last time this argument was matched on the command-line.

If this argument was not matched, the sequence number will be zero, otherwise it will be 'N' where the last time this argument was matched, it was the 'N'th argument encountered.

Returns
sequence number

◆ sequence() [2/2]

void CmdArg::sequence ( unsigned int  num)
protectedinherited

Sets the sequence number.

Parameters
numnew sequence number

◆ shortName()

char CmdArg::shortName ( ) const
inherited

Returns the argument's short name.

Return's 0 if it has none.

Returns
short name

◆ longName()

const std::string CmdArg::longName ( ) const
inherited

Returns the argument's long name.

Return's "" if it has none.

Returns
long name

◆ valueName()

const std::string CmdArg::valueName ( ) const
inherited

Returns the argument's value name.

Return's "" if it takes no value.

Returns
value name

◆ description()

const std::string CmdArg::description ( ) const
inherited

Get the description (help-message) of this argument.

Returns
description

◆ synopsis()

const std::string CmdArg::synopsis ( bool  displayShort = true,
bool  displayLong = true 
) const
inherited

Generates and returns the arguments synopsis.

Parameters
displayShortif true print short name
displayLongif true display long name
Returns
synopsis string

◆ errorMsg()

const std::string CmdArg::errorMsg ( ) const
inherited

Returns error message of last parsing.

Returns
last error message

◆ clearErrorMsg()

void CmdArg::clearErrorMsg ( )
inherited

Clears the error message.

◆ setErrorMsg()

void CmdArg::setErrorMsg ( const std::string &  msg)
inherited

Sets the error message.

Parameters
msgnew error message.

◆ modified() [1/2]

bool CmdArg::modified ( ) const
inherited

Returns true if the argument was parsed at the last parsing run.

Returns
if the argument was parsed

Referenced by CmdArgType< T >::parse(), CmdArgTypeVector< T >::parse(), CmdArgTypeFixedVector< T >::parse(), and CmdArgSwitch::parse().

◆ modified() [2/2]

void CmdArg::modified ( bool  m)
inherited

Sets the modified flag.

Parameters
m

◆ given()

bool CmdArg::given ( ) const
inherited

Returns true if the argument was parsed in any of the parsing runs.

Returns
if the argument was ever parsed

◆ adjustSyntax()

void CmdArg::adjustSyntax ( )
protectedinherited

Adjust and correct specified syntax flags.

Exceptions
CmdLineSyntaxError

Referenced by CmdArgTypeFixedVector< T >::CmdArgTypeFixedVector().

◆ setFlags()

void CmdArg::setFlags ( CmdArg::CmdLineFlags  f)
protectedinherited

Toggles specified flags.

Parameters
fflags to toggle

◆ clearFlags()

void CmdArg::clearFlags ( CmdArg::CmdLineFlags  f = ALLFLAGS)
protectedinherited

Clears the specified flags.

Parameters
fflags to clear

Field Documentation

◆ pFlags

CmdArg::CmdLineFlags CmdArg::pFlags
protectedinherited

Definition at line 541 of file CmdArg.hh.

◆ pSyntax

CmdArg::Syntax CmdArg::pSyntax
protectedinherited

Definition at line 542 of file CmdArg.hh.

◆ pSequence

unsigned int CmdArg::pSequence
protectedinherited

Definition at line 544 of file CmdArg.hh.

◆ pShortName

char CmdArg::pShortName
protectedinherited

Definition at line 545 of file CmdArg.hh.

◆ pLongName

std::string CmdArg::pLongName
protectedinherited

Definition at line 546 of file CmdArg.hh.

◆ pValueName

std::string CmdArg::pValueName
protectedinherited

Definition at line 547 of file CmdArg.hh.

◆ pDescription

std::string CmdArg::pDescription
protectedinherited

Definition at line 548 of file CmdArg.hh.

◆ pErrorMessage

std::string CmdArg::pErrorMessage
protectedinherited

Definition at line 550 of file CmdArg.hh.

◆ pModified

bool CmdArg::pModified
protectedinherited

Definition at line 552 of file CmdArg.hh.

◆ elements

T std::vector< T >::elements
inherited

STL member.


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