|
LibCppCmdLine v1.0
A cross-platform C++ library for parsing command line arguments
|
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 Param. | |
| std::string | Description () const override |
| Gets the description of the Param. | |
| bool | IsSpecified () const override |
| Indicates whether the ProgParam has been specified. | |
| bool | IsMandatory () const override |
| Indicates whether the Param is mandatory. | |
| std::string | HelpInfo () const override |
| Gets help information for the Param. | |
| 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 ProgParam is a command line ArgParam that is populated by the program name argument, which is the first command line argument the OS passes to the program by convention. Upon successful population, the parameter's value will be populated by the program name argument, which will also mark the parameter as specified. Even if the value of the program argument is not important to the program, the parameter'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.
| args | 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.
| 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.
|
inlineoverridevirtual |
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 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 Param.
The name of the Param 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 |