Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
TCLAP::CmdLine Class Reference

Detailed Description

The base class that manages the command line definition and passes along the parsing to the appropriate Arg classes.

Definition at line 81 of file CmdLine.h.

#include <mrpt/otherlibs/tclap/CmdLine.h>

Inheritance diagram for TCLAP::CmdLine:
Inheritance graph

Public Member Functions

 CmdLine (const std::string &message, const char delimiter=' ', const std::string &version="none", bool helpAndVersion=true)
 Command line constructor. More...
 
virtual ~CmdLine ()
 Deletes any resources allocated by a CmdLine object. More...
 
void add (Arg &a)
 Adds an argument to the list of arguments to be parsed. More...
 
void add (Arg *a)
 An alternative add. More...
 
void xorAdd (Arg &a, Arg &b)
 Add two Args that will be xor'd. More...
 
void xorAdd (std::vector< Arg * > &xors)
 Add a list of Args that will be xor'd. More...
 
bool parse (int argc, char **argv)
 Parses the command line. More...
 
CmdLineOutputgetOutput ()
 Returns the CmdLineOutput object. More...
 
void setOutput (CmdLineOutput *co)
 
std::string & getVersion ()
 Returns the version string. More...
 
std::string & getProgramName ()
 Returns the program name string. More...
 
std::list< Arg * > & getArgList ()
 Returns the argList. More...
 
XorHandlergetXorHandler ()
 Returns the XorHandler. More...
 
char getDelimiter ()
 Returns the delimiter string. More...
 
std::string & getMessage ()
 Returns the message string. More...
 
bool hasHelpAndVersion ()
 Indicates whether or not the help and version switches were created automatically. More...
 

Protected Member Functions

bool _emptyCombined (const std::string &s)
 Checks whether a name/flag string matches entirely matches the Arg::blankChar. More...
 
void deleteOnExit (Arg *ptr)
 Perform a delete ptr; operation on ptr when this object is deleted. More...
 
void deleteOnExit (Visitor *ptr)
 Perform a delete ptr; operation on ptr when this object is deleted. More...
 

Protected Attributes

std::list< Arg * > _argList
 The list of arguments that will be tested against the command line. More...
 
std::string _progName
 The name of the program. More...
 
std::string _message
 A message used to describe the program. More...
 
std::string _version
 The version to be displayed with the –version switch. More...
 
int _numRequired
 The number of arguments that are required to be present on the command line. More...
 
char _delimiter
 The character that is used to separate the argument flag/name from the value. More...
 
XorHandler _xorHandler
 The handler that manages xoring lists of args. More...
 
std::list< Arg * > _argDeleteOnExitList
 A list of Args to be explicitly deleted when the destructor is called. More...
 
std::list< Visitor * > _visitorDeleteOnExitList
 A list of Visitors to be explicitly deleted when the destructor is called. More...
 
CmdLineOutput_output
 Object that handles all output for the CmdLine. More...
 

Private Member Functions

void _constructor ()
 Encapsulates the code common to the constructors (which is all of it). More...
 

Private Attributes

bool _userSetOutput
 Is set to true when a user sets the output object. More...
 
bool _helpAndVersion
 Whether or not to automatically create help and version switches. More...
 

Constructor & Destructor Documentation

◆ CmdLine()

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.

Parameters
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.

Definition at line 290 of file CmdLine.h.

◆ ~CmdLine()

TCLAP::CmdLine::~CmdLine ( )
inlinevirtual

Deletes any resources allocated by a CmdLine object.

Definition at line 305 of file CmdLine.h.

References _delimiter, _helpAndVersion, _output, add(), deleteOnExit(), and TCLAP::Arg::setDelimiter().

Member Function Documentation

◆ _constructor()

void TCLAP::CmdLine::_constructor ( )
inlineprivate

Encapsulates the code common to the constructors (which is all of it).

Definition at line 324 of file CmdLine.h.

◆ _emptyCombined()

bool TCLAP::CmdLine::_emptyCombined ( const std::string &  s)
inlineprotected

Checks whether a name/flag string matches entirely matches the Arg::blankChar.

Used when multiple switches are combined into a single argument.

Parameters
s- The message to be used in the usage.

Definition at line 457 of file CmdLine.h.

References _visitorDeleteOnExitList.

◆ add() [1/2]

void TCLAP::CmdLine::add ( Arg a)
inlinevirtual

Adds an argument to the list of arguments to be parsed.

Parameters
a- Argument to be added.

Implements TCLAP::CmdLineInterface.

Definition at line 382 of file CmdLine.h.

Referenced by ~CmdLine().

◆ add() [2/2]

void TCLAP::CmdLine::add ( Arg a)
inlinevirtual

An alternative add.

Functionally identical.

Parameters
a- Argument to be added.

Implements TCLAP::CmdLineInterface.

Definition at line 387 of file CmdLine.h.

References _argList.

◆ deleteOnExit() [1/2]

void TCLAP::CmdLine::deleteOnExit ( Arg ptr)
inlineprotected

Perform a delete ptr; operation on ptr when this object is deleted.

Definition at line 469 of file CmdLine.h.

Referenced by ~CmdLine().

◆ deleteOnExit() [2/2]

void TCLAP::CmdLine::deleteOnExit ( Visitor ptr)
inlineprotected

Perform a delete ptr; operation on ptr when this object is deleted.

Definition at line 474 of file CmdLine.h.

◆ getArgList()

std::list< Arg * > & TCLAP::CmdLine::getArgList ( )
inlinevirtual

Returns the argList.

Implements TCLAP::CmdLineInterface.

Definition at line 500 of file CmdLine.h.

◆ getDelimiter()

char TCLAP::CmdLine::getDelimiter ( )
inlinevirtual

Returns the delimiter string.

Implements TCLAP::CmdLineInterface.

Definition at line 510 of file CmdLine.h.

◆ getMessage()

std::string & TCLAP::CmdLine::getMessage ( )
inlinevirtual

Returns the message string.

Implements TCLAP::CmdLineInterface.

Definition at line 515 of file CmdLine.h.

◆ getOutput()

CmdLineOutput * TCLAP::CmdLine::getOutput ( )
inlinevirtual

Returns the CmdLineOutput object.

Implements TCLAP::CmdLineInterface.

Definition at line 479 of file CmdLine.h.

◆ getProgramName()

std::string & TCLAP::CmdLine::getProgramName ( )
inlinevirtual

Returns the program name string.

Implements TCLAP::CmdLineInterface.

Definition at line 495 of file CmdLine.h.

◆ getVersion()

std::string & TCLAP::CmdLine::getVersion ( )
inlinevirtual

Returns the version string.

Implements TCLAP::CmdLineInterface.

Definition at line 490 of file CmdLine.h.

◆ getXorHandler()

XorHandler & TCLAP::CmdLine::getXorHandler ( )
inlinevirtual

Returns the XorHandler.

Implements TCLAP::CmdLineInterface.

Definition at line 505 of file CmdLine.h.

◆ hasHelpAndVersion()

bool TCLAP::CmdLine::hasHelpAndVersion ( )
inlinevirtual

Indicates whether or not the help and version switches were created automatically.

Implements TCLAP::CmdLineInterface.

Definition at line 520 of file CmdLine.h.

◆ parse()

bool TCLAP::CmdLine::parse ( int  argc,
char **  argv 
)
inlinevirtual

Parses the command line.

Parameters
argc- Number of arguments.
argv- Array of arguments.
Returns
(Added by JLBC for MRPT): Return false if the program should exit (error in args, it was –help, etc...)

Implements TCLAP::CmdLineInterface.

Definition at line 401 of file CmdLine.h.

References _xorHandler, and TCLAP::XorHandler::check().

◆ setOutput()

void TCLAP::CmdLine::setOutput ( CmdLineOutput co)
inlinevirtual
Parameters
co- CmdLineOutput object that we want to use instead.

Implements TCLAP::CmdLineInterface.

Definition at line 484 of file CmdLine.h.

◆ xorAdd() [1/2]

void TCLAP::CmdLine::xorAdd ( Arg a,
Arg b 
)
inlinevirtual

Add two Args that will be xor'd.

If this method is used, add does not need to be called.

Parameters
a- Argument to be added and xor'd.
b- Argument to be added and xor'd.

Implements TCLAP::CmdLineInterface.

Definition at line 374 of file CmdLine.h.

◆ xorAdd() [2/2]

void TCLAP::CmdLine::xorAdd ( std::vector< Arg * > &  xors)
inlinevirtual

Add a list of Args that will be xor'd.

If this method is used, add does not need to be called.

Parameters
xors- List of Args to be added and xor'd.

Implements TCLAP::CmdLineInterface.

Definition at line 361 of file CmdLine.h.

Member Data Documentation

◆ _argDeleteOnExitList

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 147 of file CmdLine.h.

◆ _argList

std::list<Arg*> TCLAP::CmdLine::_argList
protected

The list of arguments that will be tested against the command line.

Definition at line 107 of file CmdLine.h.

Referenced by add().

◆ _delimiter

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 135 of file CmdLine.h.

Referenced by ~CmdLine().

◆ _helpAndVersion

bool TCLAP::CmdLine::_helpAndVersion
private

Whether or not to automatically create help and version switches.

Definition at line 196 of file CmdLine.h.

Referenced by ~CmdLine().

◆ _message

std::string TCLAP::CmdLine::_message
protected

A message used to describe the program.

Used in the usage output.

Definition at line 117 of file CmdLine.h.

◆ _numRequired

int TCLAP::CmdLine::_numRequired
protected

The number of arguments that are required to be present on the command line.

This is set dynamically, based on the Args added to the CmdLine object.

Definition at line 129 of file CmdLine.h.

◆ _output

CmdLineOutput* TCLAP::CmdLine::_output
protected

Object that handles all output for the CmdLine.

Definition at line 159 of file CmdLine.h.

Referenced by ~CmdLine().

◆ _progName

std::string TCLAP::CmdLine::_progName
protected

The name of the program.

Set to argv[0].

Definition at line 112 of file CmdLine.h.

◆ _userSetOutput

bool TCLAP::CmdLine::_userSetOutput
private

Is set to true when a user sets the output object.

We use this so that we don't delete objects that are created outside of this lib.

Definition at line 191 of file CmdLine.h.

◆ _version

std::string TCLAP::CmdLine::_version
protected

The version to be displayed with the –version switch.

Definition at line 122 of file CmdLine.h.

◆ _visitorDeleteOnExitList

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 154 of file CmdLine.h.

Referenced by _emptyCombined().

◆ _xorHandler

XorHandler TCLAP::CmdLine::_xorHandler
protected

The handler that manages xoring lists of args.

Definition at line 140 of file CmdLine.h.

Referenced by parse().




Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 23:11:08 UTC 2019