23 #ifndef TCLAP_VALUE_ARGUMENT_H 24 #define TCLAP_VALUE_ARGUMENT_H 108 const std::string& name,
109 const std::string& desc,
112 const std::string& typeDesc,
141 const std::string& name,
142 const std::string& desc,
145 const std::string& typeDesc,
172 const std::string& name,
173 const std::string& desc,
202 const std::string& name,
203 const std::string& desc,
218 virtual bool processArg(
int* i, std::vector<std::string>& args);
229 virtual std::string
shortID(
const std::string& val =
"val")
const;
235 virtual std::string
longID(
const std::string& val =
"val")
const;
237 virtual void reset() ;
253 const std::string& name,
254 const std::string& desc,
257 const std::string& typeDesc,
259 :
Arg(flag, name, desc, req, true, v),
262 _typeDesc( typeDesc ),
268 const std::string& name,
269 const std::string& desc,
272 const std::string& typeDesc,
275 :
Arg(flag, name, desc, req, true, v),
278 _typeDesc( typeDesc ),
286 const std::string& name,
287 const std::string& desc,
292 :
Arg(flag, name, desc, req, true, v),
295 _typeDesc( constraint->shortID() ),
296 _constraint( constraint )
301 const std::string& name,
302 const std::string& desc,
308 :
Arg(flag, name, desc, req, true, v),
311 _typeDesc( constraint->shortID() ),
312 _constraint( constraint )
333 if ( _hasBlanks( args[*i] ) )
336 std::string flag = args[*i];
338 std::string value =
"";
339 trimFlag( flag, value );
341 if ( argMatches( flag ) )
347 "Mutually exclusive argument already set!",
356 "Couldn't find delimiter for this argument!",
362 if ( static_cast<unsigned int>(*i) < args.size() )
363 _extractValue( args[*i] );
369 _extractValue( value );
385 static_cast<void>(val);
395 static_cast<void>(val);
408 if ( _constraint != NULL )
409 if ( ! _constraint->check( _value ) )
411 +
"' does not meet constraint: " 412 + _constraint->description(),
void _extractValue(const std::string &val)
Extracts the value from the string.
A virtual base class that defines the essential data for all arguments.
Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
The basic labeled argument that parses a value.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
virtual std::string shortID(const std::string &val="val") const
Specialization of shortID.
T _value
The value parsed from the command line.
The interface that defines the interaction between the Arg and Constraint.
Constraint< T > * _constraint
A Constraint this Arg must conform to.
A base class that defines the interface for visitors.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
The base class that manages the command line definition and passes along the parsing to the appropria...
T & getValue()
Returns the value of the argument.
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.
static bool ignoreRest()
Whether to ignore the rest.
T::ValueCategory ValueCategory
void ExtractValue(T &destVal, const std::string &strVal, ValueLike vl)
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
T _default
Used to support the reset() method so that ValueArg can be reset to their constructed value...
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
virtual std::string longID(const std::string &val="val") const
Specialization of longID.
std::string error() const
Returns the error text.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
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.