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