#include <CmdLine.h>
Inheritance diagram for TCLAP::CmdLine:
Public Member Functions | ||||
CmdLine (const std::string &message, const char delimiter= ' ', const std::string &version="none", bool helpAndVersion=true) | ||||
Command line constructor. | ||||
virtual | ~CmdLine () | |||
Deletes any resources allocated by a CmdLine object. | ||||
void | add (Arg &a) | |||
Adds an argument to the list of arguments to be parsed. | ||||
void | add (Arg *a) | |||
An alternative add. | ||||
void | xorAdd (Arg &a, Arg &b) | |||
Add two Args that will be xor'd. | ||||
void | xorAdd (std::vector< Arg * > &xors) | |||
Add a list of Args that will be xor'd. | ||||
void | parse (int argc, char **argv) | |||
Parses the command line. | ||||
CmdLineOutput * | getOutput () | |||
Returns the CmdLineOutput object. | ||||
void | setOutput (CmdLineOutput *co) | |||
| ||||
std::string & | getVersion () | |||
Returns the version string. | ||||
std::string & | getProgramName () | |||
Returns the program name string. | ||||
std::list< Arg * > & | getArgList () | |||
Returns the argList. | ||||
XorHandler & | getXorHandler () | |||
Returns the XorHandler. | ||||
char | getDelimiter () | |||
Returns the delimiter string. | ||||
std::string & | getMessage () | |||
Returns the message string. | ||||
bool | hasHelpAndVersion () | |||
Indicates whether or not the help and version switches were created automatically. | ||||
Protected Member Functions | ||||
bool | _emptyCombined (const std::string &s) | |||
Checks whether a name/flag string matches entirely matches the Arg::blankChar. | ||||
void | deleteOnExit (Arg *ptr) | |||
Perform a delete ptr; operation on ptr when this object is deleted. | ||||
void | deleteOnExit (Visitor *ptr) | |||
Perform a delete ptr; operation on ptr when this object is deleted. | ||||
Protected Attributes | ||||
std::list< Arg * > | _argList | |||
The list of arguments that will be tested against the command line. | ||||
std::string | _progName | |||
The name of the program. | ||||
std::string | _message | |||
A message used to describe the program. | ||||
std::string | _version | |||
The version to be displayed with the --version switch. | ||||
int | _numRequired | |||
The number of arguments that are required to be present on the command line. | ||||
char | _delimiter | |||
The character that is used to separate the argument flag/name from the value. | ||||
XorHandler | _xorHandler | |||
The handler that manages xoring lists of args. | ||||
std::list< Arg * > | _argDeleteOnExitList | |||
A list of Args to be explicitly deleted when the destructor is called. | ||||
std::list< Visitor * > | _visitorDeleteOnExitList | |||
A list of Visitors to be explicitly deleted when the destructor is called. | ||||
CmdLineOutput * | _output | |||
Object that handles all output for the CmdLine. |
Definition at line 55 of file CmdLine.h.
TCLAP::CmdLine::CmdLine | ( | const std::string & | message, | |
const char | delimiter = ' ' , |
|||
const std::string & | version = "none" , |
|||
bool | helpAndVersion = true | |||
) | [inline] |
Command line constructor.
Defines how the arguments will be parsed.
message | - The message to be used in the usage output. | |
delimiter | - The character that is used to separate the argument flag/name from the value. Defaults to ' ' (space). | |
version | - The version number to be used in the --version switch. | |
helpAndVersion | - Whether or not to create the Help and Version switches. Defaults to true. |
TCLAP::CmdLine::~CmdLine | ( | ) | [inline, virtual] |
Deletes any resources allocated by a CmdLine object.
Definition at line 278 of file CmdLine.h.
References _argDeleteOnExitList, _output, and _visitorDeleteOnExitList.
bool TCLAP::CmdLine::_emptyCombined | ( | const std::string & | s | ) | [inline, protected] |
Checks whether a name/flag string matches entirely matches the Arg::blankChar.
Used when multiple switches are combined into a single argument.
s | - The message to be used in the usage. |
Definition at line 419 of file CmdLine.h.
References TCLAP::Arg::blankChar(), and TCLAP::Arg::flagStartChar().
Referenced by parse().
void TCLAP::CmdLine::deleteOnExit | ( | Arg * | ptr | ) | [inline, protected] |
Perform a delete ptr; operation on ptr when this object is deleted.
Definition at line 431 of file CmdLine.h.
References _argDeleteOnExitList.
void TCLAP::CmdLine::deleteOnExit | ( | Visitor * | ptr | ) | [inline, protected] |
Perform a delete ptr; operation on ptr when this object is deleted.
Definition at line 436 of file CmdLine.h.
References _visitorDeleteOnExitList.
void TCLAP::CmdLine::add | ( | Arg & | a | ) | [inline, virtual] |
Adds an argument to the list of arguments to be parsed.
a | - Argument to be added. |
Implements TCLAP::CmdLineInterface.
Definition at line 355 of file CmdLine.h.
Referenced by xorAdd().
void TCLAP::CmdLine::add | ( | Arg * | a | ) | [inline, virtual] |
An alternative add.
Functionally identical.
a | - Argument to be added. |
Implements TCLAP::CmdLineInterface.
Definition at line 360 of file CmdLine.h.
References _argList, _numRequired, TCLAP::Arg::addToList(), TCLAP::Arg::isRequired(), and TCLAP::Arg::longID().
Add two Args that will be xor'd.
If this method is used, add does not need to be called.
a | - Argument to be added and xor'd. | |
b | - Argument to be added and xor'd. |
Implements TCLAP::CmdLineInterface.
void TCLAP::CmdLine::xorAdd | ( | std::vector< Arg * > & | xors | ) | [inline, virtual] |
Add a list of Args that will be xor'd.
If this method is used, add does not need to be called.
xors | - List of Args to be added and xor'd. |
Implements TCLAP::CmdLineInterface.
Definition at line 334 of file CmdLine.h.
References _xorHandler, add(), and TCLAP::XorHandler::add().
void TCLAP::CmdLine::parse | ( | int | argc, | |
char ** | argv | |||
) | [inline, virtual] |
Parses the command line.
argc | - Number of arguments. | |
argv | - Array of arguments. |
Implements TCLAP::CmdLineInterface.
Definition at line 374 of file CmdLine.h.
References _argList, _emptyCombined(), _numRequired, _output, _progName, _xorHandler, TCLAP::XorHandler::check(), TCLAP::CmdLineOutput::failure(), and TCLAP::Arg::ignoreRest().
CmdLineOutput * TCLAP::CmdLine::getOutput | ( | ) | [inline, virtual] |
Returns the CmdLineOutput object.
Implements TCLAP::CmdLineInterface.
Definition at line 441 of file CmdLine.h.
References _output.
void TCLAP::CmdLine::setOutput | ( | CmdLineOutput * | co | ) | [inline, virtual] |
co | - CmdLineOutput object that we want to use instead. |
Implements TCLAP::CmdLineInterface.
Definition at line 446 of file CmdLine.h.
References _output.
std::string & TCLAP::CmdLine::getVersion | ( | ) | [inline, virtual] |
Returns the version string.
Implements TCLAP::CmdLineInterface.
Definition at line 452 of file CmdLine.h.
References _version.
std::string & TCLAP::CmdLine::getProgramName | ( | ) | [inline, virtual] |
Returns the program name string.
Implements TCLAP::CmdLineInterface.
Definition at line 457 of file CmdLine.h.
References _progName.
std::list< Arg * > & TCLAP::CmdLine::getArgList | ( | ) | [inline, virtual] |
Returns the argList.
Implements TCLAP::CmdLineInterface.
Definition at line 462 of file CmdLine.h.
References _argList.
XorHandler & TCLAP::CmdLine::getXorHandler | ( | ) | [inline, virtual] |
Returns the XorHandler.
Implements TCLAP::CmdLineInterface.
Definition at line 467 of file CmdLine.h.
References _xorHandler.
char TCLAP::CmdLine::getDelimiter | ( | ) | [inline, virtual] |
Returns the delimiter string.
Implements TCLAP::CmdLineInterface.
Definition at line 472 of file CmdLine.h.
References _delimiter.
std::string & TCLAP::CmdLine::getMessage | ( | ) | [inline, virtual] |
Returns the message string.
Implements TCLAP::CmdLineInterface.
Definition at line 477 of file CmdLine.h.
References _message.
bool TCLAP::CmdLine::hasHelpAndVersion | ( | ) | [inline, virtual] |
Indicates whether or not the help and version switches were created automatically.
Implements TCLAP::CmdLineInterface.
std::list<Arg*> TCLAP::CmdLine::_argList [protected] |
The list of arguments that will be tested against the command line.
Definition at line 63 of file CmdLine.h.
Referenced by add(), getArgList(), and parse().
std::string TCLAP::CmdLine::_progName [protected] |
The name of the program.
Set to argv[0].
Definition at line 68 of file CmdLine.h.
Referenced by getProgramName(), and parse().
std::string TCLAP::CmdLine::_message [protected] |
A message used to describe the program.
Used in the usage output.
Definition at line 73 of file CmdLine.h.
Referenced by getMessage().
std::string TCLAP::CmdLine::_version [protected] |
The version to be displayed with the --version switch.
Definition at line 78 of file CmdLine.h.
Referenced by getVersion().
int TCLAP::CmdLine::_numRequired [protected] |
char TCLAP::CmdLine::_delimiter [protected] |
The character that is used to separate the argument flag/name from the value.
Defaults to ' ' (space).
Definition at line 91 of file CmdLine.h.
Referenced by getDelimiter().
XorHandler TCLAP::CmdLine::_xorHandler [protected] |
The handler that manages xoring lists of args.
Definition at line 96 of file CmdLine.h.
Referenced by getXorHandler(), parse(), and xorAdd().
std::list<Arg*> TCLAP::CmdLine::_argDeleteOnExitList [protected] |
A list of Args to be explicitly deleted when the destructor is called.
At the moment, this only includes the three default Args.
Definition at line 103 of file CmdLine.h.
Referenced by deleteOnExit(), and ~CmdLine().
std::list<Visitor*> TCLAP::CmdLine::_visitorDeleteOnExitList [protected] |
A list of Visitors to be explicitly deleted when the destructor is called.
At the moment, these are the Vistors created for the default Args.
Definition at line 110 of file CmdLine.h.
Referenced by deleteOnExit(), and ~CmdLine().
CmdLineOutput* TCLAP::CmdLine::_output [protected] |
Object that handles all output for the CmdLine.
Definition at line 115 of file CmdLine.h.
Referenced by getOutput(), parse(), setOutput(), and ~CmdLine().