![]() |
VR-Forces 4.0.4 Class Documentation
|
The base class that manages the command line definition and passes along the parsing to the appropriate Arg classes. More...

Public Member Functions | |
| CmdLine (const std::string &name, const std::string &message, const std::string &version="none", bool pressAnyKey=false) | |
| Command line constructor. | |
| CmdLine (const std::string &message, const char delimiter= ' ', const std::string &version="none", bool pressAnyKey=false) | |
| Command line constructor. | |
| virtual | ~CmdLine () |
| Deletes any resources allocated by a CmdLine object. | |
| void | add (DtCmdLine::Arg &a) |
| Adds an argument to the list of arguments to be parsed. | |
| void | add (DtCmdLine::Arg *a) |
| An alternative add. | |
| void | xorAdd (DtCmdLine::Arg &a, DtCmdLine::Arg &b) |
| Add two Args that will be xor'd. | |
| void | xorAdd (std::vector< DtCmdLine::Arg * > &xors) |
| Add a list of Args that will be xor'd. | |
| void | parse (int argc, char **argv) |
| Parses the command line. | |
| DtCmdLine::CmdLineOutput * | getOutput () |
| void | setOutput (DtCmdLine::CmdLineOutput *co) |
| std::string & | getVersion () |
| std::string & | getProgramName () |
| std::list< DtCmdLine::Arg * > & | getArgList () |
| DtCmdLine::XorHandler & | getXorHandler () |
| char | getDelimiter () |
| std::string & | getMessage () |
Protected Member Functions | |
| bool | _emptyCombined (const std::string &s) |
| Checks whether a name/flag string matches entirely matches the Arg::blankChar. | |
Protected Attributes | |
| std::list< DtCmdLine::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. | |
| DtCmdLine::XorHandler | _xorHandler |
| The handler that manages xoring lists of args. | |
| std::list< DtCmdLine::Arg * > | _argDeleteOnExitList |
| A list of Args to be explicitly deleted when the destructor is called. | |
| std::list< DtCmdLine::Visitor * > | _visitorDeleteOnExitList |
| A list of Visitors to be explicitly deleted when the destructor is called. | |
| DtCmdLine::CmdLineOutput * | _output |
| Object that handles all output for the CmdLine. | |
| bool | myPressAnyKey |
Private Member Functions | |
| void | _constructor () |
| Encapsulates the code common to the constructors (which is all of it). | |
| void | deleteOnExit (DtCmdLine::Arg *ptr) |
| Perform a delete ptr; operation on ptr when this object is deleted. | |
| void | deleteOnExit (DtCmdLine::Visitor *ptr) |
| Perform a delete ptr; operation on ptr when this object is deleted. | |
Private Attributes | |
| bool | _userSetOutput |
| Is set to true when a user sets the output object. | |
The base class that manages the command line definition and passes along the parsing to the appropriate Arg classes.
This version of CmdLine patches an invalid array access. See cmdLine/cmdLine.h in VR-Link for the original.
| makVrv::CmdLine::CmdLine | ( | const std::string & | name, |
| const std::string & | message, | ||
| const std::string & | version = "none", |
||
| bool | pressAnyKey = false |
||
| ) | [inline] |
Command line constructor.
DEPRECATED!!! This is here to maintain backwards compatibility with earlier releases. Note that the program name will be overwritten with argv[0]. The delimiter used is ' ' (as before).
| name | - The program name - will be overwritten with argv[0]. |
| message | - The message to be used in the usage output. |
| version | - The version number to be used in the --version switch. |
References _constructor().
| makVrv::CmdLine::CmdLine | ( | const std::string & | message, |
| const char | delimiter = ' ', |
||
| const std::string & | version = "none", |
||
| bool | pressAnyKey = false |
||
| ) | [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. |
References _constructor().
| makVrv::CmdLine::~CmdLine | ( | ) | [inline, virtual] |
Deletes any resources allocated by a CmdLine object.
References _argDeleteOnExitList, _output, _userSetOutput, and _visitorDeleteOnExitList.
| bool makVrv::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. |
Referenced by parse().
| void makVrv::CmdLine::_constructor | ( | ) | [inline, private] |
Encapsulates the code common to the constructors (which is all of it).
References _delimiter, _output, add(), deleteOnExit(), and myPressAnyKey.
Referenced by CmdLine().
| void makVrv::CmdLine::deleteOnExit | ( | DtCmdLine::Arg * | ptr | ) | [inline, private] |
Perform a delete ptr; operation on ptr when this object is deleted.
References _argDeleteOnExitList.
Referenced by _constructor().
| void makVrv::CmdLine::deleteOnExit | ( | DtCmdLine::Visitor * | ptr | ) | [inline, private] |
Perform a delete ptr; operation on ptr when this object is deleted.
References _visitorDeleteOnExitList.
| void makVrv::CmdLine::add | ( | DtCmdLine::Arg & | a | ) | [inline] |
Adds an argument to the list of arguments to be parsed.
| a | - Argument to be added. |
Referenced by _constructor(), and xorAdd().
| void makVrv::CmdLine::add | ( | DtCmdLine::Arg * | a | ) | [inline] |
An alternative add.
Functionally identical.
| a | - Argument to be added. |
References _argList, and _numRequired.
| void makVrv::CmdLine::xorAdd | ( | DtCmdLine::Arg & | a, |
| DtCmdLine::Arg & | b | ||
| ) | [inline] |
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. |
| void makVrv::CmdLine::xorAdd | ( | std::vector< DtCmdLine::Arg * > & | xors | ) | [inline] |
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. |
References _xorHandler, and add().
| void makVrv::CmdLine::parse | ( | int | argc, |
| char ** | argv | ||
| ) | [inline] |
Parses the command line.
| argc | - Number of arguments. |
| argv | - Array of arguments. |
References _argList, _emptyCombined(), _numRequired, _output, _progName, _xorHandler, and myPressAnyKey.
| DtCmdLine::CmdLineOutput * makVrv::CmdLine::getOutput | ( | ) | [inline] |
References _output.
| void makVrv::CmdLine::setOutput | ( | DtCmdLine::CmdLineOutput * | co | ) | [inline] |
References _output, and _userSetOutput.
| std::string & makVrv::CmdLine::getVersion | ( | ) | [inline] |
References _version.
| std::string & makVrv::CmdLine::getProgramName | ( | ) | [inline] |
References _progName.
| std::list< DtCmdLine::Arg * > & makVrv::CmdLine::getArgList | ( | ) | [inline] |
References _argList.
| DtCmdLine::XorHandler & makVrv::CmdLine::getXorHandler | ( | ) | [inline] |
References _xorHandler.
| char makVrv::CmdLine::getDelimiter | ( | ) | [inline] |
References _delimiter.
| std::string & makVrv::CmdLine::getMessage | ( | ) | [inline] |
References _message.
std::list<DtCmdLine::Arg*> makVrv::CmdLine::_argList [protected] |
The list of arguments that will be tested against the command line.
Referenced by add(), getArgList(), and parse().
std::string makVrv::CmdLine::_progName [protected] |
std::string makVrv::CmdLine::_message [protected] |
std::string makVrv::CmdLine::_version [protected] |
The version to be displayed with the --version switch.
Referenced by getVersion().
int makVrv::CmdLine::_numRequired [protected] |
char makVrv::CmdLine::_delimiter [protected] |
The character that is used to separate the argument flag/name from the value.
Defaults to ' ' (space).
Referenced by _constructor(), and getDelimiter().
DtCmdLine::XorHandler makVrv::CmdLine::_xorHandler [protected] |
The handler that manages xoring lists of args.
Referenced by getXorHandler(), parse(), and xorAdd().
std::list<DtCmdLine::Arg*> makVrv::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.
Referenced by deleteOnExit(), and ~CmdLine().
std::list<DtCmdLine::Visitor*> makVrv::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.
Referenced by deleteOnExit(), and ~CmdLine().
DtCmdLine::CmdLineOutput* makVrv::CmdLine::_output [protected] |
Object that handles all output for the CmdLine.
Referenced by _constructor(), getOutput(), parse(), setOutput(), and ~CmdLine().
bool makVrv::CmdLine::myPressAnyKey [protected] |
Referenced by _constructor(), and parse().
bool makVrv::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.
Referenced by setOutput(), and ~CmdLine().