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

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

#include <ValueArg.h>

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

Public Member Functions

virtual bool processArg (int *i, std::vector< std::string > &args)
 Handles the processing of the argument. More...
 
 ValueArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, T value, const std::string &typeDesc, bool allowOverwrite=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
 ValueArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, T value, const std::string &typeDesc, TCLAP::CmdLineInterface &parser, bool allowOverwrite=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
 ValueArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, T value, TCLAP::Constraint< T > *constraint, TCLAP::CmdLineInterface &parser, bool allowOverwrite=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 
 ValueArg (const std::string &flag, const std::string &name, const std::string &desc, bool req, T value, TCLAP::Constraint< T > *constraint, bool allowOverwrite=false, TCLAP::Visitor *v=NULL)
 Constructor. More...
 

Protected Attributes

bool _allowOverwrite
 

Detailed Description

template<class T>
class basis::ValueArg< T >

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

Unlike TCLAP::ValueArg, this argument optionally allows the assignement of a value more than once, overwriting the previously set argument value. This is useful when a visitor set on another option consumed the previously set argument already and thus the value can be overwritten before the next appearance of this option. See the basistest-driver executable, for example, where the tolerances are stored in a structure every time a –compare option is encountered and the tolerances can then be overwritten for the next –compare statement.

Copyright (c) 2012 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 ValueArg.h.

Constructor & Destructor Documentation

§ ValueArg() [1/4]

template<class T >
basis::ValueArg< T >::ValueArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
value,
const std::string &  typeDesc,
bool  allowOverwrite = 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]valueThe default value assigned to this argument if it is not present 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]allowOverwriteWhether value can be overwritten by another occurrence of the argument on the command-line.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 206 of file ValueArg.h.

§ ValueArg() [2/4]

template<class T >
basis::ValueArg< T >::ValueArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
value,
const std::string &  typeDesc,
TCLAP::CmdLineInterface &  parser,
bool  allowOverwrite = 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]valueThe default value assigned to this argument if it is not present 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]allowOverwriteWhether value can be overwritten by another occurrence of the argument on the command-line.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 222 of file ValueArg.h.

§ ValueArg() [3/4]

template<class T >
basis::ValueArg< T >::ValueArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
value,
TCLAP::Constraint< T > *  constraint,
TCLAP::CmdLineInterface &  parser,
bool  allowOverwrite = 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]valueThe default value assigned to this argument if it is not present 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]allowOverwriteWhether value can be overwritten by another occurrence of the argument on the command-line.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 255 of file ValueArg.h.

§ ValueArg() [4/4]

template<class T >
basis::ValueArg< T >::ValueArg ( const std::string &  flag,
const std::string &  name,
const std::string &  desc,
bool  req,
value,
TCLAP::Constraint< T > *  constraint,
bool  allowOverwrite = 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]valueThe default value assigned to this argument if it is not present on the command line.
[in]constraintA pointer to a Constraint object used to constrain this Arg.
[in]allowOverwriteWhether value can be overwritten by another occurrence of the argument on the command-line.
[in]vAn optional visitor. You probably should not use this unless you have a very good reason.

Definition at line 239 of file ValueArg.h.

Member Function Documentation

§ processArg()

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

Handles the processing of the argument.

This re-implements the TCLAP::ValueArg version of this method to ignore the _alreadySet flag if _allowOverwrite is true.

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

Definition at line 272 of file ValueArg.h.

Member Data Documentation

§ _allowOverwrite

template<class T>
bool basis::ValueArg< T >::_allowOverwrite
protected

Whether argument value can be overwritten by another occurrence of this argument.

Definition at line 194 of file ValueArg.h.


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