Go to the documentation of this file.
23 #ifndef TCLAP_MULTIPLE_ARGUMENT_H
24 #define TCLAP_MULTIPLE_ARGUMENT_H
39 class MultiArg :
public Arg
43 typedef typename container_type::iterator
iterator;
96 const std::string& name,
97 const std::string& desc,
99 const std::string& typeDesc,
121 const std::string& name,
122 const std::string& desc,
124 const std::string& typeDesc,
144 const std::string& name,
145 const std::string& desc,
167 const std::string& name,
168 const std::string& desc,
182 virtual bool processArg(
int* i, std::vector<std::string>& args);
206 virtual std::string
shortID(
const std::string& val=
"val")
const;
212 virtual std::string
longID(
const std::string& val=
"val")
const;
222 virtual void reset();
228 MultiArg<T>(
const MultiArg<T>& rhs);
229 MultiArg<T>& operator=(
const MultiArg<T>& rhs);
235 const std::string& name,
236 const std::string& desc,
238 const std::string& typeDesc,
240 Arg( flag, name, desc, req, true, v ),
241 _values(std::vector<T>()),
242 _typeDesc( typeDesc ),
251 const std::string& name,
252 const std::string& desc,
254 const std::string& typeDesc,
257 :
Arg( flag, name, desc, req, true, v ),
258 _values(std::vector<T>()),
259 _typeDesc( typeDesc ),
272 const std::string& name,
273 const std::string& desc,
277 :
Arg( flag, name, desc, req, true, v ),
278 _values(std::vector<T>()),
279 _typeDesc( constraint->shortID() ),
280 _constraint( constraint ),
288 const std::string& name,
289 const std::string& desc,
294 :
Arg( flag, name, desc, req, true, v ),
295 _values(std::vector<T>()),
296 _typeDesc( constraint->shortID() ),
297 _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() ) )
410 throw( CmdLineParseException(
"Value '" + val +
411 "' does not meet constraint: " +
412 _constraint->description(),
419 bool am = _allowMore;
The base class that manages the command line definition and passes along the parsing to the appropria...
virtual std::string longID(const std::string &val="val") const
Returns the a long id string.
virtual void add(Arg &a)=0
Adds an argument to the list of arguments to be parsed.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
void ExtractValue(T &destVal, const std::string &strVal, ValueLike vl)
static bool ignoreRest()
Whether to ignore the rest.
std::vector< T > _values
The list of values parsed from the CmdLine.
const_iterator begin() const
Returns an iterator over the values parsed from the command line.
virtual std::string shortID(const std::string &val="val") const
Returns the a short id string.
const std::vector< T > & getValue()
Returns a vector of type T containing the values parsed from the command line.
const_iterator end() const
Returns the end of the values parsed from the command line.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
bool _acceptsMultipleValues
virtual bool isRequired() const
Once we've matched the first value, then the arg is no longer required.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
std::string _typeDesc
The description of type T to be used in the usage.
container_type::const_iterator const_iterator
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
std::string error() const
Returns the error text.
std::vector< T > container_type
void _extractValue(const std::string &val)
Extracts the value from the string.
Constraint< T > * _constraint
A list of constraint on this Arg.
MultiArg(const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, Visitor *v=NULL)
Constructor.
bool _allowMore
Used by XorHandler to decide whether to keep parsing for this arg.
A base class that defines the interface for visitors.
virtual bool allowMore()
Used for MultiArgs and XorHandler to determine whether args can still be set.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
The interface that defines the interaction between the Arg and Constraint.
T::ValueCategory ValueCategory
container_type::iterator iterator
A virtual base class that defines the essential data for all arguments.