LibCppCmd v1.0 Beta 15
C++ Command Line Parsing Library
|
A Positional command line ArgParam. More...
#include <PosParam.h>
Classes | |
struct | Definition |
This definition is used to construct a PosParam. More... | |
Public Member Functions | |
PosParam (Definition d) | |
Constructs a new PosParam. | |
std::string | Value () const |
Gets the value of the PosParam. | |
virtual std::string | Name () const override |
Gets the name of the PosParam. | |
virtual std::string | Description () const override |
Gets the description of the PosParam. | |
virtual std::string | HelpInfo () const override |
Gets help info for the PosParam. | |
virtual bool | IsSpecified () const override |
Indicates whether the PosParam has been specified. | |
virtual bool | IsMandatory () const override |
Indicates whether the PosParam is mandatory. | |
bool | Populate (std::deque< std::string > &args) override |
Populates this PosParam from an argument queue. | |
bool | CanPopulate (const std::deque< std::string > &args) const override |
Determines if arguments can populate this PosParam. | |
std::size_t | Consumes (const std::deque< std::string > &args) const override |
Gets the number of arguments the PosParam consumes. | |
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 Positional command line ArgParam.
A PosParam is a command line ArgParam that is populated based on the position of the command line arguments. Exactly one argument populates a PosParam by both specifying it and populating its value. By default, PosParams are populated after all Options have been parsed. However, if a MultiPosParam is also set on the Parser with a MultiPosParam::ParsingOrder of AfterOptions, then PosParams will be populated at the end. An example of when to use a PosParam is a copy program that has multiple source file paths and a single desitination path. The single destination path would populate a PosParam while the multile source paths would be captured by a MultiPosParam.
CmdLine::PosParam::PosParam | ( | Definition | d | ) |
Constructs a new PosParam.
d | The definition to construct the PosParam with. |
Param::InvalidDefinition | Doesn't satisfy invariants. |
|
overridevirtual |
Determines if arguments can populate this PosParam.
Accepts a reference to an argument queue (deque) and determines if the next argument in the queue can populate the PosParam.
args | The argument queue to evaluate. |
Implements CmdLine::ArgParam.
|
inlineoverridevirtual |
Gets the number of arguments the PosParam consumes.
Each Positional consumes exactly 1 argument.
arguments | The argument queue to evaluate. |
Implements CmdLine::ArgParam.
|
inlineoverridevirtual |
Gets the description of the PosParam.
The description of the PosParam is used for generating help.
Implements CmdLine::Param.
|
overridevirtual |
Gets help info for the PosParam.
The help info will include the name and description of the PosParam when generating help.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Indicates whether the PosParam is mandatory.
The command line Parser uses this to determine if a PosParam must be specified at the command line for parsing to be successful. If a mandatory PosParam is not specified, parsing will fail indicating the program was supplied with bad command line arguments.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Indicates whether the PosParam has been specified.
A PosParam will only indicate it was specified if it has been successfully populated by a command line argument. The Parser also uses this to determine if a mandatory PosParam has been specified.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Gets the name of the PosParam.
The name of the PosParam is used for generating usage and help.
Implements CmdLine::Param.
|
overridevirtual |
Populates this PosParam from an argument queue.
Accepts a reference to an argument queue (deque) and attempts to populate the PosParam from the next argument in the queue. Populating the MultiPosParam marks it as specified and populates it with value from the command line argument. Successful population also consumes the argument from the queue that populated the PosParam.
args | The arguments to populate the PosParam with. |
Implements CmdLine::ArgParam.
|
inline |