Go to the documentation of this file.
11 #ifndef TCLAP_VALUE_ARGUMENT_H
12 #define TCLAP_VALUE_ARGUMENT_H
27 #if defined(HAVE_SSTREAM)
29 #elif defined(HAVE_STRSTREAM)
32 #error "Need a stringstream (sstream or strstream) to compile!"
39 namespace VALUE_ARG_HELPER {
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!"
92 if ( is.peek() != EOF )
103 if ( valuesRead > 1 )
159 class ValueArg :
public Arg
218 const std::string& name,
219 const std::string& desc,
222 const std::string& typeDesc,
251 const std::string& name,
252 const std::string& desc,
255 const std::string& typeDesc,
282 const std::string& name,
283 const std::string& desc,
312 const std::string& name,
313 const std::string& desc,
328 virtual bool processArg(
int* i, std::vector<std::string>& args);
339 virtual std::string
shortID(
const std::string& val =
"val")
const;
345 virtual std::string
longID(
const std::string& val =
"val")
const;
355 const std::string& name,
356 const std::string& desc,
359 const std::string& typeDesc,
361 :
Arg(flag, name, desc, req, true, v),
363 _typeDesc( typeDesc ),
369 const std::string& name,
370 const std::string& desc,
373 const std::string& typeDesc,
376 :
Arg(flag, name, desc, req, true, v),
378 _typeDesc( typeDesc ),
386 const std::string& name,
387 const std::string& desc,
392 :
Arg(flag, name, desc, req, true, v),
394 _typeDesc( constraint->shortID() ),
395 _constraint( constraint )
400 const std::string& name,
401 const std::string& desc,
407 :
Arg(flag, name, desc, req, true, v),
409 _typeDesc( constraint->shortID() ),
410 _constraint( constraint )
431 if ( _hasBlanks( args[*i] ) )
434 std::string flag = args[*i];
436 std::string value =
"";
437 trimFlag( flag, value );
439 if ( argMatches( flag ) )
446 "Couldn't find delimiter for this argument!",
452 if (
static_cast<unsigned int>(*i) < args.size() )
453 _extractValue( args[*i] );
459 _extractValue( value );
496 val +
"'", toString() ) );
500 "More than one valid value parsed from string '" +
501 val +
"'", toString() ) );
503 if ( _constraint != NULL )
504 if ( ! _constraint->check( _value ) )
506 "' does not meet constraint: " +
507 _constraint->description(),
static char delimiter()
The delimiter that separates an argument flag/name from the value.
static bool ignoreRest()
Whether to ignore the rest.
The interface that defines the interaction between the Arg and Constraint.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
T & getValue()
Returns the value of the argument.
void _extractValue(const std::string &val)
Extracts the value from the string.
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
Specialization of longID.
Constraint< T > * _constraint
A Constraint this Arg must conform to.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
A base class that defines the interface for visitors.
T _value
The value parsed from the command line.
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
ValueArg(const std::string &flag, const std::string &name, const std::string &desc, bool req, T value, const std::string &typeDesc, Visitor *v=NULL)
Labeled ValueArg constructor.
virtual void add(Arg &a)=0
Adds an argument to the list of arguments to be parsed.
std::string _typeDesc
A human readable description of the type to be parsed.
A virtual base class that defines the essential data for all arguments.
The basic labeled argument that parses a value.
virtual std::string shortID(const std::string &val="val") const
Specialization of shortID.
Page generated by Doxygen 1.8.17 for MRPT 1.4.0 SVN: at Sat Jan 18 22:37:07 UTC 2020 | | |