VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
makVrv::CmdLine Class Reference

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

Inheritance diagram for makVrv::CmdLine:
Inheritance graph
[legend]

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, bool printOnError=true)
 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.

Detailed Description

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.

Constructor & Destructor Documentation

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

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

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.

References _constructor().

makVrv::CmdLine::~CmdLine ( )
inlinevirtual

Deletes any resources allocated by a CmdLine object.

References _argDeleteOnExitList, _output, _userSetOutput, and _visitorDeleteOnExitList.

Member Function Documentation

bool makVrv::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.

References int().

Referenced by parse().

void makVrv::CmdLine::_constructor ( )
inlineprivate

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)
inlineprivate

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

References _argDeleteOnExitList.

Referenced by _constructor().

void makVrv::CmdLine::deleteOnExit ( DtCmdLine::Visitor *  ptr)
inlineprivate

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.

Parameters
a- Argument to be added.

Referenced by _constructor(), and xorAdd().

void makVrv::CmdLine::add ( DtCmdLine::Arg *  a)
inline

An alternative add.

Functionally identical.

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

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

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

References _xorHandler, and add().

void makVrv::CmdLine::parse ( int  argc,
char **  argv,
bool  printOnError = true 
)
inline

Parses the command line.

Parameters
argc- Number of arguments.
argv- Array of arguments.

References _argList, _emptyCombined(), _numRequired, _output, _progName, _xorHandler, int(), 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.

Member Data Documentation

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

The name of the program.

Set to argv[0].

Referenced by getProgramName(), and parse().

std::string makVrv::CmdLine::_message
protected

A message used to describe the program.

Used in the usage output.

Referenced by getMessage().

std::string makVrv::CmdLine::_version
protected

The version to be displayed with the –version switch.

Referenced by getVersion().

int makVrv::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 makVrvmakVrv::CmdLine object.

Referenced by add(), and parse().

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().


The documentation for this class was generated from the following file:

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)