Class ae108::cmdline::CommandLineOptionParser
ClassList > ae108 > cmdline > CommandLineOptionParser
Public Functions
| Type | Name |
|---|---|
| CommandLineOptionParser (std::ostream & stream) Create an instance of the class. |
|
| CommandLineOptionParser (const CommandLineOptionParser & other) = delete |
|
| CommandLineOptionParser (CommandLineOptionParser && other) = delete |
|
| CommandLineOptionParser & | operator= (const CommandLineOptionParser & other) = delete |
| CommandLineOptionParser & | operator= (CommandLineOptionParser && other) = delete |
| void | parse (int argc, const char *const * argv) const Parses the command line arguments. If "help" is requested, then help is printed and the application exits with return code 0. If an error occurs, then the error message is printed and the application exits with return code 1. |
| CommandLineOptionParser & | withOption (const char * name, const char * help, T * target) Add a parsed command line option to the parser. A "help" option does not need to be provided since it is added automatically. |
| CommandLineOptionParser & | withOption (const char * name, T * target) Calls withOption with no help text. |
| ~CommandLineOptionParser () = default |
Public Functions Documentation
function CommandLineOptionParser [1/3]
Create an instance of the class.
explicit ae108::cmdline::CommandLineOptionParser::CommandLineOptionParser (
std::ostream & stream
)
Parameters:
streamMessages (e.g. warnings) are printed to this stream.
function CommandLineOptionParser [2/3]
ae108::cmdline::CommandLineOptionParser::CommandLineOptionParser (
const CommandLineOptionParser & other
) = delete
function CommandLineOptionParser [3/3]
ae108::cmdline::CommandLineOptionParser::CommandLineOptionParser (
CommandLineOptionParser && other
) = delete
function operator=
CommandLineOptionParser & ae108::cmdline::CommandLineOptionParser::operator= (
const CommandLineOptionParser & other
) = delete
function operator=
CommandLineOptionParser & ae108::cmdline::CommandLineOptionParser::operator= (
CommandLineOptionParser && other
) = delete
function parse
Parses the command line arguments. If "help" is requested, then help is printed and the application exits with return code 0. If an error occurs, then the error message is printed and the application exits with return code 1.
void ae108::cmdline::CommandLineOptionParser::parse (
int argc,
const char *const * argv
) const
Remark:
Unknown options are ignored and a warning is printed.
function withOption [1/2]
Add a parsed command line option to the parser. A "help" option does not need to be provided since it is added automatically.
template<typename T>
CommandLineOptionParser & ae108::cmdline::CommandLineOptionParser::withOption (
const char * name,
const char * help,
T * target
)
Parameters:
nameThe name of the option, e.g. "verbose" (which will add an option verbose). Use "verbose,v" to also provide "-v".helpA description of the flag.targetThe value of the flag (if any) will be written to this variable. Must be a valid nonzero pointer.
function withOption [2/2]
Calls withOption with no help text.
template<typename T>
CommandLineOptionParser & ae108::cmdline::CommandLineOptionParser::withOption (
const char * name,
T * target
)
function ~CommandLineOptionParser
ae108::cmdline::CommandLineOptionParser::~CommandLineOptionParser () = default
The documentation for this class was generated from the following file cmdline/src/include/ae108/cmdline/CommandLineOptionParser.h