LibCppCmd v1.0 Beta 15
C++ Command Line Parsing Library
|
A command line ArgParam populated by the program name. More...
#include <ProgParam.h>
Classes | |
struct | Definition |
This definition is used to construct a ProgParam. More... | |
Public Member Functions | |
ProgParam (Definition d) | |
Constructs a new ProgParam. | |
std::string | Name () const override |
Gets the name of the ProgParam. | |
std::string | Description () const override |
Gets the description of the ProgParam. | |
bool | IsSpecified () const override |
Indicates whether the ProgParam has been specified. | |
bool | IsMandatory () const override |
Indicates whether the ProgParam is mandatory. | |
std::string | HelpInfo () const override |
Gets help info for the ProgParam. | |
bool | Populate (std::deque< std::string > &args) override |
Populates this ProgParam from an argument queue. | |
bool | CanPopulate (const std::deque< std::string > &args) const override |
Determines if arguments can populate this ProgParam. | |
std::size_t | Consumes (const std::deque< std::string > &args) const override |
Gets the number of arguments the ProgParam consumes. | |
std::string | Value () const |
Gets the value of the ProgParam. | |
Public Member Functions inherited from CmdLine::ArgParam | |
virtual | ~ArgParam ()=default |
Destructs an ArgParam. | |
Public Member Functions inherited from CmdLine::Param | |
virtual | ~Param ()=default |
Destructs a Param. | |
A command line ArgParam populated by the program name.
A ProgramParameter is a CommandLine ArgumentParameter that is populated by the program name argument, which is the first CommandLine argument the OS passes to the program by convention. Upon successful population, the ProgramParameter's value will be populated by the program name argument, which will also mark the ProgramParameter as specified. Even if the value of the program argument is not important to the program, the ProgramParameter's name is still used to represent the program when the parser generates help and usage info.
CmdLine::ProgParam::ProgParam | ( | Definition | d | ) |
Constructs a new ProgParam.
d | The definition to construct the ProgParam with. |
Param::InvalidDefinition | Doesn't satisfy invariants. |
|
overridevirtual |
Determines if arguments can populate this ProgParam.
Accepts a reference to an argument queue (deque) and determines if the first argument in the queue can populate the ProgParam.
arguments | The argument queue to evaluate. |
Implements CmdLine::ArgParam.
|
inlineoverridevirtual |
Gets the number of arguments the ProgParam consumes.
Each ProgParam consumes exactly 1 argument from the argument queue upon successful population.
arguments | The argument queue to evaluate. |
Implements CmdLine::ArgParam.
|
inlineoverridevirtual |
Gets the description of the ProgParam.
The description of the ProgParam is used for generating help.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Gets help info for the ProgParam.
The help info will include the name and description of the ProgParam when generating help.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Indicates whether the ProgParam is mandatory.
The command line Parser uses this to determine if the program name argument must be specified at the command line for parsing to be successful. If a mandatory ProgParam is not specified i.e. the correct command line argument necessary to populate the ProgParam was not supplied, parsing will fail indicating the program was supplied with bad command line arguments.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Indicates whether the ProgParam has been specified.
A ProgParam will only indicate it was specified if the parameter has been successfully populated by the program name command line argument. The Parser also uses this to determine if a mandatory ProgParam has been specified.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Gets the name of the ProgParam.
The name of the ProgParam is used for generating usage and help.
Implements CmdLine::Param.
|
overridevirtual |
Populates this ProgParam from an argument queue.
Accepts a reference to an argument queue (deque) and attempts to populate the ProgParam from the first argument in the queue. Populating the ProgParam marks it as specified and will also populate the ProgParam value with the argument. Successful population also consumes the argument from the queue that populated the argument.
args | The argument queue to populate the parameter with. |
Implements CmdLine::ArgParam.
|
inline |