15 #ifndef TCLAP_VALUE_ARGUMENT_H 16 #define TCLAP_VALUE_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 ValueArg;
38 namespace ValueArgHelper {
79 #if defined(HAVE_SSTREAM) 80 std::istringstream is(val);
81 #elif defined(HAVE_STRSTREAM) 82 std::istrstream is(val.c_str());
84 #error "Need a stringstream (sstream or strstream) to compile!" 90 if ( is.peek() != EOF )
101 if ( valuesRead > 1 )
174 std::string _typeDesc;
187 void _extractValue(
const std::string& val );
215 const std::string& name,
216 const std::string& desc,
219 const std::string& typeDesc,
248 const std::string& name,
249 const std::string& desc,
252 const std::string& typeDesc,
279 const std::string& name,
280 const std::string& desc,
309 const std::string& name,
310 const std::string& desc,
325 virtual bool processArg(
int* i, std::vector<std::string>& args);
336 virtual std::string shortID(
const std::string& val =
"val")
const;
342 virtual std::string longID(
const std::string& val =
"val")
const;
352 const std::string& name,
353 const std::string& desc,
356 const std::string& typeDesc,
358 :
Arg(flag, name, desc, req,
true, v),
360 _typeDesc( typeDesc ),
366 const std::string& name,
367 const std::string& desc,
370 const std::string& typeDesc,
373 :
Arg(flag, name, desc, req,
true, v),
375 _typeDesc( typeDesc ),
383 const std::string& name,
384 const std::string& desc,
389 :
Arg(flag, name, desc, req,
true, v),
391 _typeDesc( constraint->
shortID() ),
392 _constraint( constraint )
397 const std::string& name,
398 const std::string& desc,
404 :
Arg(flag, name, desc, req,
true, v),
406 _typeDesc( constraint->
shortID() ),
407 _constraint( constraint )
428 if ( _hasBlanks( args[*i] ) )
431 std::string flag = args[*i];
433 std::string value =
"";
434 trimFlag( flag, value );
436 if ( argMatches( flag ) )
443 "Couldn't find delimiter for this argument!",
449 if ( static_cast<unsigned int>(*i) < args.size() )
450 _extractValue( args[*i] );
456 _extractValue( value );
472 std::string stop_warnings = val;
482 std::string stop_warnings = val;
495 val +
"'", toString() ) );
499 "More than one valid value parsed from string '" +
500 val +
"'", toString() ) );
502 if ( _constraint != NULL )
503 if ( ! _constraint->check(
_value ) )
505 "' does not meet constraint: " +
506 _constraint->description(),
void _extractValue(const std::string &val)
ValueArg(const std::string &flag, const std::string &name, const std::string &desc, bool req, T value, const std::string &typeDesc, Visitor *v=NULL)
virtual bool processArg(int *i, std::vector< std::string > &args)
virtual std::string shortID(const std::string &valueId="val") const
virtual std::string shortID() const =0
TClap class indirectly used to define the interface for visitors.
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
virtual std::string longID(const std::string &valueId="val") const
Defines the exception when an argument is improperly specified.