LibCppCmdLine v1.0
A cross-platform C++ library for parsing command line arguments
Loading...
Searching...
No Matches
CmdLine::Param Class Referenceabstract

A parameter that stores data from the command line (base class). More...

#include <Param.h>

Inheritance diagram for CmdLine::Param:
CmdLine::ArgParam CmdLine::OptionParam CmdLine::MultiPosParam CmdLine::Option CmdLine::PosParam CmdLine::ProgParam CmdLine::ValueOption

Classes

struct  Definition
 Defines a command line Param. More...
class  InvalidDefinition
 An exception thrown for invalid Param definitions. More...

Public Member Functions

virtual ~Param ()=default
 Destructs a Param.
virtual std::string Name () const =0
 Gets the name of the Param.
virtual std::string Description () const =0
 Gets the description of the Param.
virtual std::string HelpInfo () const =0
 Gets help information for the Param.
virtual bool IsSpecified () const =0
 Indicates whether the Param has been specified.
virtual bool IsMandatory () const =0
 Indicates whether the Param is mandatory.

Detailed Description

A parameter that stores data from the command line (base class).

A command line Param is a variable that stores data specified at the command line. How this is achieved is defined by the implemntation of each class that inherits from this one. This base class declares the the minimum attributes all types of Param are expected to have: a Name(), Description(), HelpInfo() to print on help and usage screens, whether the Param IsSpecified() at the command line, and whether the Param IsMandatory().

Invariant
Name must be non-empty.
Name must contain only alpha numerics or - and _.
Name must not be longer than 20 characters.
Name must not start with an option prefix.
Can only be specified upon successful population.

Member Function Documentation

◆ Description()

virtual std::string CmdLine::Param::Description ( ) const
pure virtual

Gets the description of the Param.

The description of the Param is used for generating help.

Returns
The description of the Param.

Implemented in CmdLine::MultiPosParam, CmdLine::Option, CmdLine::OptionParam, CmdLine::PosParam, and CmdLine::ProgParam.

◆ HelpInfo()

virtual std::string CmdLine::Param::HelpInfo ( ) const
pure virtual

Gets help information for the Param.

The help info will include the Name() and Description() of the parameter when generating help.

Returns
Help information for the parameter.

Implemented in CmdLine::MultiPosParam, CmdLine::Option, CmdLine::OptionParam, CmdLine::PosParam, CmdLine::ProgParam, and CmdLine::ValueOption.

◆ IsMandatory()

virtual bool CmdLine::Param::IsMandatory ( ) const
pure virtual

Indicates whether the Param is mandatory.

The command line Parser uses this to determine if a parameter must be specified at the command line for parsing to be successful. If a mandatory parameter is not specified, parsing will fail indicating the program was supplied with bad command line arguments.

Returns
True if the parameter is mandatory, otherwise false.

Implemented in CmdLine::MultiPosParam, CmdLine::Option, CmdLine::OptionParam, CmdLine::PosParam, and CmdLine::ProgParam.

◆ IsSpecified()

virtual bool CmdLine::Param::IsSpecified ( ) const
pure virtual

Indicates whether the Param has been specified.

A Param will only indicate it was specified if it has been successfully populated by data from a command line argument. The command line Parser also uses this to determine if a mandatory parameter has been specified.

Returns
True if the parameter is specified, otherwise false.

Implemented in CmdLine::MultiPosParam, CmdLine::Option, CmdLine::OptionParam, CmdLine::PosParam, and CmdLine::ProgParam.

◆ Name()

virtual std::string CmdLine::Param::Name ( ) const
pure virtual

Gets the name of the Param.

The name of the Param is used for generating usage and help.

Returns
The name of the Param.

Implemented in CmdLine::MultiPosParam, CmdLine::Option, CmdLine::OptionParam, CmdLine::PosParam, and CmdLine::ProgParam.


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