VR-Link API Documentation for HLA 1.3
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
DtCmdLine::MultiArg< T > Class Template Reference

An argument that allows multiple values of type T to be specified. More...

+ Inheritance diagram for DtCmdLine::MultiArg< T >:
+ Collaboration diagram for DtCmdLine::MultiArg< T >:

List of all members.

Public Member Functions

 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, Visitor *v=NULL)
 Constructor.
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, CmdLineInterface &parser, Visitor *v=NULL)
 Constructor.
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::vector< T > &allowed, Visitor *v=NULL)
 Constructor.
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::vector< T > &allowed, CmdLineInterface &parser, Visitor *v=NULL)
 Constructor.
virtual bool processArg (int *i, std::vector< std::string > &args)
 Handles the processing of the argument.
const std::vector< T > & getValue () const
 Returns a vector of type T containing the values parsed from the command line.
virtual std::string shortID (const std::string &val="val") const
 Returns the a short id string.
virtual std::string longID (const std::string &val="val") const
 Returns the a long id string.
virtual bool isRequired () const
 Once we've matched the first value, then the arg is no longer required.

Protected Member Functions

void _extractValue (const std::string &val)
 Extracts the value from the string.
void _checkAllowed (const std::string &val)
 Checks to see if parsed value is in allowed list.

Protected Attributes

std::vector< T > _values
 The list of values parsed from the CmdLine.
std::vector< T > _allowed
 A list of allowed values.
std::string _typeDesc
 The description of type T to be used in the usage.

Private Member Functions

void allowedInit ()
 Common initialization code for constructors with allowed vectors.

Detailed Description

template<class T>
class DtCmdLine::MultiArg< T >

An argument that allows multiple values of type T to be specified.

Very similar to a ValueArg, except a vector of values will be returned instead of just one.


Constructor & Destructor Documentation

template<class T >
DtCmdLine::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
const std::string &  typeDesc,
Visitor v = NULL 
)

Constructor.

 
Parameters:
flag- The one character flag that identifies this argument on the command line.
name- A one word name for the argument. Can be used as a long flag on the command line.
desc- A description of what the argument is for or does.
req- Whether the argument is required on the command line.
typeDesc- A short, human readable description of the type that this object expects. This is used in the generation of the USAGE statement. The goal is to be helpful to the end user of the program.
v- An optional visitor. You probably should not use this unless you have a very good reason.
template<class T >
DtCmdLine::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
const std::string &  typeDesc,
CmdLineInterface parser,
Visitor v = NULL 
)

Constructor.

Parameters:
flag- The one character flag that identifies this argument on the command line.
name- A one word name for the argument. Can be used as a long flag on the command line.
desc- A description of what the argument is for or does.
req- Whether the argument is required on the command line.
typeDesc- A short, human readable description of the type that this object expects. This is used in the generation of the USAGE statement. The goal is to be helpful to the end user of the program.
parser- A CmdLine parser object to add this Arg to
v- An optional visitor. You probably should not use this unless you have a very good reason.

References DtCmdLine::CmdLineInterface::add().

template<class T >
DtCmdLine::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
const std::vector< T > &  allowed,
Visitor v = NULL 
)

Constructor.

 
Parameters:
flag- The one character flag that identifies this argument on the command line.
name- A one word name for the argument. Can be used as a long flag on the command line.
desc- A description of what the argument is for or does.
req- Whether the argument is required on the command line.
allowed- A vector of type T that where the values in the vector are the only values allowed for the arg.
v- An optional visitor. You probably should not use this unless you have a very good reason.

References DtCmdLine::MultiArg< T >::allowedInit().

template<class T >
DtCmdLine::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
const std::vector< T > &  allowed,
CmdLineInterface parser,
Visitor v = NULL 
)

Constructor.

Parameters:
flag- The one character flag that identifies this argument on the command line.
name- A one word name for the argument. Can be used as a long flag on the command line.
desc- A description of what the argument is for or does.
req- Whether the argument is required on the command line.
allowed- A vector of type T that where the values in the vector are the only values allowed for the arg.
parser- A CmdLine parser object to add this Arg to
v- An optional visitor. You probably should not use this unless you have a very good reason.

References DtCmdLine::CmdLineInterface::add(), and DtCmdLine::MultiArg< T >::allowedInit().


Member Function Documentation

template<class T >
void DtCmdLine::MultiArg< T >::_checkAllowed ( const std::string &  val) [protected]

Checks to see if parsed value is in allowed list.

Checks to see if the value parsed is in the allowed list.

Parameters:
val- value parsed (only used in output).
template<class T >
void DtCmdLine::MultiArg< T >::_extractValue ( const std::string &  val) [protected]

Extracts the value from the string.

Attempts to parse string as type T, if this fails an exception is thrown.

Parameters:
val- The string to be read.

References DtCmdLine::MULTI_ARG_HELPER::EXTRACT_FAILURE, DtCmdLine::MULTI_ARG_HELPER::EXTRACT_TOO_MANY, and DtCmdLine::MULTI_ARG_HELPER::ValueExtractor< T >::extractValue().

template<class T >
void DtCmdLine::MultiArg< T >::allowedInit ( ) [private]

Common initialization code for constructors with allowed vectors.

 

Referenced by DtCmdLine::MultiArg< T >::MultiArg().

template<class T >
const std::vector< T > & DtCmdLine::MultiArg< T >::getValue ( ) const

Returns a vector of type T containing the values parsed from the command line.

 
template<class T >
bool DtCmdLine::MultiArg< T >::isRequired ( ) const [virtual]

Once we've matched the first value, then the arg is no longer required.

Reimplemented from DtCmdLine::Arg.

template<class T >
std::string DtCmdLine::MultiArg< T >::longID ( const std::string &  val = "val") const [virtual]

Returns the a long id string.

 

Used in the usage.

Parameters:
val- value to be used.

Reimplemented from DtCmdLine::Arg.

Reimplemented in DtCmdLine::UnlabeledMultiArg< T >.

References DtCmdLine::Arg::longID().

template<class T >
bool DtCmdLine::MultiArg< T >::processArg ( int *  i,
std::vector< std::string > &  args 
) [virtual]

Handles the processing of the argument.

 

This re-implements the Arg version of this method to set the _value of the argument appropriately. It knows the difference between labeled and unlabeled.

Parameters:
i- Pointer the the current argument in the list.
args- Mutable list of strings. Passed from main().

Implements DtCmdLine::Arg.

Reimplemented in DtCmdLine::UnlabeledMultiArg< T >.

References DtCmdLine::Arg::delimiter(), and DtCmdLine::Arg::ignoreRest().

template<class T >
std::string DtCmdLine::MultiArg< T >::shortID ( const std::string &  val = "val") const [virtual]

Returns the a short id string.

 

Used in the usage.

Parameters:
val- value to be used.

Reimplemented from DtCmdLine::Arg.

Reimplemented in DtCmdLine::UnlabeledMultiArg< T >.

References DtCmdLine::Arg::shortID().


Member Data Documentation

template<class T>
std::vector<T> DtCmdLine::MultiArg< T >::_allowed [protected]

A list of allowed values.

A list of values allowed for this argument. If the value parsed for this arg is not found in this list, then an exception is thrown. If the list is empty, then any value is allowed.

template<class T>
std::string DtCmdLine::MultiArg< T >::_typeDesc [protected]

The description of type T to be used in the usage.

template<class T>
std::vector<T> DtCmdLine::MultiArg< T >::_values [protected]

The list of values parsed from the CmdLine.


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

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)