CmdLine API Documentation#
-
class CommandLineOptionParser#
Public Functions
-
explicit CommandLineOptionParser(std::ostream &stream)#
Create an instance of the class.
- Parameters:
stream – Messages (e.g. warnings) are printed to this stream.
-
template<typename T>
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.
- Parameters:
name – The name of the option, e.g. “verbose” (which will add an option —verbose). Use “verbose,v” to also provide “-v”.
help – A description of the flag.
target – The value of the flag (if any) will be written to this variable. Must be a valid nonzero pointer.
-
template<typename T>
CommandLineOptionParser &withOption(const char *name, T *target)# Calls withOption with no help text.
-
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.
Remark
Unknown options are ignored and a warning is printed.
-
explicit CommandLineOptionParser(std::ostream &stream)#