VR-Link API Documentation for DIS
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
DtCmdLine::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 DtCmdLine::CmdLine:
+ Collaboration diagram for DtCmdLine::CmdLine:

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 (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.
CmdLineOutputgetOutput ()
 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.
XorHandlergetXorHandler ()
 Returns the XorHandler.
char getDelimiter ()
 Returns the delimiter string.
std::string & getMessage ()
 Returns the message string.
- Public Member Functions inherited from DtCmdLine::CmdLineInterface
virtual ~CmdLineInterface ()
 Destructor.

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< 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.
bool myPressAnyKey

Private Member Functions

void _constructor ()
 Encapsulates the code common to the constructors (which is all of it).
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.

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.

Constructor & Destructor Documentation

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

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

DtCmdLine::CmdLine::~CmdLine ( )
inlinevirtual

Deletes any resources allocated by a CmdLine object.

References _argDeleteOnExitList, _output, _userSetOutput, and _visitorDeleteOnExitList.

Member Function Documentation

void DtCmdLine::CmdLine::_constructor ( )
inlineprivate

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

References _delimiter, _output, add(), deleteOnExit(), DtCmdLine::Arg::flagStartString(), DtCmdLine::Arg::ignoreNameString(), myPressAnyKey, and DtCmdLine::Arg::setDelimiter().

Referenced by CmdLine().

bool DtCmdLine::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 DtCmdLine::Arg::blankChar(), and DtCmdLine::Arg::flagStartChar().

Referenced by parse().

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

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

Parameters
a- Argument to be added.

Implements DtCmdLine::CmdLineInterface.

Referenced by _constructor(), and xorAdd().

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

An alternative add.

Functionally identical.

Parameters
a- Argument to be added.

Implements DtCmdLine::CmdLineInterface.

References _argList, _numRequired, DtCmdLine::Arg::addToList(), DtCmdLine::Arg::isRequired(), and DtCmdLine::Arg::longID().

void DtCmdLine::CmdLine::deleteOnExit ( Arg ptr)
inlineprivate

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

References _argDeleteOnExitList.

Referenced by _constructor().

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

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

References _visitorDeleteOnExitList.

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

Returns the argList.

Implements DtCmdLine::CmdLineInterface.

References _argList.

char DtCmdLine::CmdLine::getDelimiter ( )
inlinevirtual

Returns the delimiter string.

Implements DtCmdLine::CmdLineInterface.

References _delimiter.

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

Returns the message string.

Implements DtCmdLine::CmdLineInterface.

References _message.

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

Returns the CmdLineOutput object.

Implements DtCmdLine::CmdLineInterface.

References _output.

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

Returns the program name string.

Implements DtCmdLine::CmdLineInterface.

References _progName.

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

Returns the version string.

Implements DtCmdLine::CmdLineInterface.

References _version.

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

Returns the XorHandler.

Implements DtCmdLine::CmdLineInterface.

References _xorHandler.

void DtCmdLine::CmdLine::parse ( int  argc,
char **  argv 
)
inlinevirtual
void DtCmdLine::CmdLine::setOutput ( CmdLineOutput co)
inlinevirtual
Parameters
co- CmdLineOutput object that we want to use instead.

Implements DtCmdLine::CmdLineInterface.

References _output, and _userSetOutput.

void DtCmdLine::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 DtCmdLine::CmdLineInterface.

void DtCmdLine::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 DtCmdLine::CmdLineInterface.

References _xorHandler, DtCmdLine::XorHandler::add(), and add().

Member Data Documentation

std::list<Arg*> DtCmdLine::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<Arg*> DtCmdLine::CmdLine::_argList
protected

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

Referenced by add(), getArgList(), and parse().

char DtCmdLine::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().

std::string DtCmdLine::CmdLine::_message
protected

A message used to describe the program.

Used in the usage output.

Referenced by getMessage().

int DtCmdLine::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.

Referenced by add(), and parse().

CmdLineOutput* DtCmdLine::CmdLine::_output
protected

Object that handles all output for the CmdLine.

Referenced by _constructor(), getOutput(), parse(), setOutput(), and ~CmdLine().

std::string DtCmdLine::CmdLine::_progName
protected

The name of the program.

Set to argv[0].

Referenced by getProgramName(), and parse().

bool DtCmdLine::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().

std::string DtCmdLine::CmdLine::_version
protected

The version to be displayed with the –version switch.

Referenced by getVersion().

std::list<Visitor*> DtCmdLine::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().

XorHandler DtCmdLine::CmdLine::_xorHandler
protected

The handler that manages xoring lists of args.

Referenced by getXorHandler(), parse(), and xorAdd().

bool DtCmdLine::CmdLine::myPressAnyKey
protected

Referenced by _constructor(), and parse().


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

Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)