25 #ifndef TCLAP_SWITCH_ARG_H 26 #define TCLAP_SWITCH_ARG_H 66 SwitchArg(
const std::string &flag,
const std::string &name,
67 const std::string &desc,
bool def =
false,
Visitor *v = NULL);
82 SwitchArg(
const std::string &flag,
const std::string &name,
83 const std::string &desc,
ArgContainer &parser,
bool def =
false,
94 virtual bool processArg(
int *i, std::vector<std::string> &args);
114 virtual void reset();
121 bool lastCombined(std::string &combined);
126 void commonProcessing();
133 const std::string &desc,
bool default_val,
135 :
Arg(flag, name, desc, false, false, v),
142 :
Arg(flag, name, desc, false, false, v),
148 inline bool SwitchArg::lastCombined(std::string &combinedSwitches) {
149 for (
unsigned int i = 1; i < combinedSwitches.length(); i++)
157 if (combinedSwitches.length() > 0 &&
167 if (combinedSwitches.find_first_of(
Arg::delimiter()) != std::string::npos)
172 for (
unsigned int i = 1; i < combinedSwitches.length(); i++) {
173 if (
_flag.length() > 0 && combinedSwitches[i] ==
_flag[0] &&
189 inline void SwitchArg::commonProcessing() {
222 return lastCombined(args[*i]);
235 #endif // TCLAP_SWITCH_ARG_H bool getValue() const
Returns bool, whether or not the switch has been set.
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.
virtual ArgContainer & add(Arg &a)=0
Adds an argument.
bool combinedSwitchesMatch(std::string &combined)
Checks a string to see if any of the chars in the string match the flag for this Switch.
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.
A simple switch argument.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
bool _value
The value of the switch.
bool _default
Used to support the reset() method so that ValueArg can be reset to their constructed value...
void _checkWithVisitor() const
Performs the special handling described by the Visitor.
static const std::string nameStartString()
Interface that allows adding an Arg to a "container".
A base class that defines the interface for visitors.
virtual std::string toString() const
Returns a simple string representation of the argument.
virtual void reset()
Clears the Arg object and allows it to be reused by new command lines.
static char blankChar()
The char used as a place holder when SwitchArgs are combined.
SwitchArg(const std::string &flag, const std::string &name, const std::string &desc, bool def=false, Visitor *v=NULL)
SwitchArg constructor.
std::string _flag
The single char flag used to identify the argument.
std::string _setBy
Indicates the value specified to set this flag (like -a or –all).
static const std::string flagStartString()