11 #ifndef TCLAP_MULTIPLE_ARGUMENT_H 12 #define TCLAP_MULTIPLE_ARGUMENT_H 27 #if defined(HAVE_SSTREAM) 29 #elif defined(HAVE_STRSTREAM) 32 #error "Need a stringstream (sstream or strstream) to compile!" 39 namespace MULTI_ARG_HELPER {
80 #if defined(HAVE_SSTREAM) 81 std::istringstream is(val);
82 #elif defined(HAVE_STRSTREAM) 83 std::istrstream is(val.c_str());
85 #error "Need a stringstream (sstream or strstream) to compile!" 92 if ( is.peek() != EOF )
103 if ( valuesRead > 1 )
106 _values.push_back(temp);
181 void _extractValue(
const std::string& val );
205 const std::string& name,
206 const std::string& desc,
208 const std::string& typeDesc,
230 const std::string& name,
231 const std::string& desc,
233 const std::string& typeDesc,
253 const std::string& name,
254 const std::string& desc,
276 const std::string& name,
277 const std::string& desc,
291 virtual bool processArg(
int* i, std::vector<std::string>& args);
297 const std::vector<T>& getValue();
303 virtual std::string shortID(
const std::string& val=
"val")
const;
309 virtual std::string longID(
const std::string& val=
"val")
const;
315 virtual bool isRequired()
const;
317 virtual bool allowMore();
323 const std::string& name,
324 const std::string& desc,
326 const std::string& typeDesc,
328 :
Arg( flag, name, desc, req, true, v ),
329 _typeDesc( typeDesc ),
338 const std::string& name,
339 const std::string& desc,
341 const std::string& typeDesc,
344 :
Arg( flag, name, desc, req, true, v ),
358 const std::string& name,
359 const std::string& desc,
363 :
Arg( flag, name, desc, req, true, v ),
373 const std::string& name,
374 const std::string& desc,
379 :
Arg( flag, name, desc, req, true, v ),
400 std::string flag = args[*i];
401 std::string
value =
"";
409 "Couldn't find delimiter for this argument!",
416 if ( static_cast<unsigned int>(*i) < args.size() )
492 "from string '" + val +
"'",
toString() ) );
496 "parsed from string '" + val +
"'",
501 "' does not meet constraint: " +
bool _acceptsMultipleValues
MultiArg(const std::string &flag, const std::string &name, const std::string &desc, bool req, const std::string &typeDesc, Visitor *v=NULL)
Constructor.
void _checkWithVisitor() const
Performs the special handling described by the Vistitor.
An argument that allows multiple values of type T to be specified.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
T value(details::expression_node< T > *n)
const std::vector< T > & getValue()
Returns a vector of type T containing the values parsed from the command line.
std::vector< T > _values
The list of values parsed from the CmdLine.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
virtual bool argMatches(const std::string &s) const
A method that tests whether a string matches this argument.
A virtual base class that defines the essential data for all arguments.
virtual void add(Arg &a)=0
Adds an argument to the list of arguments to be parsed.
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
virtual bool isRequired() const
Once we've matched the first value, then the arg is no longer required.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
bool _alreadySet
Indicates whether the argument has been set.
Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.
A base class that defines the interface for visitors.
virtual std::string longID(const std::string &val="val") const
Returns the a long id string.
std::string _typeDesc
The description of type T to be used in the usage.
virtual void trimFlag(std::string &flag, std::string &value) const
Trims a value off of the flag.
virtual std::string shortID(const std::string &val="val") const
Returns the a short id string.
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.
virtual std::string toString() const
Returns a simple string representation of the argument.
Constraint< T > * _constraint
A list of constraint on this Arg.
void _extractValue(const std::string &val)
Extracts the value from the string.
static bool ignoreRest()
Whether to ignore the rest.
bool _required
Indicating whether the argument is required.
The interface that defines the interaction between the Arg and Constraint.
bool _hasBlanks(const std::string &s) const
Checks whether a given string has blank chars, indicating that it is a combined SwitchArg.
The base class that manages the command line definition and passes along the parsing to the appropria...