Go to the documentation of this file.
31 #ifndef TCLAP_CMDLINE_H
32 #define TCLAP_CMDLINE_H
63 class CmdLine :
public CmdLineInterface
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;
373 throw( SpecificationException(
374 "Argument with same flag/name already exists!",
379 if ( a->isRequired() )
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 ) )
415 throw(CmdLineParseException(
"Couldn't find match for argument",
420 throw(CmdLineParseException(
"One or more required arguments missing!"));
423 throw(CmdLineParseException(
"Too many arguments!"));
428 catch ( ActionDoneException e )
432 catch ( ArgException e )
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.
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.
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.
bool _userSetOutput
Is set to true when a user sets the output object.
XorHandler _xorHandler
The handler that manages xoring lists of args.
bool parse(int argc, char **argv)
Parses the command line.
A base class that defines the interface for visitors.
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.
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.16 for MRPT 1.4.0 SVN: at Mon Oct 14 23:11:08 UTC 2019 | | |