26 #ifndef TCLAP_MULTIPLE_ARGUMENT_H 
   27 #define TCLAP_MULTIPLE_ARGUMENT_H 
   46     typedef typename container_type::iterator 
iterator;
 
   99                   const std::string& name,
 
  100                   const std::string& desc,
 
  102                   const std::string& typeDesc,
 
  124                   const std::string& name,
 
  125                   const std::string& desc,
 
  127                   const std::string& typeDesc,
 
  147                   const std::string& name,
 
  148                   const std::string& desc,
 
  170                   const std::string& name,
 
  171                   const std::string& desc,
 
  185     virtual bool processArg(
int* i, std::vector<std::string>& args); 
 
  209     virtual std::string 
shortID(
const std::string& val=
"val") 
const;
 
  215     virtual std::string 
longID(
const std::string& val=
"val") 
const;
 
  225     virtual void reset();
 
  238                       const std::string& name,
 
  239                       const std::string& desc,
 
  241                       const std::string& typeDesc,
 
  243    Arg( flag, name, desc, req, true, v ),
 
  244   _values(std::vector<T>()),
 
  245   _typeDesc( typeDesc ),
 
  254                       const std::string& name,
 
  255                       const std::string& desc,
 
  257                       const std::string& typeDesc,
 
  260 : 
Arg( flag, name, desc, req, true, v ),
 
  261   _values(std::vector<T>()),
 
  262   _typeDesc( typeDesc ),
 
  275                       const std::string& name,
 
  276                       const std::string& desc,
 
  280 : 
Arg( flag, name, desc, req, true, v ),
 
  281   _values(std::vector<T>()),
 
  282   _typeDesc( 
Constraint<T>::shortID(constraint) ),
 
  283   _constraint( constraint ),
 
  291                       const std::string& name,
 
  292                       const std::string& desc,
 
  297 : 
Arg( flag, name, desc, req, true, v ),
 
  298   _values(std::vector<T>()),
 
  299   _typeDesc( 
Constraint<T>::shortID(constraint) ),
 
  300   _constraint( constraint ),
 
  313     if ( _hasBlanks( args[*i] ) )
 
  316     std::string flag = args[*i];
 
  317     std::string value = 
"";
 
  319     trimFlag( flag, value );
 
  321     if ( argMatches( flag ) )
 
  325                        "Couldn't find delimiter for this argument!",
 
  332             if ( 
static_cast<unsigned int>(*i) < args.size() )
 
  333                 _extractValue( args[*i] );
 
  339             _extractValue( value );
 
  364     static_cast<void>(val); 
 
  374     static_cast<void>(val); 
 
  375     return Arg::longID(_typeDesc) + 
"  (accepted multiple times)";
 
  387         if ( _values.size() > 1 )
 
  403     _values.push_back(tmp);
 
  408     if ( _constraint != NULL )
 
  409     if ( ! _constraint->check( _values.back() ) )
 
  411                       "' does not meet constraint: " +
 
  412                       _constraint->description(), 
 
  419     bool am = _allowMore;
 
std::string error() const
Returns the error text.
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
A virtual base class that defines the essential data for all arguments.
bool _acceptsMultipleValues
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
static bool ignoreRest()
Whether to ignore the rest.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
The base class that manages the command line definition and passes along the parsing to the appropria...
virtual void add(Arg &a)=0
Adds an argument to the list of arguments to be parsed.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
The interface that defines the interaction between the Arg and Constraint.
An argument that allows multiple values of type T to be specified.
const std::vector< T > & getValue() const
Returns a vector of type T containing the values parsed from the command line.
std::string _typeDesc
The description of type T to be used in the usage.
void _extractValue(const std::string &val)
Extracts the value from the string.
container_type::iterator iterator
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
container_type::const_iterator const_iterator
const_iterator end() const
Returns the end of the values parsed from the command line.
MultiArg(const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, Visitor *v=NULL)
Constructor.
virtual bool isRequired() const
Once we've matched the first value, then the arg is no longer required.
const_iterator begin() const
Returns an iterator over the values parsed from the command line.
bool _allowMore
Used by XorHandler to decide whether to keep parsing for this arg.
std::vector< T > _values
The list of values parsed from the CmdLine.
virtual bool allowMore()
Used for MultiArgs and XorHandler to determine whether args can still be set.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
virtual std::string shortID(const std::string &val="val") const
Returns the a short id string.
std::vector< T > container_type
virtual std::string longID(const std::string &val="val") const
Returns the a long id string.
Constraint< T > * _constraint
A list of constraint on this Arg.
A base class that defines the interface for visitors.
void ExtractValue(T &destVal, const std::string &strVal, ValueLike vl)
A value like argument value type is a value that can be set using operator>>.