Go to the documentation of this file.
32 #ifndef TCLAP_ARGUMENT_H
33 #define TCLAP_ARGUMENT_H
58 static bool&
ignoreRestRef() {
static bool ign =
false;
return ign; }
64 static char&
delimiterRef() {
static char delim =
' ';
return delim; }
156 Arg(
const std::string& flag,
157 const std::string& name,
158 const std::string& desc,
173 virtual void addToList( std::list<Arg*>& argList )
const;
233 virtual bool processArg(
int *i, std::vector<std::string>& args) = 0;
245 const std::string&
getFlag()
const;
250 const std::string&
getName()
const;
298 virtual bool argMatches(
const std::string& s )
const;
304 virtual std::string
toString()
const;
310 virtual std::string
shortID(
const std::string& valueId =
"val" )
const;
316 virtual std::string
longID(
const std::string& valueId =
"val" )
const;
325 virtual void trimFlag( std::string& flag, std::string& value )
const;
333 bool _hasBlanks(
const std::string& s )
const;
367 inline Arg::Arg(
const std::string& flag,
368 const std::string& name,
369 const std::string& desc,
377 _requireLabel(
"required"),
378 _valueRequired(valreq),
383 _acceptsMultipleValues(false)
385 if ( _flag.length() > 1 )
387 "Argument flag can only be one character long", toString() ) );
389 if ( _name != ignoreNameString() &&
400 ( _name.find(
" ", 0 ) != std::string::npos ) )
410 inline std::string
Arg::shortID(
const std::string& valueId )
const
419 std::string delim =
" ";
423 id += delim +
"<" + valueId +
">";
431 inline std::string
Arg::longID(
const std::string& valueId )
const
440 id +=
" <" + valueId +
">";
448 id +=
" <" + valueId +
">";
464 std::string desc =
"";
528 inline void Arg::trimFlag(std::string& flag, std::string& value)
const
531 for (
int i = 0; static_cast<unsigned int>(i) < flag.length(); i++ )
540 value = flag.substr(stop+1);
541 flag = flag.substr(0,stop);
551 for (
int i = 1; static_cast<unsigned int>(i) < s.length(); i++ )
574 argList.push_front( const_cast<Arg*>(
this) );
virtual void visit()
Does nothing.
bool isValueRequired() const
Indicates whether a value must be specified for argument.
static bool & ignoreRestRef()
Indicates whether the rest of the arguments should be ignored.
void setRequireLabel(const std::string &s)
Sets the requireLabel.
virtual bool argMatches(const std::string &s) const
A method that tests whether a string matches this argument.
static char delimiter()
The delimiter that separates an argument flag/name from the value.
static void beginIgnoring()
Begin ignoring arguments since the "--" argument was specified.
bool isSet() const
Indicates whether the argument has already been set.
static const std::string flagStartString()
The sting that indicates the beginning of a flag.
static bool ignoreRest()
Whether to ignore the rest.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
std::string _name
A single work namd indentifying the argument.
std::list< Visitor * >::iterator VisitorListIterator
Typedef of a Visitor list iterator.
bool _required
Indicating whether the argument is required.
bool _xorSet
Indicates that the arg was set as part of an XOR and not on the command line.
virtual bool isRequired() const
Indicates whether the argument is required.
static void setDelimiter(char c)
Sets the delimiter for all arguments.
static char blankChar()
The char used as a place holder when SwitchArgs are combined.
static const std::string ignoreNameString()
The name used to identify the ignore rest argument.
static char & delimiterRef()
The delimiter that separates an argument flag/name from the value.
std::string _requireLabel
Label to be used in usage description.
bool isIgnoreable() const
Indicates whether the argument can be ignored, if desired.
Visitor * _visitor
A pointer to a vistitor object.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
A base class that defines the interface for visitors.
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
bool _ignoreable
Whether this argument can be ignored, if desired.
std::string _flag
The single char flag used to identify the argument.
static char flagStartChar()
The char that indicates the beginning of a flag.
std::string _description
Description of the argument.
void _checkWithVisitor() const
Performs the special handling described by the Vistitor.
virtual ~Arg()
Destructor.
const std::string & getFlag() const
Returns the argument flag.
A virtual base class that defines the essential data for all arguments.
bool _valueRequired
Indicates whether a value is required for the argument.
static const std::string nameStartString()
The sting that indicates the beginning of a name.
bool _hasBlanks(const std::string &s) const
Checks whether a given string has blank chars, indicating that it is a combined SwitchArg.
virtual bool acceptsMultipleValues()
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.
void forceRequired()
Sets _required to true.
void xorSet()
Sets the _alreadySet value to true.
virtual std::string toString() const
Returns a simple string representation of the argument.
bool _alreadySet
Indicates whether the argument has been set.
virtual void trimFlag(std::string &flag, std::string &value) const
Trims a value off of the flag.
std::string getDescription() const
Returns the argument description.
virtual void addToList(std::list< Arg * > &argList) const
Adds this to the specified list of Args.
const std::string & getName() const
Returns the argument name.
bool _acceptsMultipleValues
Arg(const std::string &flag, const std::string &name, const std::string &desc, bool req, bool valreq, Visitor *v=NULL)
Primary constructor.
virtual bool operator==(const Arg &a) const
Operator ==.
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...
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 23:08:25 UTC 2019 | | |