Go to the documentation of this file.
31 #ifndef TCLAP_CMDLINE_H
32 #define TCLAP_CMDLINE_H
176 CmdLine(
const std::string& message,
177 const char delimiter =
' ',
178 const std::string& version =
"none",
179 bool helpAndVersion =
true);
211 void xorAdd( std::vector<Arg*>& xors );
219 bool parse(
int argc,
char** argv);
274 const std::string& v,
276 : _progName(
"not_set_yet"),
281 _userSetOutput(false),
282 _helpAndVersion(help)
318 "Displays usage information and exits.",
326 "Displays version information and exits.",
336 "Ignores the rest of the labeled arguments following this flag.",
349 (*it)->forceRequired();
350 (*it)->setRequireLabel(
"OR required" );
358 std::vector<Arg*> ors;
374 "Argument with same flag/name already exists!",
390 std::vector<std::string> args;
391 for (
int i = 1; i < argc; i++)
392 args.push_back(argv[i]);
394 int requiredCount = 0;
396 for (
int i = 0;
static_cast<unsigned int>(i) < args.size(); i++)
398 bool matched =
false;
401 if ( (*it)->processArg( &i, args ) )
444 for (
int i = 1;
static_cast<unsigned int>(i) < s.length(); i++ )
CmdLineOutput * getOutput()
Returns the CmdLineOutput object.
char getDelimiter()
Returns the delimiter string.
void add(Arg &a)
Adds an argument to the list of arguments to be parsed.
The base class that manages the command line definition and passes along the parsing to the appropria...
(Added by JLBC for MRPT): An exception that indicates to CmdLine::parse that help,...
static const std::string flagStartString()
The sting that indicates the beginning of a flag.
static bool ignoreRest()
Whether to ignore the rest.
void deleteOnExit(Arg *ptr)
Perform a delete ptr; operation on ptr when this object is deleted.
std::list< Visitor * >::iterator VisitorListIterator
Typedef of a Visitor list iterator.
CmdLine(const std::string &message, const char delimiter=' ', const std::string &version="none", bool helpAndVersion=true)
Command line constructor.
This class handles lists of Arg's that are to be XOR'd on the command line.
virtual bool isRequired() const
Indicates whether the argument is required.
A Visitor object that calls the usage method of the given CmdLineOutput object for the specified CmdL...
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.
A simple switch argument.
void _constructor()
Encapsulates the code common to the constructors (which is all of it).
char _delimiter
The character that is used to separate the argument flag/name from the value.
The interface that any output object must implement.
bool _helpAndVersion
Whether or not to automatically create help and version switches.
void add(std::vector< Arg * > &ors)
Add a list of Arg*'s that will be orred together.
std::string _progName
The name of the program.
static const std::string ignoreNameString()
The name used to identify the ignore rest argument.
std::string _message
A message used to describe the program.
A simple class that defines and argument exception.
The base class that manages the command line definition and passes along the parsing to the appropria...
bool _userSetOutput
Is set to true when a user sets the output object.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
XorHandler _xorHandler
The handler that manages xoring lists of args.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
bool parse(int argc, char **argv)
Parses the command line.
A base class that defines the interface for visitors.
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
static char flagStartChar()
The char that indicates the beginning of a flag.
std::list< Visitor * > _visitorDeleteOnExitList
A list of Visitors to be explicitly deleted when the destructor is called.
A virtual base class that defines the essential data for all arguments.
XorHandler & getXorHandler()
Returns the XorHandler.
A Vistor that will call the version method of the given CmdLineOutput for the specified CmdLine objec...
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.
virtual ~CmdLine()
Deletes any resources allocated by a CmdLine object.
void xorAdd(Arg &a, Arg &b)
Add two Args that will be xor'd.
std::list< Arg * > _argDeleteOnExitList
A list of Args to be explicitly deleted when the destructor is called.
std::string & getProgramName()
Returns the program name string.
std::list< Arg * > & getArgList()
Returns the argList.
std::string & getMessage()
Returns the message string.
virtual void addToList(std::list< Arg * > &argList) const
Adds this to the specified list of Args.
A class that isolates any output from the CmdLine object so that it may be easily modified.
void setOutput(CmdLineOutput *co)
CmdLineOutput * _output
Object that handles all output for the CmdLine.
std::list< Arg * > _argList
The list of arguments that will be tested against the command line.
virtual void failure(CmdLineInterface &c, ArgException &e)=0
Generates some sort of output for a failure.
int _numRequired
The number of arguments that are required to be present on the command line.
A Vistor that tells the CmdLine to begin ignoring arguments after this one is parsed.
std::string & getVersion()
Returns the version string.
std::string _version
The version to be displayed with the –version switch.
int check(const Arg *a)
Checks whether the specified Arg is in one of the xor lists and if it does match one,...
bool hasHelpAndVersion()
Indicates whether or not the help and version switches were created automatically.
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
bool _emptyCombined(const std::string &s)
Checks whether a name/flag string matches entirely matches the Arg::blankChar.
Page generated by Doxygen 1.8.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020 | | |