LibCppCmd v1.0 Beta 15
C++ Command Line Parsing Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CmdLine::ArgParam Class Referenceabstract

A parameter populated by command line arguments (base class). More...

#include <ArgParam.h>

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

Public Member Functions

virtual ~ArgParam ()=default
 Destructs an ArgParam.
 
virtual bool Populate (std::deque< std::string > &args)=0
 Populates the ArgParam from an argument queue.
 
virtual bool CanPopulate (const std::deque< std::string > &args) const =0
 Determines if the specified args can populate the ArgParam.
 
virtual std::size_t Consumes (const std::deque< std::string > &args) const =0
 Gets the number of arguments the ArgParam consumes.
 
- Public Member Functions inherited from CmdLine::Param
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 populated by command line arguments (base class).

An ArgParam is a variable that the CmdLine::Parser will populate with data from one or more command line arguments. It provides methods for populating the parameter, as well as determining how many arguments population consumes and whether the next arguments in an argument queue (deque) can populate the parameter.

Member Function Documentation

◆ CanPopulate()

virtual bool CmdLine::ArgParam::CanPopulate ( const std::deque< std::string > & args) const
pure virtual

Determines if the specified args can populate the ArgParam.

Accepts a reference to an argument queue (deque) and determines if the next n arguments in the queue can populate the ArgParam.

Parameters
argsThe argument queue to evaluate.
Returns
True if the arguments can populate, otherwise false.

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

◆ Consumes()

virtual std::size_t CmdLine::ArgParam::Consumes ( const std::deque< std::string > & args) const
pure virtual

Gets the number of arguments the ArgParam consumes.

Each ArgParam consumes a certain number of arguments from an argument queue upon successful population. This number is implementation defined.

Parameters
argsThe argument queue to evaluate.
Returns
The number of arguments the ArgParam will consume.

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

◆ Populate()

virtual bool CmdLine::ArgParam::Populate ( std::deque< std::string > & args)
pure virtual

Populates the ArgParam from an argument queue.

Accepts a reference to an argument queue (deque) and attempts to populate the ArgParam with data from the next n arguments in the queue, where n is the number of arguments the ArgParam consumes. Populating the ArgParam, at a minimum, marks it as specified and may also populate it with values (depending on the implementation). Successful population also consumes the arguments from the queue that populated the ArgParam.

Parameters
argsThe argument queue to populate from.
Returns
True if population is successful, otherwise false.
Precondition
Size of arguments > 0.
Size of arguments >= result of Consumes().
Postcondition
The ArgParam is marked specified.
Removes the number of arguments from the queue = Consumes().

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


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