24 #ifndef DtCmdLine_SWITCH_ARG_H
25 #define DtCmdLine_SWITCH_ARG_H
36 #ifdef DtUSE_UTILITIES_NAMESPACE
37 namespace DtUSE_UTILITIES_NAMESPACE
48 class SwitchArg :
public Arg
78 const std::string& name,
79 const std::string& desc,
98 const std::string& name,
99 const std::string& desc,
113 virtual bool processArg(
int* i, std::vector<std::string>& args);
119 bool combinedSwitchesMatch(std::string& combined);
124 bool getValue()
const;
129 bool getDefault()
const;
140 inline SwitchArg::SwitchArg(
const std::string& flag,
141 const std::string& name,
142 const std::string& desc,
145 :
Arg(flag, name, desc, false, false, v)
147 , myDefault( _default )
151 const std::string& name,
152 const std::string& desc,
156 :
Arg(flag, name, desc, false, false, v)
158 , myDefault( _default )
167 inline SwitchArg::operator
bool() {
return _value; }
182 for (
unsigned int i = 1; i < combinedSwitches.length(); i++ )
183 if ( !
_flag.empty() && combinedSwitches[i] ==
_flag[0] )
236 #ifdef DtUSE_UTILITIES_NAMESPACE
A base class that defines the interface for visitors.
Definition: cmdVisitor.h:41
static const char blankChar()
The char used as a place holder when SwitchArgs are combined.
Definition: cmdArg.h:191
A simple switch argument.
Definition: cmdSwitchArg.h:49
bool combinedSwitchesMatch(std::string &combined)
Checks a string to see if any of the chars in the string match the flag for this Switch.
Definition: cmdSwitchArg.h:169
bool getDefault() const
Returns bool, the default value.
Definition: cmdSwitchArg.h:165
This file declares classes for VR-Link command line parsing utility.
bool _ignoreable
Whether this argument can be ignored, if desired.
Definition: cmdArg.h:125
bool _value
The value of the switch.
Definition: cmdSwitchArg.h:56
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the argument.
Definition: cmdSwitchArg.h:198
SwitchArg(const std::string &flag, const std::string &name, const std::string &desc, bool def, Visitor *v=NULL)
SwitchArg constructor.
Definition: cmdSwitchArg.h:140
bool myDefault
The default value of the switch.
Definition: cmdSwitchArg.h:61
bool _alreadySet
Indicates whether the argument has been set.
Definition: cmdArg.h:112
static const std::string flagStartString()
The sting that indicates the beginning of a flag.
Definition: cmdArg.h:202
Thrown from CmdLine when the arguments on the command line are not properly specified, e.g.
Definition: cmdArgException.h:153
virtual std::string toString() const
Returns a simple string representation of the argument.
Definition: cmdArg.h:522
static const std::string nameStartString()
The sting that indicates the beginning of a name.
Definition: cmdArg.h:208
static bool ignoreRest()
Whether to ignore the rest.
Definition: cmdArg.h:178
A virtual base class that defines the essential data for all arguments.
Definition: cmdArg.h:48
virtual void add(Arg &a)=0
Adds an argument to the list of arguments to be parsed.
bool getValue() const
Returns bool, whether or not the switch has been set.
Definition: cmdSwitchArg.h:163
The base class that manages the command line definition and passes along the parsing to the appropria...
Definition: cmdLineInterface.h:52
std::string _flag
The single char flag used to identify the argument.
Definition: cmdArg.h:73
void _checkWithVisitor() const
Performs the special handling described by the Vistitor.
Definition: cmdArg.h:534
virtual bool argMatches(const std::string &s) const
A method that tests whether a string matches this argument.
Definition: cmdArg.h:513