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

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

#include <ValueArg.h>

List of all members.

Public Member Functions

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

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

Definition at line 43 of file ValueArg.h.


Constructor & Destructor Documentation

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 202 of file ValueArg.h.

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 218 of file ValueArg.h.

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 251 of file ValueArg.h.

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 235 of file ValueArg.h.


Member Function Documentation

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 268 of file ValueArg.h.


Member Data Documentation

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

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

Definition at line 190 of file ValueArg.h.


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