VR-Link API Documentation for DIS
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:

List of all members.

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

void setOutput (CmdLineOutput *co)
 
    

std::string & getVersion ()
 
    

std::string & getProgramName ()
 
    

std::list< Arg * > & getArgList ()
 
    

XorHandlergetXorHandler ()
 
    

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< 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 ( ) [inline, virtual]

Deletes any resources allocated by a CmdLine object.

References _argDeleteOnExitList, _output, _userSetOutput, and _visitorDeleteOnExitList.


Member Function Documentation

void DtCmdLine::CmdLine::_constructor ( ) [inline, private]

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) [inline, protected]

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) [inline, virtual]

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) [inline, virtual]

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) [inline, private]

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

References _argDeleteOnExitList.

Referenced by _constructor().

void DtCmdLine::CmdLine::deleteOnExit ( Visitor ptr) [inline, private]

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

References _visitorDeleteOnExitList.

std::list< Arg * > & DtCmdLine::CmdLine::getArgList ( ) [inline, virtual]

    

Implements DtCmdLine::CmdLineInterface.

References _argList.

char DtCmdLine::CmdLine::getDelimiter ( ) [inline, virtual]

    

Implements DtCmdLine::CmdLineInterface.

References _delimiter.

std::string & DtCmdLine::CmdLine::getMessage ( ) [inline, virtual]

    

Implements DtCmdLine::CmdLineInterface.

References _message.

    

Implements DtCmdLine::CmdLineInterface.

References _output.

std::string & DtCmdLine::CmdLine::getProgramName ( ) [inline, virtual]

    

Implements DtCmdLine::CmdLineInterface.

References _progName.

std::string & DtCmdLine::CmdLine::getVersion ( ) [inline, virtual]

    

Implements DtCmdLine::CmdLineInterface.

References _version.

    

Implements DtCmdLine::CmdLineInterface.

References _xorHandler.

void DtCmdLine::CmdLine::parse ( int  argc,
char **  argv 
) [inline, virtual]
void DtCmdLine::CmdLine::setOutput ( CmdLineOutput co) [inline, virtual]

    

Implements DtCmdLine::CmdLineInterface.

References _output, and _userSetOutput.

void DtCmdLine::CmdLine::xorAdd ( Arg a,
Arg b 
) [inline, virtual]

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) [inline, virtual]

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

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

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

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

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

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

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

The handler that manages xoring lists of args.

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

Referenced by _constructor(), and parse().


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

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)