Public Member Functions | Protected Attributes | List of all members
basis::MultiArg< T > Class Template Reference

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

#include <MultiArg.h>

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

Public Member Functions

virtual bool isRequired () const
 Whether the argument is required or not. More...
 
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, unsigned int n=1, bool once=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, TCLAP::CmdLineInterface &parser, unsigned int n=1, bool once=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, TCLAP::Constraint< T > *constraint, unsigned int n=1, bool once=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
 MultiArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, TCLAP::Constraint< T > *constraint, TCLAP::CmdLineInterface &parser, unsigned int n=1, bool once=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
virtual bool processArg (int *i, std::vector< std::string > &args)
 Handles the processing of the argument. More...
 

Protected Attributes

unsigned int _numberOfArguments
 Number of values to process each time. More...
 

Detailed Description

template<class T>
class basis::MultiArg< T >

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

Very similar to a TCLAP::ValueArg, except a vector of values will be returned instead of just one. Unlike TCLAP::MultiArg, this argument will each time its option keyword or flag is encountered process N > 0 argument values, where the number N is specified at construction time. Moreover, this argument can be given several times. Hence, the returned vector of values has length N * M, where M is the number of times the argument was given on the command-line.

Copyright (c) 2011 University of Pennsylvania. All rights reserved.
See http://www.rad.upenn.edu/sbia/software/license.html or COPYING file.

Definition at line 47 of file MultiArg.h.

Constructor & Destructor Documentation

§ MultiArg() [1/4]

template<class T >
basis::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
const std::string &  typeDesc,
unsigned int  n = 1,
bool  once = false,
TCLAP::Visitor *  v = NULL 
)

Constructor.

Parameters
[in]flagThe one character flag that identifies this argument on the command line.
[in]nameA one word name for the argument. Can be used as a long flag on the command line.
[in]descA description of what the argument is for or does.
[in]reqWhether the argument is required on the command-line.
[in]typeDescA 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.
[in]nNumber of values per argument occurrence.
[in]onceAccept argument only once.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 207 of file MultiArg.h.

§ MultiArg() [2/4]

template<class T >
basis::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
const std::string &  typeDesc,
TCLAP::CmdLineInterface &  parser,
unsigned int  n = 1,
bool  once = false,
TCLAP::Visitor *  v = NULL 
)

Constructor.

Parameters
[in]flagThe one character flag that identifies this argument on the command line.
[in]nameA one word name for the argument. Can be used as a long flag on the command line.
[in]descA description of what the argument is for or does.
[in]reqWhether the argument is required on the command-line.
[in]typeDescA 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.
[in]parserA CmdLine parser object to add this Arg to
[in]nNumber of values per argument occurrence.
[in]onceAccept argument only once.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 224 of file MultiArg.h.

§ MultiArg() [3/4]

template<class T >
basis::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
TCLAP::Constraint< T > *  constraint,
unsigned int  n = 1,
bool  once = false,
TCLAP::Visitor *  v = NULL 
)

Constructor.

Parameters
[in]flagThe one character flag that identifies this argument on the command line.
[in]nameA one word name for the argument. Can be used as a long flag on the command line.
[in]descA description of what the argument is for or does.
[in]reqWhether the argument is required on the command-line.
[in]constraintA pointer to a Constraint object used to constrain this Arg.
[in]nNumber of values per argument occurrence.
[in]onceAccept argument only once.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 242 of file MultiArg.h.

§ MultiArg() [4/4]

template<class T >
basis::MultiArg< T >::MultiArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
TCLAP::Constraint< T > *  constraint,
TCLAP::CmdLineInterface &  parser,
unsigned int  n = 1,
bool  once = false,
TCLAP::Visitor *  v = NULL 
)

Constructor.

Parameters
[in]flagThe one character flag that identifies this argument on the command line.
[in]nameA one word name for the argument. Can be used as a long flag on the command line.
[in]descA description of what the argument is for or does.
[in]reqWhether the argument is required on the command-line.
[in]constraintA pointer to a Constraint object used to constrain this Arg.
[in]parserA CmdLine parser object to add this Arg to.
[in]nNumber of values per argument occurrence.
[in]onceAccept argument only once.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 259 of file MultiArg.h.

Member Function Documentation

§ isRequired()

template<class T >
bool basis::MultiArg< T >::isRequired ( ) const
virtual

Whether the argument is required or not.

Once we've matched the first value, then the arg is no longer required, except if the argument is only accepted once with multiple values.

Definition at line 331 of file MultiArg.h.

§ processArg()

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

Handles the processing of the argument.

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

Parameters
[in,out]iPointer to the current argument in the list.
[in,out]argsMutable list of strings. Passed from main().

Definition at line 277 of file MultiArg.h.

Member Data Documentation

§ _numberOfArguments

template<class T>
unsigned int basis::MultiArg< T >::_numberOfArguments
protected

Number of values to process each time.

Definition at line 196 of file MultiArg.h.


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