Command line parser which automatically fills variables and prints nice usage messages.
This is a straightforward command line parser in C++, which will recognize short options -s, long options –long and parameters, both required and optional. It will automatically parse integers and byte sizes with SI/IEC suffixes (e.g. 1 GiB). It also works with lists of strings, e.g. multiple filenames.
Maybe most important it will nicely format the options and parameters description using word wrapping.
- Examples:
- examples/applications/skew3.cpp, and examples/common/cmdline.cpp.
Definition at line 45 of file cmdline.h.
|
| cmdline_parser () |
| Construct new command line parser. More...
|
|
| ~cmdline_parser () |
| Delete all added arguments. More...
|
|
void | add_bytes (char key, const std::string &longkey, const std::string &keytype, stxxl::uint32 &dest, const std::string &desc) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest More...
|
|
void | add_bytes (char key, const std::string &longkey, const std::string &keytype, stxxl::uint64 &dest, const std::string &desc) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest More...
|
|
void | add_bytes (char key, const std::string &longkey, stxxl::uint32 &dest, const std::string &desc) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 32-bit dest More...
|
|
void | add_bytes (char key, const std::string &longkey, stxxl::uint64 &dest, const std::string &desc) |
| add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest More...
|
|
void | add_double (char key, const std::string &longkey, const std::string &keytype, double &dest, const std::string &desc) |
| add double option -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_double (char key, const std::string &longkey, double &dest, const std::string &desc) |
| add double option -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_flag (char key, const std::string &longkey, const std::string &keytype, bool &dest, const std::string &desc) |
| add boolean option flag -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_flag (char key, const std::string &longkey, bool &dest, const std::string &desc) |
| add boolean option flag -key, –longkey with description and store to dest More...
|
|
void | add_int (char key, const std::string &longkey, const std::string &keytype, int &dest, const std::string &desc) |
| add signed integer option -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_int (char key, const std::string &longkey, int &dest, const std::string &desc) |
| add signed integer option -key, –longkey with description and store to dest More...
|
|
void | add_opt_param_bytes (const std::string &name, uint32 &dest, const std::string &desc) |
| add optional SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_opt_param_bytes (const std::string &name, uint64 &dest, const std::string &desc) |
| add optional SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_opt_param_double (const std::string &name, double &dest, const std::string &desc) |
| add optional double parameter [name] with description and store to dest More...
|
|
void | add_opt_param_int (const std::string &name, int &dest, const std::string &desc) |
| add optional signed integer parameter [name] with description and store to dest More...
|
|
void | add_opt_param_string (const std::string &name, std::string &dest, const std::string &desc) |
| add optional string parameter [name] with description and store to dest More...
|
|
void | add_opt_param_stringlist (const std::string &name, std::vector< std::string > &dest, const std::string &desc) |
| add optional string parameter [name] with description and store to dest More...
|
|
void | add_opt_param_uint (const std::string &name, unsigned int &dest, const std::string &desc) |
| add optional unsigned integer parameter [name] with description and store to dest More...
|
|
void | add_param_bytes (const std::string &name, uint32 &dest, const std::string &desc) |
| add SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_param_bytes (const std::string &name, uint64 &dest, const std::string &desc) |
| add SI/IEC suffixes byte size parameter [name] with description and store to dest More...
|
|
void | add_param_double (const std::string &name, double &dest, const std::string &desc) |
| add double parameter [name] with description and store to dest More...
|
|
void | add_param_int (const std::string &name, int &dest, const std::string &desc) |
| add signed integer parameter [name] with description and store to dest More...
|
|
void | add_param_string (const std::string &name, std::string &dest, const std::string &desc) |
| add string parameter [name] with description and store to dest More...
|
|
void | add_param_stringlist (const std::string &name, std::vector< std::string > &dest, const std::string &desc) |
| add string list parameter [name] with description and store to dest. More...
|
|
void | add_param_uint (const std::string &name, unsigned int &dest, const std::string &desc) |
| add unsigned integer parameter [name] with description and store to dest More...
|
|
void | add_string (char key, const std::string &longkey, const std::string &keytype, std::string &dest, const std::string &desc) |
| add string option -key, –longkey [keytype] and store to dest More...
|
|
void | add_string (char key, const std::string &longkey, std::string &dest, const std::string &desc) |
| add string option -key, –longkey [keytype] and store to dest More...
|
|
void | add_stringlist (char key, const std::string &longkey, const std::string &keytype, std::vector< std::string > &dest, const std::string &desc) |
| add string list option -key, –longkey [keytype] and store to dest More...
|
|
void | add_stringlist (char key, const std::string &longkey, std::vector< std::string > &dest, const std::string &desc) |
| add string list option -key, –longkey [keytype] and store to dest More...
|
|
void | add_uint (char key, const std::string &longkey, const std::string &keytype, unsigned int &dest, const std::string &desc) |
| add unsigned integer option -key, –longkey [keytype] with description and store to dest More...
|
|
void | add_uint (char key, const std::string &longkey, unsigned int &dest, const std::string &desc) |
| add unsigned integer option -key, –longkey [keytype] with description and store to dest More...
|
|
void | print_result (std::ostream &os=std::cout) |
| print nicely formatted result of processing More...
|
|
void | print_usage (std::ostream &os=std::cout) |
| output nicely formatted usage information including description of all parameters and options. More...
|
|
bool | process (int argc, const char *const *argv, std::ostream &os=std::cout) |
| parse command line options as specified by the options and parameters added. More...
|
|
void | set_author (const std::string &author) |
| Set author of program, will be wrapped. More...
|
|
void | set_description (const std::string &description) |
| Set description of program, text will be wrapped. More...
|
|
void | set_verbose_process (bool verbose_process) |
| Set verbose processing of command line arguments. More...
|
|