LibCppCmd v1.0 Beta 15
C++ Command Line Parsing Library
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
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
 Getst the description of the Param.
 
virtual std::string HelpInfo () const =0
 Gets help info 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, help information to print on help and usage screens, whether the Param was specified at the command line, and whether the Param is mandatory.

Member Function Documentation

◆ Description()

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

Getst 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 info for the Param.

The help info will include the name and description of the Param when generating help.

Returns
Help info for the Param.

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 Param must be specified at the command line for parsing to be successful. If a mandatory Param is not specified i.e. the correct command line argument necessary to populate the Param was not supplied, parsing will fail indicating the program was supplied with bad command line arguments.

Returns
True if the Param 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 the it has been successfully populated by data from a command line argument. This is particularly useful to determine if a particular command line Option (also a type of Param) has been specified at the command line, etc. The comand line Parser also uses this to determine if a mandatory parameter has been specified.

Returns
True if the Param 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: