Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ecl::CmdLine Class Reference

Manages the command line parsing object. More...

#include <cmd_line.hpp>

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

Public Member Functions

void add (Arg &a)
 
void add (Arg *a)
 
 CmdLine (const std::string &message, const char delimiter=' ', const std::string &version="none", bool helpAndVersion=true)
 
std::list< Arg * > & getArgList ()
 
char getDelimiter ()
 
std::string & getMessage ()
 
CmdLineOutputgetOutput ()
 
std::string & getProgramName ()
 
std::string & getVersion ()
 
XorHandlergetXorHandler ()
 
bool hasHelpAndVersion ()
 
void parse (int argc, char **argv)
 
void setOutput (CmdLineOutput *co)
 
void xorAdd (Arg &a, Arg &b)
 
void xorAdd (std::vector< Arg * > &xors)
 
virtual ~CmdLine ()
 
- Public Member Functions inherited from ecl::CmdLineInterface
virtual ~CmdLineInterface ()
 

Protected Member Functions

bool _emptyCombined (const std::string &s)
 
void deleteOnExit (Arg *ptr)
 
void deleteOnExit (Visitor *ptr)
 

Protected Attributes

std::list< Arg * > _argDeleteOnExitList
 
std::list< Arg * > _argList
 
char _delimiter
 
std::string _message
 
int _numRequired
 
CmdLineOutput_output
 
std::string _progName
 
std::string _version
 
std::list< Visitor * > _visitorDeleteOnExitList
 
XorHandler _xorHandler
 

Private Member Functions

void _constructor ()
 

Private Attributes

bool _helpAndVersion
 
bool _userSetOutput
 

Detailed Description

Manages the command line parsing object.

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

Definition at line 51 of file cmd_line.hpp.

Constructor & Destructor Documentation

◆ CmdLine()

ecl::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 259 of file cmd_line.hpp.

◆ ~CmdLine()

ecl::CmdLine::~CmdLine ( )
inlinevirtual

Deletes any resources allocated by a CmdLine object.

Definition at line 274 of file cmd_line.hpp.

Member Function Documentation

◆ _constructor()

void ecl::CmdLine::_constructor ( )
inlineprivate

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

Definition at line 293 of file cmd_line.hpp.

◆ _emptyCombined()

bool ecl::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 415 of file cmd_line.hpp.

◆ add() [1/2]

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

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

Parameters
a- Argument to be added.

Implements ecl::CmdLineInterface.

Definition at line 351 of file cmd_line.hpp.

◆ add() [2/2]

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

An alternative add. Functionally identical.

Parameters
a- Argument to be added.

Implements ecl::CmdLineInterface.

Definition at line 356 of file cmd_line.hpp.

◆ deleteOnExit() [1/2]

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

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

Definition at line 427 of file cmd_line.hpp.

◆ deleteOnExit() [2/2]

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

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

Definition at line 432 of file cmd_line.hpp.

◆ getArgList()

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

Returns the argList.

Implements ecl::CmdLineInterface.

Definition at line 458 of file cmd_line.hpp.

◆ getDelimiter()

char ecl::CmdLine::getDelimiter ( )
inlinevirtual

Returns the delimiter string.

Implements ecl::CmdLineInterface.

Definition at line 468 of file cmd_line.hpp.

◆ getMessage()

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

Returns the message string.

Implements ecl::CmdLineInterface.

Definition at line 473 of file cmd_line.hpp.

◆ getOutput()

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

Returns the CmdLineOutput object.

Implements ecl::CmdLineInterface.

Definition at line 437 of file cmd_line.hpp.

◆ getProgramName()

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

Returns the program name string.

Implements ecl::CmdLineInterface.

Definition at line 453 of file cmd_line.hpp.

◆ getVersion()

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

Returns the version string.

Implements ecl::CmdLineInterface.

Definition at line 448 of file cmd_line.hpp.

◆ getXorHandler()

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

Returns the XorHandler.

Implements ecl::CmdLineInterface.

Definition at line 463 of file cmd_line.hpp.

◆ hasHelpAndVersion()

bool ecl::CmdLine::hasHelpAndVersion ( )
inlinevirtual

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

Implements ecl::CmdLineInterface.

Definition at line 478 of file cmd_line.hpp.

◆ parse()

void ecl::CmdLine::parse ( int  argc,
char **  argv 
)
inlinevirtual

Parses the command line.

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

Implements ecl::CmdLineInterface.

Definition at line 370 of file cmd_line.hpp.

◆ setOutput()

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

Implements ecl::CmdLineInterface.

Definition at line 442 of file cmd_line.hpp.

◆ xorAdd() [1/2]

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

Definition at line 343 of file cmd_line.hpp.

◆ xorAdd() [2/2]

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

Definition at line 330 of file cmd_line.hpp.

Member Data Documentation

◆ _argDeleteOnExitList

std::list<Arg*> ecl::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 101 of file cmd_line.hpp.

◆ _argList

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

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

Definition at line 61 of file cmd_line.hpp.

◆ _delimiter

char ecl::CmdLine::_delimiter
protected

The character that is used to separate the argument flag/name from the value. Defaults to ' ' (space).

Definition at line 89 of file cmd_line.hpp.

◆ _helpAndVersion

bool ecl::CmdLine::_helpAndVersion
private

Whether or not to automatically create help and version switches.

Definition at line 150 of file cmd_line.hpp.

◆ _message

std::string ecl::CmdLine::_message
protected

A message used to describe the program. Used in the usage output.

Definition at line 71 of file cmd_line.hpp.

◆ _numRequired

int ecl::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 83 of file cmd_line.hpp.

◆ _output

CmdLineOutput* ecl::CmdLine::_output
protected

Object that handles all output for the CmdLine.

Definition at line 113 of file cmd_line.hpp.

◆ _progName

std::string ecl::CmdLine::_progName
protected

The name of the program. Set to argv[0].

Definition at line 66 of file cmd_line.hpp.

◆ _userSetOutput

bool ecl::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 145 of file cmd_line.hpp.

◆ _version

std::string ecl::CmdLine::_version
protected

The version to be displayed with the –version switch.

Definition at line 76 of file cmd_line.hpp.

◆ _visitorDeleteOnExitList

std::list<Visitor*> ecl::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 108 of file cmd_line.hpp.

◆ _xorHandler

XorHandler ecl::CmdLine::_xorHandler
protected

The handler that manages xoring lists of args.

Definition at line 94 of file cmd_line.hpp.


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


ecl_command_line
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:13