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++ )
(Added by JLBC for MRPT): An exception that indicates to CmdLine::parse that help,...
A simple class that defines and argument exception.
A virtual base class that defines the essential data for all arguments.
static char blankChar()
The char used as a place holder when SwitchArgs are combined.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
static bool ignoreRest()
Whether to ignore the rest.
static const std::string ignoreNameString()
The name used to identify the ignore rest argument.
static char flagStartChar()
The char that indicates the beginning of a flag.
virtual void addToList(std::list< Arg * > &argList) const
Adds this to the specified list of Args.
static void setDelimiter(char c)
Sets the delimiter for all arguments.
virtual bool isRequired() const
Indicates whether the argument is required.
static const std::string flagStartString()
The sting that indicates the beginning of a flag.
The base class that manages the command line definition and passes along the parsing to the appropria...
bool _emptyCombined(const std::string &s)
Checks whether a name/flag string matches entirely matches the Arg::blankChar.
int _numRequired
The number of arguments that are required to be present on the command line.
std::string _version
The version to be displayed with the –version switch.
XorHandler _xorHandler
The handler that manages xoring lists of args.
std::list< Arg * > & getArgList()
Returns the argList.
std::string _message
A message used to describe the program.
char getDelimiter()
Returns the delimiter string.
void deleteOnExit(Arg *ptr)
Perform a delete ptr; operation on ptr when this object is deleted.
void setOutput(CmdLineOutput *co)
std::string & getProgramName()
Returns the program name string.
std::list< Arg * > _argList
The list of arguments that will be tested against the command line.
CmdLineOutput * _output
Object that handles all output for the CmdLine.
bool hasHelpAndVersion()
Indicates whether or not the help and version switches were created automatically.
char _delimiter
The character that is used to separate the argument flag/name from the value.
CmdLine(const std::string &message, const char delimiter=' ', const std::string &version="none", bool helpAndVersion=true)
Command line constructor.
std::list< Visitor * > _visitorDeleteOnExitList
A list of Visitors to be explicitly deleted when the destructor is called.
XorHandler & getXorHandler()
Returns the XorHandler.
std::string & getVersion()
Returns the version string.
virtual ~CmdLine()
Deletes any resources allocated by a CmdLine object.
std::string _progName
The name of the program.
std::string & getMessage()
Returns the message string.
void add(Arg &a)
Adds an argument to the list of arguments to be parsed.
void _constructor()
Encapsulates the code common to the constructors (which is all of it).
bool _userSetOutput
Is set to true when a user sets the output object.
CmdLineOutput * getOutput()
Returns the CmdLineOutput object.
bool _helpAndVersion
Whether or not to automatically create help and version switches.
bool parse(int argc, char **argv)
Parses the command line.
std::list< Arg * > _argDeleteOnExitList
A list of Args to be explicitly deleted when the destructor is called.
void xorAdd(Arg &a, Arg &b)
Add two Args that will be xor'd.
The base class that manages the command line definition and passes along the parsing to the appropria...
The interface that any output object must implement.
virtual void failure(CmdLineInterface &c, ArgException &e)=0
Generates some sort of output for a failure.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
A Visitor object that calls the usage method of the given CmdLineOutput object for the specified CmdL...
A Vistor that tells the CmdLine to begin ignoring arguments after this one is parsed.
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
A class that isolates any output from the CmdLine object so that it may be easily modified.
A simple switch argument.
A Vistor that will call the version method of the given CmdLineOutput for the specified CmdLine objec...
A base class that defines the interface for visitors.
This class handles lists of Arg's that are to be XOR'd on the command line.
int check(const Arg *a)
Checks whether the specified Arg is in one of the xor lists and if it does match one,...
void add(std::vector< Arg * > &ors)
Add a list of Arg*'s that will be orred together.
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
std::list< Visitor * >::iterator VisitorListIterator
Typedef of a Visitor list iterator.
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.