15 #ifndef TCLAP_MULTIPLE_ARGUMENT_H 16 #define TCLAP_MULTIPLE_ARGUMENT_H 26 #if defined(HAVE_SSTREAM) 28 #elif defined(HAVE_STRSTREAM) 31 #error "Need a stringstream (sstream or strstream) to compile!" 36 template<
class T>
class MultiArg;
38 namespace MultiArgHelper {
81 #if defined(HAVE_SSTREAM) 82 std::istringstream is(val);
83 #elif defined(HAVE_STRSTREAM) 84 std::istrstream is(val.c_str());
86 #error "Need a stringstream (sstream or strstream) to compile!" 93 if ( is.peek() != EOF )
104 if ( valuesRead > 1 )
107 _values.push_back(temp);
131 std::vector<std::string> &
_values;
171 std::string _typeDesc;
184 void _extractValue(
const std::string& val );
208 const std::string& name,
209 const std::string& desc,
211 const std::string& typeDesc,
233 const std::string& name,
234 const std::string& desc,
236 const std::string& typeDesc,
256 const std::string& name,
257 const std::string& desc,
279 const std::string& name,
280 const std::string& desc,
294 virtual bool processArg(
int* i, std::vector<std::string>&
args);
300 const std::vector<T>& getValue();
306 virtual std::string shortID(
const std::string& val=
"val")
const;
312 virtual std::string longID(
const std::string& val=
"val")
const;
318 virtual bool isRequired()
const;
320 virtual bool allowMore();
326 const std::string& name,
327 const std::string& desc,
329 const std::string& typeDesc,
331 :
Arg( flag, name, desc, req,
true, v ),
332 _typeDesc( typeDesc ),
336 _acceptsMultipleValues =
true;
341 const std::string& name,
342 const std::string& desc,
344 const std::string& typeDesc,
347 :
Arg( flag, name, desc, req,
true, v ),
348 _typeDesc( typeDesc ),
353 _acceptsMultipleValues =
true;
361 const std::string& name,
362 const std::string& desc,
366 :
Arg( flag, name, desc, req,
true, v ),
367 _typeDesc( constraint->
shortID() ),
368 _constraint( constraint ),
371 _acceptsMultipleValues =
true;
376 const std::string& name,
377 const std::string& desc,
382 :
Arg( flag, name, desc, req,
true, v ),
383 _typeDesc( constraint->
shortID() ),
384 _constraint( constraint ),
388 _acceptsMultipleValues =
true;
400 if ( _hasBlanks( args[*i] ) )
403 std::string flag = args[*i];
404 std::string
value =
"";
406 trimFlag( flag, value );
408 if ( argMatches( flag ) )
412 "Couldn't find delimiter for this argument!",
419 if ( static_cast<unsigned int>(*i) < args.size() )
420 _extractValue( args[*i] );
426 _extractValue( value );
462 std::string
id =
Arg::longID(_typeDesc) +
" (accepted multiple times)";
495 "from string '" + val +
"'", toString() ) );
499 "parsed from string '" + val +
"'",
501 if ( _constraint != NULL )
502 if ( ! _constraint->check(
_values.back() ) )
504 "' does not meet constraint: " +
505 _constraint->description(),
512 bool am = _allowMore;
virtual std::string shortID(const std::string &valueId="val") const
virtual std::string shortID() const =0
std::vector< double > values
TClap class indirectly used to define the interface for visitors.
virtual bool processArg(int *i, std::vector< std::string > &args)
Managing interface for The base class that manages the command line definition and passes along the p...
Virtual parent for all the different argument classes.
Defines the interaction between an argument and a constraint.
Defines the exception that is thrown when an argument is improperly parsed.
virtual std::string longID(const std::string &val="val") const
virtual std::string shortID(const std::string &val="val") const
virtual void add(Arg &a)=0
MultiArg(const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, Visitor *v=NULL)
virtual std::string longID(const std::string &valueId="val") const
Defines the exception when an argument is improperly specified.
const GenericPointer< typename T::ValueType > T2 value
void _extractValue(const std::string &val)
virtual bool isRequired() const
const std::vector< T > & getValue()