BASIS  r3148
basis::MultiArg< T > Class Template Reference

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

#include <MultiArg.h>

List of all members.

Public Member Functions

virtual bool isRequired () const
 Whether the argument is required or not.
 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.
 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.
 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.
 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.
virtual bool processArg (int *i, std::vector< std::string > &args)
 Handles the processing of the argument.

Protected Attributes

unsigned int _numberOfArguments
 Number of values to process each time.

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 https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.

Definition at line 43 of file MultiArg.h.


Constructor & Destructor Documentation

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 203 of file MultiArg.h.

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 220 of file MultiArg.h.

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 238 of file MultiArg.h.

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 255 of file MultiArg.h.


Member Function Documentation

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 327 of file MultiArg.h.

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 273 of file MultiArg.h.


Member Data Documentation

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

Number of values to process each time.

Definition at line 192 of file MultiArg.h.


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