25#ifndef TCLAP_VALUE_ARG_H
26#define TCLAP_VALUE_ARG_H
103 ValueArg(
const std::string &flag,
const std::string &name,
104 const std::string &desc,
bool req, T value,
105 const std::string &typeDesc,
Visitor *v = NULL);
128 ValueArg(
const std::string &flag,
const std::string &name,
129 const std::string &desc,
bool req, T value,
152 ValueArg(
const std::string &flag,
const std::string &name,
153 const std::string &desc,
bool req, T value,
175 ValueArg(
const std::string &flag,
const std::string &name,
176 const std::string &desc,
bool req, T value,
188 virtual bool processArg(
int *i, std::vector<std::string> &args);
205 virtual std::string
shortID(
const std::string &val =
"val")
const;
211 virtual std::string
longID(
const std::string &val =
"val")
const;
213 virtual void reset();
216 void _extractNextValue(
int *index, std::vector<std::string> &args);
230 const std::string &desc,
bool req, T val,
231 const std::string &typeDesc,
Visitor *v)
232 :
Arg(flag, name, desc, req, true, v),
240 const std::string &desc,
bool req, T val,
243 :
Arg(flag, name, desc, req, true, v),
253 const std::string &desc,
bool req, T val,
255 :
Arg(flag, name, desc, req, true, v),
258 _typeDesc(
Constraint<T>::shortID(constraint)),
259 _constraint(constraint) {}
263 const std::string &desc,
bool req, T val,
266 :
Arg(flag, name, desc, req, true, v),
269 _typeDesc(
Constraint<T>::shortID(constraint)),
270 _constraint(constraint) {
279 if (_hasBlanks(args[*i]))
return false;
281 std::string flag = args[*i];
283 std::string value =
"";
284 trimFlag(flag, value);
285 const bool hasAttachedValue = flag != args[*i];
287 if (!argMatches(flag))
return false;
293 if (this->getDelimiter() !=
' ' && !hasAttachedValue)
295 "Couldn't find delimiter for this argument!", toString()));
297 if (!hasAttachedValue) {
298 _extractNextValue(i, args);
300 _extractValue(value);
311 std::vector<std::string> &args) {
313 if (
static_cast<unsigned int>(*index) < args.size())
314 _extractValue(args[*index]);
344 if (_constraint != NULL && !_constraint->check(_value))
346 +
"' does not meet constraint: " +
347 _constraint->description(),
Interface that allows adding an Arg to a "container".
virtual ArgContainer & add(Arg &a)=0
Adds an argument.
std::string error() const
Returns the error text.
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
A virtual base class that defines the essential data for all arguments.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
The interface that defines the interaction between the Arg and Constraint.
The basic labeled argument that parses a value.
virtual std::string longID(const std::string &val="val") const
Specialization of longID.
T _default
Used to support the reset() method so that ValueArg can be reset to their constructed value.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
T _value
The value parsed from the command line.
const 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.
std::string _typeDesc
A human readable description of the type to be parsed.
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.
const T & getValue() const
Returns the value of the argument.
void _extractValue(const std::string &val)
Extracts the value from the string.
virtual std::string shortID(const std::string &val="val") const
Specialization of shortID.
A base class that defines the interface for visitors.
void ExtractValue(T &destVal, const std::string &strVal, ValueLike vl)
A value like argument value type is a value that can be set using operator>>.