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 )
190 void _extractValue(
const std::string& val );
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),
386 const std::string& name,
387 const std::string& desc,
392 :
Arg(flag, name, desc, req, true, v),
400 const std::string& name,
401 const std::string& desc,
407 :
Arg(flag, name, desc, req, true, v),
434 std::string flag = args[*i];
436 std::string value =
"";
446 "Couldn't find delimiter for this argument!",
452 if ( static_cast<unsigned int>(*i) < args.size() )
500 "More than one valid value parsed from string '" +
506 "' does not meet constraint: " +
Constraint< T > * _constraint
A Constraint this Arg must conform to.
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
virtual std::string toString() const
Returns a simple string representation of the argument.
std::string _typeDesc
A human readable description of the type to be parsed.
virtual std::string shortID(const std::string &val="val") const
Specialization of shortID.
A virtual base class that defines the essential data for all arguments.
virtual std::string longID(const std::string &val="val") const
Specialization of longID.
virtual void add(Arg &a)=0
Adds an argument to the list of arguments to be parsed.
void _checkWithVisitor() const
Performs the special handling described by the Vistitor.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
bool _alreadySet
Indicates whether the argument has been set.
bool _hasBlanks(const std::string &s) const
Checks whether a given string has blank chars, indicating that it is a combined SwitchArg.
T & getValue()
Returns the value of the argument.
Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.
virtual void trimFlag(std::string &flag, std::string &value) const
Trims a value off of the flag.
A base class that defines the interface for visitors.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
void _extractValue(const std::string &val)
Extracts the value from the string.
The basic labeled argument that parses a value.
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
bool _ignoreable
Whether this argument can be ignored, if desired.
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 bool argMatches(const std::string &s) const
A method that tests whether a string matches this argument.
static bool ignoreRest()
Whether to ignore the rest.
T _value
The value parsed from the command line.
The interface that defines the interaction between the Arg and Constraint.
The base class that manages the command line definition and passes along the parsing to the appropria...