|
LibCppCmdLine v1.0
A cross-platform C++ library for parsing command line arguments
|
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 Param. | |
| virtual std::string | Description () const override |
| Gets the description of the Param. | |
| virtual std::string | HelpInfo () const override |
| Gets help information for the Param. | |
| virtual bool | IsSpecified () const override |
| Indicates whether the Param has been specified. | |
| virtual bool | IsMandatory () const override |
| Indicates whether the Param 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 the specified args can populate the ArgParam. | |
| 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 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.
| args | The argument queue to evaluate. |
Implements CmdLine::ArgParam.
|
inlineoverridevirtual |
Gets the number of arguments the PosParam consumes.
Each Positional consumes exactly 1 argument.
| args | The argument queue to evaluate. |
Implements CmdLine::ArgParam.
|
inlineoverridevirtual |
Gets the description of the Param.
The description of the Param is used for generating help.
Implements CmdLine::Param.
|
overridevirtual |
Gets help information for the Param.
The help info will include the Name() and Description() of the parameter when generating help.
Implements CmdLine::Param.
|
inlineoverridevirtual |
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.
Implements CmdLine::Param.
|
inlineoverridevirtual |
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.
Implements CmdLine::Param.
|
inlineoverridevirtual |
Gets the name of the Param.
The name of the Param 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 |