28 #ifdef HAVE_TCLAP_CONFIG_H 29 #include <tclap/TCLAPConfig.h> 63 Arg &operator=(
const Arg &rhs);
69 static char &delimiterRef() {
70 static char delim =
' ';
167 Arg(
const std::string &flag,
const std::string &name,
168 const std::string &desc,
bool req,
bool valreq,
Visitor *v = NULL);
180 virtual void addToList(std::list<Arg *> &argList)
const;
198 #ifndef TCLAP_FLAGSTARTCHAR 199 #define TCLAP_FLAGSTARTCHAR '-' 208 #ifndef TCLAP_FLAGSTARTSTRING 209 #define TCLAP_FLAGSTARTSTRING "-" 217 #ifndef TCLAP_NAMESTARTSTRING 218 #define TCLAP_NAMESTARTSTRING "--" 240 virtual bool processArg(
int *i, std::vector<std::string> &args) = 0;
252 const std::string &
getFlag()
const;
257 const std::string &
getName()
const;
271 return (required ?
"(" + _requireLabel +
") " :
"") +
_description;
308 virtual bool argMatches(
const std::string &s)
const;
314 virtual std::string
toString()
const;
320 virtual std::string
shortID(
const std::string &valueId =
"val")
const;
326 virtual std::string
longID(
const std::string &valueId =
"val")
const;
335 virtual void trimFlag(std::string &flag, std::string &value)
const;
361 virtual void reset();
367 virtual void hideFromHelp(
bool hide =
true) { _visibleInHelp = !hide; }
398 template <
typename T>
400 static_cast<void>(vl);
405 if (is.peek() != EOF)
406 #ifdef TCLAP_SETBASE_ZERO
407 is >> std::setbase(0) >> destVal;
436 template <
typename T>
438 static_cast<void>(sl);
446 inline Arg::Arg(
const std::string &flag,
const std::string &name,
447 const std::string &desc,
bool req,
bool valreq,
Visitor *v)
460 if (
_flag.length() > 1)
462 "Argument flag can only be one character long",
toString()));
476 (
_name.find(
" ", 0) != std::string::npos))
498 inline std::string
Arg::longID(
const std::string &valueId)
const {
562 for (
int i = 0;
static_cast<unsigned int>(i) < flag.length(); i++)
569 value = flag.substr(stop + 1);
570 flag = flag.substr(0, stop);
578 for (
int i = 1;
static_cast<unsigned int>(i) < s.length(); i++)
588 argList.push_front(const_cast<Arg *>(
this));
603 #endif // TCLAP_ARG_H std::vector< Arg * >::const_iterator ArgVectorIterator
Typedef of an Arg vector iterator.
virtual bool argMatches(const std::string &s) const
A method that tests whether a string matches this argument.
bool _alreadySet
Indicates whether the argument has been set.
bool _valueRequired
Indicates whether a value is required for the argument.
A virtual base class that defines the essential data for all arguments.
virtual void visit()=0
This method (to implemented by children) will be called when the visitor is visited.
void SetString(T &dst, const std::string &src)
virtual void addToList(std::list< Arg *> &argList) const
Adds this to the specified list of Args.
A value like argument value type is a value that can be set using operator>>.
static char flagStartChar()
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
std::istringstream istringstream
bool isSet() const
Indicates whether the argument has already been set.
virtual bool hasLabel() const
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
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 ~Arg()
Destructor.
virtual void hideFromHelp(bool hide=true)
Hide this argument from the help output (e.g., when specifying the –help flag or on error...
std::list< Visitor * >::const_iterator VisitorListIterator
Typedef of a Visitor list iterator.
#define TCLAP_FLAGSTARTCHAR
The char that indicates the beginning of a flag.
A string like argument value type is a value that can be set using operator=(string).
virtual bool isRequired() const
Indicates whether the argument is required.
Visitor * _visitor
A pointer to a visitor object.
const bool _required
Indicating whether the argument is required.
virtual bool visibleInHelp() const
Returns true if this Arg is visible in the help output.
void _checkWithVisitor() const
Performs the special handling described by the Visitor.
static const std::string ignoreNameString()
The name used to identify the ignore rest argument.
static const std::string nameStartString()
#define TCLAP_NAMESTARTSTRING
The sting that indicates the beginning of a name.
A base class that defines the interface for visitors.
const std::string & getName() const
Returns the argument name.
std::string _description
Description of the argument.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
virtual std::string toString() const
Returns a simple string representation of the argument.
bool isValueRequired() const
Indicates whether a value must be specified for argument.
virtual bool acceptsMultipleValues()
Use by output classes to determine whether an Arg accepts multiple values.
bool _ignoreable
Whether this argument can be ignored, if desired.
virtual bool processArg(int *i, std::vector< std::string > &args)=0
Pure virtual method meant to handle the parsing and value assignment of the string on the command lin...
virtual bool operator==(const Arg &a) const
Operator ==.
bool isIgnoreable() const
Indicates whether the argument can be ignored, if desired.
std::string getDescription() const
Returns the argument description.
const std::string & getFlag() const
Returns the argument flag.
void ExtractValue(T &destVal, const std::string &strVal, ValueLike vl)
bool _visibleInHelp
Indicates if the argument is visible in the help output (e.g., when specifying –help).
std::string _name
A single word namd identifying the argument.
std::string getDescription(bool required) const
Returns the argument description.
static char blankChar()
The char used as a place holder when SwitchArgs are combined.
std::string _flag
The single char flag used to identify the argument.
bool _acceptsMultipleValues
Thrown from within the child Arg classes when it fails to properly parse the argument it has been pas...
std::list< Arg * >::const_iterator ArgListIterator
Typedef of an Arg list iterator.
virtual bool allowMore()
Used for MultiArgs to determine whether args can still be set.
const std::string & setBy() const
Returns the value specified to set this flag (like -a or –all).
bool _hasBlanks(const std::string &s) const
Checks whether a given string has blank chars, indicating that it is a combined SwitchArg.
#define TCLAP_FLAGSTARTSTRING
The sting that indicates the beginning of a flag.
std::string _setBy
Indicates the value specified to set this flag (like -a or –all).
std::string _requireLabel
Label to be used in usage description.
static const std::string flagStartString()
virtual void trimFlag(std::string &flag, std::string &value) const
Trims a value off of the flag.
static void setDelimiter(char c)
Sets the delimiter for all arguments.