tlx
CmdlineParser Class Referenceabstract

base class of all options and parameters More...

#include <cmdline_parser.hpp>

Inheritance diagram for CmdlineParser:

Public Member Functions

 Argument (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required)
 contructor filling most attributes More...
 
virtual ~Argument ()=default
 empty virtual destructor More...
 
virtual const char * type_name () const =0
 return formatted type name to user More...
 
virtual bool process (int &argc, const char *const *&argv)=0
 process one item from command line for this argument More...
 
virtual void print_value (std::ostream &os) const =0
 format value to ostream More...
 
std::string param_text () const
 return 'longkey [keytype]' More...
 
std::string option_text () const
 return '-s, –longkey [keytype]' More...
 
 ArgumentBool (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, bool &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 "process" argument: just set to true, no argument is used. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentInt (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, int &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse signed integer using sscanf. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentUnsigned (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, unsigned int &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse unsigned integer using sscanf. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentSizeT (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, size_t &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse size_t using sscanf. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentFloat (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, float &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse unsigned integer using sscanf. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentDouble (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, double &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse unsigned integer using sscanf. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentBytes32 (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, uint32_t &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse byte size using SI/IEC parser. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentBytes64 (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, uint64_t &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 parse byte size using SI/IEC parser. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentString (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, std::string &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 "process" string argument just by storing it. More...
 
void print_value (std::ostream &os) const final
 
 ArgumentStringlist (char key, const std::string &longkey, const std::string &keytype, const std::string &desc, bool required, std::vector< std::string > &dest)
 contructor filling most attributes More...
 
const char * type_name () const final
 
bool process (int &argc, const char *const *&argv) final
 "process" string argument just by storing it in vector. More...
 
void print_value (std::ostream &os) const final
 
 CmdlineParser ()
 Constructor. More...
 
 ~CmdlineParser ()
 Delete all added arguments. More...
 
void set_description (const std::string &description)
 Set description of program, text will be wrapped. More...
 
void set_author (const std::string &author)
 Set author of program, will be wrapped. More...
 
void set_verbose_process (bool verbose_process)
 Set verbose processing of command line arguments. More...
 
void print_usage (std::ostream &os)
 output nicely formatted usage information including description of all parameters and options. More...
 
void print_usage ()
 output to std::cout nicely formatted usage information including description of all parameters and options. More...
 
CmdlineParsersort ()
 sort options by key (but not the positional parameters) More...
 
bool process (int argc, const char *const *argv, std::ostream &os)
 parse command line options as specified by the options and parameters added. More...
 
bool process (int argc, const char *const *argv)
 parse command line options as specified by the options and parameters added. More...
 
void print_result (std::ostream &os)
 print nicely formatted result of processing More...
 
void print_result ()
 print nicely formatted result of processing to std::cout More...
 
Add Option with short -k, –longkey, and description.
void add_bool (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_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, int &dest, const std::string &desc)
 add signed integer option -key, –longkey with description and store to dest More...
 
void add_unsigned (char key, const std::string &longkey, unsigned int &dest, const std::string &desc)
 add unsigned integer option -key, –longkey 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 with description and store to dest. More...
 
void add_size_t (char key, const std::string &longkey, size_t &dest, const std::string &desc)
 add size_t option -key, –longkey with description and store to dest More...
 
void add_float (char key, const std::string &longkey, float &dest, const std::string &desc)
 add float option -key, –longkey 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 with description and store to dest More...
 
void add_bytes (char key, const std::string &longkey, uint32_t &dest, const std::string &desc)
 add SI/IEC suffixes byte size option -key, –longkey and store to 32-bit dest More...
 
void add_bytes (char key, const std::string &longkey, uint64_t &dest, const std::string &desc)
 add SI/IEC suffixes byte size option -key, –longkey and store to 64-bit dest More...
 
void add_string (char key, const std::string &longkey, std::string &dest, const std::string &desc)
 add string option -key, –longkey 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 and store to dest More...
 
Add Option with –longkey and description.
void add_bool (const std::string &longkey, bool &dest, const std::string &desc)
 add boolean option flag –longkey with description and store to dest More...
 
void add_flag (const std::string &longkey, bool &dest, const std::string &desc)
 add boolean option flag –longkey with description and store to dest. More...
 
void add_int (const std::string &longkey, int &dest, const std::string &desc)
 add signed integer option –longkey with description and store to dest More...
 
void add_unsigned (const std::string &longkey, unsigned int &dest, const std::string &desc)
 add unsigned integer option –longkey with description and store to dest More...
 
void add_uint (const std::string &longkey, unsigned int &dest, const std::string &desc)
 add unsigned integer option –longkey with description and store to dest. More...
 
void add_size_t (const std::string &longkey, size_t &dest, const std::string &desc)
 add size_t option –longkey with description and store to dest More...
 
void add_float (const std::string &longkey, float &dest, const std::string &desc)
 add float option –longkey with description and store to dest More...
 
void add_double (const std::string &longkey, double &dest, const std::string &desc)
 add double option –longkey with description and store to dest More...
 
void add_bytes (const std::string &longkey, uint32_t &dest, const std::string &desc)
 add SI/IEC suffixes byte size option –longkey and store to 32-bit dest More...
 
void add_bytes (const std::string &longkey, uint64_t &dest, const std::string &desc)
 add SI/IEC suffixes byte size option –longkey and store to 64-bit dest More...
 
void add_string (const std::string &longkey, std::string &dest, const std::string &desc)
 add string option –longkey and store to dest More...
 
void add_stringlist (const std::string &longkey, std::vector< std::string > &dest, const std::string &desc)
 add string list option –longkey and store to dest More...
 
Add Option with short -k, –longkey, [keytype], and description.
void add_bool (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, 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_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_unsigned (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, 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_size_t (char key, const std::string &longkey, const std::string &keytype, size_t &dest, const std::string &desc)
 add size_t option -key, –longkey [keytype] with description and store to dest More...
 
void add_float (char key, const std::string &longkey, const std::string &keytype, float &dest, const std::string &desc)
 add float option -key, –longkey [keytype] with description and store to 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_bytes (char key, const std::string &longkey, const std::string &keytype, uint32_t &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, uint64_t &dest, const std::string &desc)
 add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit 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_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...
 
Add Required Parameter [name] with description.
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_unsigned (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_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_param_size_t (const std::string &name, size_t &dest, const std::string &desc)
 add size_t parameter [name] with description and store to dest More...
 
void add_param_float (const std::string &name, float &dest, const std::string &desc)
 add float 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_bytes (const std::string &name, uint32_t &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_t &dest, const std::string &desc)
 add SI/IEC suffixes byte size 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...
 
Add Optional Parameter [name] with description.
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_unsigned (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_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_opt_param_size_t (const std::string &name, size_t &dest, const std::string &desc)
 add optional size_t parameter [name] with description and store to dest More...
 
void add_opt_param_float (const std::string &name, float &dest, const std::string &desc)
 add optional float 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_bytes (const std::string &name, uint32_t &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_t &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_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...
 

Static Public Member Functions

static void output_wrap (std::ostream &os, const std::string &text, size_t wraplen, size_t indent_first=0, size_t indent_rest=0, size_t current=0, size_t indent_newline=0)
 Wrap a long string at spaces into lines. More...
 

Public Attributes

char key_
 single letter short option, or 0 is none More...
 
std::string longkey_
 long option key or name for parameters More...
 
std::string keytype_
 option type description, e.g. "<#>" to indicate numbers More...
 
std::string desc_
 longer description, which will be wrapped More...
 
bool required_
 required, process() fails if the option/parameter is not found. More...
 
bool found_
 found during processing of command line More...
 
bool repeated_
 repeated argument, i.e. std::vector<std::string> More...
 

Protected Attributes

bool & dest_
 reference to boolean to set to true More...
 
int & dest_
 
unsigned int & dest_
 
size_t & dest_
 
float & dest_
 
double & dest_
 
uint32_t & dest_
 
uint64_t & dest_
 
std::string & dest_
 
std::vector< std::string > & dest_
 

Private Types

using ArgumentList = std::vector< Argument * >
 option and parameter list type More...
 

Private Member Functions

void calc_option_max (const Argument *arg)
 update maximum formatting width for new option More...
 
void calc_param_max (const Argument *arg)
 update maximum formatting width for new parameter More...
 
void print_option_error (int argc, const char *const *argv, const Argument *arg, std::ostream &os)
 print error about option. More...
 
void print_param_error (int argc, const char *const *argv, const Argument *arg, std::ostream &os)
 print error about parameter. More...
 

Private Attributes

ArgumentList option_list_
 list of options available More...
 
ArgumentList param_list_
 list of parameters, both required and optional More...
 
size_t option_max_width_
 formatting width for options, '-s, –switch <#>' More...
 
size_t param_max_width_
 formatting width for parameters, 'param <#>' More...
 
const char * program_name_
 argv[0] for usage. More...
 
bool verbose_process_
 verbose processing of arguments More...
 
std::string description_
 user set description of program, will be wrapped More...
 
std::string author_
 user set author of program, will be wrapped More...
 
unsigned int line_wrap_
 set line wrap length More...
 

Static Private Attributes

static constexpr int max_type_name_
 maximum length of a type_name() result More...
 

Detailed Description

base class of all options and parameters

Command line parser which automatically fills variables and prints nice usage messages.

specialization of argument for multiple string options or parameters

specialization of argument for string options or parameters

specialization of argument for SI/IEC suffixes byte size options or parameters

specialization of argument for double options or parameters

specialization of argument for float options or parameters

specialization of argument for size_t options or parameters

specialization of argument for unsigned integer options or parameters

specialization of argument for integer options or parameters

specialization of argument for boolean flags (can only be set to true).

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.

#include <iostream>
#include <string>
int main(int argc, char* argv[]) {
// add description and author
cp.set_description("This may some day be a useful program, which solves "
"many serious problems of the real world and achives "
"global peace.");
cp.set_author("Timo Bingmann <tb@panthema.net>");
// add an unsigned integer option --rounds <N>
unsigned rounds = 0;
cp.add_unsigned('r', "rounds", "N", rounds,
"Run N rounds of the experiment.");
// add a byte size argument which the user can enter like '1gi'
uint64_t a_size = 0;
cp.add_bytes('s', "size", a_size,
"Number of bytes to process.");
// add a required parameter
std::string a_filename;
cp.add_param_string("filename", a_filename,
"A filename to process");
// process command line
if (!cp.process(argc, argv))
return -1; // some error occurred and help was always written to user.
std::cout << "Command line parsed okay." << std::endl;
// output for debugging
// do something useful
return 0;
}

When running the program above without arguments, it will print:

$ ./tlx_cmdline_parser_example
Missing required argument for parameter 'filename'

Usage: ./tlx_cmdline_parser_example [options] <filename>

This may some day be a useful program, which solves many serious problems of
the real world and achives global peace.

Author: Timo Bingmann <tb@panthema.net>

Parameters:
  filename  A filename to process
Options:
  -r, --rounds N  Run N rounds of the experiment.
  -s, --size      Number of bytes to process.

Nice output, notice the line wrapping of the description and formatting of parameters and arguments. These too are wrapped if the description is too long.

We now try to give the program some arguments:

$ ./tlx_cmdline_parser_example -s 2GiB -r 42 /dev/null
Option -s, --size set to 2147483648.
Option -r, --rounds N set to 42.
Parameter filename set to "/dev/null".
Command line parsed okay.
Parameters:
  filename        (string)            "/dev/null"
Options:
  -r, --rounds N  (unsigned integer)  42
  -s, --size      (bytes)             2147483648

The output shows pretty much what happens. The command line parser is by default in a verbose mode outputting all arguments and values parsed. The debug summary shows to have values the corresponding variables were set.

One feature worth naming is that the parser also supports lists of strings, i.e. std::vector<std::string> via CmdlineParser::add_param_stringlist() and similar.

Definition at line 40 of file cmdline_parser.cpp.

Member Typedef Documentation

◆ ArgumentList

using ArgumentList = std::vector<Argument*>
private

option and parameter list type

Definition at line 111 of file cmdline_parser.hpp.

Constructor & Destructor Documentation

◆ ~Argument()

virtual ~Argument ( )
virtualdefault

empty virtual destructor

◆ CmdlineParser()

Constructor.

Definition at line 498 of file cmdline_parser.cpp.

◆ ~CmdlineParser()

Delete all added arguments.

Definition at line 500 of file cmdline_parser.cpp.

Member Function Documentation

◆ add_bool() [1/3]

void add_bool ( char  key,
const std::string &  longkey,
bool &  dest,
const std::string &  desc 
)

add boolean option flag -key, –longkey with description and store to dest

Definition at line 620 of file cmdline_parser.cpp.

◆ add_bool() [2/3]

void add_bool ( 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

Definition at line 524 of file cmdline_parser.cpp.

◆ add_bool() [3/3]

void add_bool ( const std::string &  longkey,
bool &  dest,
const std::string &  desc 
)

add boolean option flag –longkey with description and store to dest

Definition at line 683 of file cmdline_parser.cpp.

◆ add_bytes() [1/6]

void add_bytes ( char  key,
const std::string &  longkey,
const std::string &  keytype,
uint32_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest

Definition at line 584 of file cmdline_parser.cpp.

◆ add_bytes() [2/6]

void add_bytes ( char  key,
const std::string &  longkey,
const std::string &  keytype,
uint64_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size option -key, –longkey [keytype] and store to 64-bit dest

Definition at line 592 of file cmdline_parser.cpp.

◆ add_bytes() [3/6]

void add_bytes ( char  key,
const std::string &  longkey,
uint32_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size option -key, –longkey and store to 32-bit dest

Definition at line 660 of file cmdline_parser.cpp.

◆ add_bytes() [4/6]

void add_bytes ( char  key,
const std::string &  longkey,
uint64_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size option -key, –longkey and store to 64-bit dest

Definition at line 665 of file cmdline_parser.cpp.

◆ add_bytes() [5/6]

void add_bytes ( const std::string &  longkey,
uint32_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size option –longkey and store to 32-bit dest

Definition at line 723 of file cmdline_parser.cpp.

◆ add_bytes() [6/6]

void add_bytes ( const std::string &  longkey,
uint64_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size option –longkey and store to 64-bit dest

Definition at line 728 of file cmdline_parser.cpp.

◆ add_double() [1/3]

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

Definition at line 576 of file cmdline_parser.cpp.

◆ add_double() [2/3]

void add_double ( char  key,
const std::string &  longkey,
double &  dest,
const std::string &  desc 
)

add double option -key, –longkey with description and store to dest

Definition at line 655 of file cmdline_parser.cpp.

◆ add_double() [3/3]

void add_double ( const std::string &  longkey,
double &  dest,
const std::string &  desc 
)

add double option –longkey with description and store to dest

Definition at line 718 of file cmdline_parser.cpp.

◆ add_flag() [1/3]

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.

identical to add_bool()

Definition at line 625 of file cmdline_parser.cpp.

◆ add_flag() [2/3]

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.

identical to add_bool()

Definition at line 532 of file cmdline_parser.cpp.

◆ add_flag() [3/3]

void add_flag ( const std::string &  longkey,
bool &  dest,
const std::string &  desc 
)

add boolean option flag –longkey with description and store to dest.

identical to add_bool()

Definition at line 688 of file cmdline_parser.cpp.

◆ add_float() [1/3]

void add_float ( char  key,
const std::string &  longkey,
const std::string &  keytype,
float &  dest,
const std::string &  desc 
)

add float option -key, –longkey [keytype] with description and store to dest

Definition at line 568 of file cmdline_parser.cpp.

◆ add_float() [2/3]

void add_float ( char  key,
const std::string &  longkey,
float &  dest,
const std::string &  desc 
)

add float option -key, –longkey with description and store to dest

Definition at line 650 of file cmdline_parser.cpp.

◆ add_float() [3/3]

void add_float ( const std::string &  longkey,
float &  dest,
const std::string &  desc 
)

add float option –longkey with description and store to dest

Definition at line 713 of file cmdline_parser.cpp.

◆ add_int() [1/3]

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

Definition at line 538 of file cmdline_parser.cpp.

◆ add_int() [2/3]

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

Definition at line 630 of file cmdline_parser.cpp.

◆ add_int() [3/3]

void add_int ( const std::string &  longkey,
int &  dest,
const std::string &  desc 
)

add signed integer option –longkey with description and store to dest

Definition at line 693 of file cmdline_parser.cpp.

◆ add_opt_param_bytes() [1/2]

void add_opt_param_bytes ( const std::string &  name,
uint32_t &  dest,
const std::string &  desc 
)

add optional SI/IEC suffixes byte size parameter [name] with description and store to dest

Definition at line 849 of file cmdline_parser.cpp.

◆ add_opt_param_bytes() [2/2]

void add_opt_param_bytes ( const std::string &  name,
uint64_t &  dest,
const std::string &  desc 
)

add optional SI/IEC suffixes byte size parameter [name] with description and store to dest

Definition at line 856 of file cmdline_parser.cpp.

◆ add_opt_param_double()

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

Definition at line 842 of file cmdline_parser.cpp.

◆ add_opt_param_float()

void add_opt_param_float ( const std::string &  name,
float &  dest,
const std::string &  desc 
)

add optional float parameter [name] with description and store to dest

Definition at line 836 of file cmdline_parser.cpp.

◆ add_opt_param_int()

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

Definition at line 812 of file cmdline_parser.cpp.

◆ add_opt_param_size_t()

void add_opt_param_size_t ( const std::string &  name,
size_t &  dest,
const std::string &  desc 
)

add optional size_t parameter [name] with description and store to dest

Definition at line 830 of file cmdline_parser.cpp.

◆ add_opt_param_string()

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

Definition at line 863 of file cmdline_parser.cpp.

◆ add_opt_param_stringlist()

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

Warning
this parameter must be last, as it will gobble all non-option arguments!

Definition at line 870 of file cmdline_parser.cpp.

◆ add_opt_param_uint()

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.

identical to add_unsigned()

Definition at line 825 of file cmdline_parser.cpp.

◆ add_opt_param_unsigned()

void add_opt_param_unsigned ( const std::string &  name,
unsigned int &  dest,
const std::string &  desc 
)

add optional unsigned integer parameter [name] with description and store to dest

Definition at line 818 of file cmdline_parser.cpp.

◆ add_param_bytes() [1/2]

void add_param_bytes ( const std::string &  name,
uint32_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size parameter [name] with description and store to dest

Definition at line 782 of file cmdline_parser.cpp.

◆ add_param_bytes() [2/2]

void add_param_bytes ( const std::string &  name,
uint64_t &  dest,
const std::string &  desc 
)

add SI/IEC suffixes byte size parameter [name] with description and store to dest

Definition at line 789 of file cmdline_parser.cpp.

◆ add_param_double()

void add_param_double ( const std::string &  name,
double &  dest,
const std::string &  desc 
)

add double parameter [name] with description and store to dest

Definition at line 776 of file cmdline_parser.cpp.

◆ add_param_float()

void add_param_float ( const std::string &  name,
float &  dest,
const std::string &  desc 
)

add float parameter [name] with description and store to dest

Definition at line 770 of file cmdline_parser.cpp.

◆ add_param_int()

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

Definition at line 746 of file cmdline_parser.cpp.

◆ add_param_size_t()

void add_param_size_t ( const std::string &  name,
size_t &  dest,
const std::string &  desc 
)

add size_t parameter [name] with description and store to dest

Definition at line 764 of file cmdline_parser.cpp.

◆ add_param_string()

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

Definition at line 796 of file cmdline_parser.cpp.

◆ add_param_stringlist()

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.

Warning
this parameter must be last, as it will gobble all non-option arguments!

Definition at line 802 of file cmdline_parser.cpp.

◆ add_param_uint()

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.

identical to add_unsigned()

Definition at line 759 of file cmdline_parser.cpp.

◆ add_param_unsigned()

void add_param_unsigned ( const std::string &  name,
unsigned int &  dest,
const std::string &  desc 
)

add unsigned integer parameter [name] with description and store to dest

Definition at line 752 of file cmdline_parser.cpp.

◆ add_size_t() [1/3]

void add_size_t ( char  key,
const std::string &  longkey,
const std::string &  keytype,
size_t &  dest,
const std::string &  desc 
)

add size_t option -key, –longkey [keytype] with description and store to dest

Definition at line 560 of file cmdline_parser.cpp.

◆ add_size_t() [2/3]

void add_size_t ( char  key,
const std::string &  longkey,
size_t &  dest,
const std::string &  desc 
)

add size_t option -key, –longkey with description and store to dest

Definition at line 645 of file cmdline_parser.cpp.

◆ add_size_t() [3/3]

void add_size_t ( const std::string &  longkey,
size_t &  dest,
const std::string &  desc 
)

add size_t option –longkey with description and store to dest

Definition at line 708 of file cmdline_parser.cpp.

◆ add_string() [1/3]

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

Definition at line 600 of file cmdline_parser.cpp.

◆ add_string() [2/3]

void add_string ( char  key,
const std::string &  longkey,
std::string &  dest,
const std::string &  desc 
)

add string option -key, –longkey and store to dest

Definition at line 670 of file cmdline_parser.cpp.

◆ add_string() [3/3]

void add_string ( const std::string &  longkey,
std::string &  dest,
const std::string &  desc 
)

add string option –longkey and store to dest

Definition at line 733 of file cmdline_parser.cpp.

◆ add_stringlist() [1/3]

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

Definition at line 608 of file cmdline_parser.cpp.

◆ add_stringlist() [2/3]

void add_stringlist ( char  key,
const std::string &  longkey,
std::vector< std::string > &  dest,
const std::string &  desc 
)

add string list option -key, –longkey and store to dest

Definition at line 675 of file cmdline_parser.cpp.

◆ add_stringlist() [3/3]

void add_stringlist ( const std::string &  longkey,
std::vector< std::string > &  dest,
const std::string &  desc 
)

add string list option –longkey and store to dest

Definition at line 738 of file cmdline_parser.cpp.

◆ add_uint() [1/3]

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.

identical to add_unsigned()

Definition at line 554 of file cmdline_parser.cpp.

◆ add_uint() [2/3]

void add_uint ( char  key,
const std::string &  longkey,
unsigned int &  dest,
const std::string &  desc 
)

add unsigned integer option -key, –longkey with description and store to dest.

identical to add_unsigned()

Definition at line 640 of file cmdline_parser.cpp.

◆ add_uint() [3/3]

void add_uint ( const std::string &  longkey,
unsigned int &  dest,
const std::string &  desc 
)

add unsigned integer option –longkey with description and store to dest.

identical to add_unsigned()

Definition at line 703 of file cmdline_parser.cpp.

◆ add_unsigned() [1/3]

void add_unsigned ( 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

Definition at line 546 of file cmdline_parser.cpp.

◆ add_unsigned() [2/3]

void add_unsigned ( char  key,
const std::string &  longkey,
unsigned int &  dest,
const std::string &  desc 
)

add unsigned integer option -key, –longkey with description and store to dest

Definition at line 635 of file cmdline_parser.cpp.

◆ add_unsigned() [3/3]

void add_unsigned ( const std::string &  longkey,
unsigned int &  dest,
const std::string &  desc 
)

add unsigned integer option –longkey with description and store to dest

Definition at line 698 of file cmdline_parser.cpp.

◆ Argument()

Argument ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required 
)
inline

contructor filling most attributes

Definition at line 68 of file cmdline_parser.cpp.

◆ ArgumentBool()

ArgumentBool ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
bool &  dest 
)
inline

contructor filling most attributes

Definition at line 113 of file cmdline_parser.cpp.

◆ ArgumentBytes32()

ArgumentBytes32 ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
uint32_t &  dest 
)
inline

contructor filling most attributes

Definition at line 317 of file cmdline_parser.cpp.

◆ ArgumentBytes64()

ArgumentBytes64 ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
uint64_t &  dest 
)
inline

contructor filling most attributes

Definition at line 352 of file cmdline_parser.cpp.

◆ ArgumentDouble()

ArgumentDouble ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
double &  dest 
)
inline

contructor filling most attributes

Definition at line 282 of file cmdline_parser.cpp.

◆ ArgumentFloat()

ArgumentFloat ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
float &  dest 
)
inline

contructor filling most attributes

Definition at line 249 of file cmdline_parser.cpp.

◆ ArgumentInt()

ArgumentInt ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
int &  dest 
)
inline

contructor filling most attributes

Definition at line 141 of file cmdline_parser.cpp.

◆ ArgumentSizeT()

ArgumentSizeT ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
size_t &  dest 
)
inline

contructor filling most attributes

Definition at line 213 of file cmdline_parser.cpp.

◆ ArgumentString()

ArgumentString ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
std::string &  dest 
)
inline

contructor filling most attributes

Definition at line 384 of file cmdline_parser.cpp.

◆ ArgumentStringlist()

ArgumentStringlist ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
std::vector< std::string > &  dest 
)
inline

contructor filling most attributes

Definition at line 414 of file cmdline_parser.cpp.

◆ ArgumentUnsigned()

ArgumentUnsigned ( char  key,
const std::string &  longkey,
const std::string &  keytype,
const std::string &  desc,
bool  required,
unsigned int &  dest 
)
inline

contructor filling most attributes

Definition at line 177 of file cmdline_parser.cpp.

◆ calc_option_max()

void calc_option_max ( const Argument arg)
private

update maximum formatting width for new option

Definition at line 445 of file cmdline_parser.cpp.

◆ calc_param_max()

void calc_param_max ( const Argument arg)
private

update maximum formatting width for new parameter

Definition at line 450 of file cmdline_parser.cpp.

◆ option_text()

std::string option_text ( ) const
inline

return '-s, –longkey [keytype]'

Definition at line 95 of file cmdline_parser.cpp.

◆ output_wrap()

void output_wrap ( std::ostream &  os,
const std::string &  text,
size_t  wraplen,
size_t  indent_first = 0,
size_t  indent_rest = 0,
size_t  current = 0,
size_t  indent_newline = 0 
)
static

Wrap a long string at spaces into lines.

Prefix is added unconditionally to each line. Lines are wrapped after wraplen characters if possible.

Definition at line 457 of file cmdline_parser.cpp.

◆ param_text()

std::string param_text ( ) const
inline

return 'longkey [keytype]'

Definition at line 86 of file cmdline_parser.cpp.

◆ print_option_error()

void print_option_error ( int  argc,
const char *const *  argv,
const Argument arg,
std::ostream &  os 
)
private

print error about option.

Definition at line 950 of file cmdline_parser.cpp.

◆ print_param_error()

void print_param_error ( int  argc,
const char *const *  argv,
const Argument arg,
std::ostream &  os 
)
private

print error about parameter.

Definition at line 963 of file cmdline_parser.cpp.

◆ print_result() [1/2]

void print_result ( )

print nicely formatted result of processing to std::cout

Definition at line 1168 of file cmdline_parser.cpp.

◆ print_result() [2/2]

void print_result ( std::ostream &  os)

print nicely formatted result of processing

Definition at line 1122 of file cmdline_parser.cpp.

◆ print_usage() [1/2]

void print_usage ( )

output to std::cout nicely formatted usage information including description of all parameters and options.

Definition at line 946 of file cmdline_parser.cpp.

◆ print_usage() [2/2]

void print_usage ( std::ostream &  os)

output nicely formatted usage information including description of all parameters and options.

Definition at line 888 of file cmdline_parser.cpp.

◆ print_value() [1/11]

virtual void print_value ( std::ostream &  os) const
pure virtual

format value to ostream

◆ print_value() [2/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 127 of file cmdline_parser.cpp.

◆ print_value() [3/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 165 of file cmdline_parser.cpp.

◆ print_value() [4/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 201 of file cmdline_parser.cpp.

◆ print_value() [5/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 237 of file cmdline_parser.cpp.

◆ print_value() [6/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 271 of file cmdline_parser.cpp.

◆ print_value() [7/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 304 of file cmdline_parser.cpp.

◆ print_value() [8/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 340 of file cmdline_parser.cpp.

◆ print_value() [9/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 372 of file cmdline_parser.cpp.

◆ print_value() [10/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 400 of file cmdline_parser.cpp.

◆ print_value() [11/11]

void print_value ( std::ostream &  os) const
inlinefinal

Definition at line 432 of file cmdline_parser.cpp.

◆ process() [1/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

"process" argument: just set to true, no argument is used.

Definition at line 121 of file cmdline_parser.cpp.

◆ process() [2/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse signed integer using sscanf.

Definition at line 149 of file cmdline_parser.cpp.

◆ process() [3/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse unsigned integer using sscanf.

Definition at line 185 of file cmdline_parser.cpp.

◆ process() [4/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse size_t using sscanf.

Definition at line 221 of file cmdline_parser.cpp.

◆ process() [5/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse unsigned integer using sscanf.

Definition at line 257 of file cmdline_parser.cpp.

◆ process() [6/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse unsigned integer using sscanf.

Definition at line 290 of file cmdline_parser.cpp.

◆ process() [7/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse byte size using SI/IEC parser.

Definition at line 325 of file cmdline_parser.cpp.

◆ process() [8/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

parse byte size using SI/IEC parser.

Definition at line 360 of file cmdline_parser.cpp.

◆ process() [9/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

"process" string argument just by storing it.

Definition at line 392 of file cmdline_parser.cpp.

◆ process() [10/13]

bool process ( int &  argc,
const char *const *&  argv 
)
inlinefinal

"process" string argument just by storing it in vector.

Definition at line 424 of file cmdline_parser.cpp.

◆ process() [11/13]

virtual bool process ( int &  argc,
const char *const *&  argv 
)
pure virtual

process one item from command line for this argument

◆ process() [12/13]

bool process ( int  argc,
const char *const *  argv 
)

parse command line options as specified by the options and parameters added.

Returns
true if command line is okay and all required parameters are present.

Definition at line 1118 of file cmdline_parser.cpp.

◆ process() [13/13]

bool process ( int  argc,
const char *const *  argv,
std::ostream &  os 
)

parse command line options as specified by the options and parameters added.

Returns
true if command line is okay and all required parameters are present.

Definition at line 976 of file cmdline_parser.cpp.

◆ set_author()

void set_author ( const std::string &  author)

Set author of program, will be wrapped.

Definition at line 514 of file cmdline_parser.cpp.

◆ set_description()

void set_description ( const std::string &  description)

Set description of program, text will be wrapped.

Definition at line 510 of file cmdline_parser.cpp.

◆ set_verbose_process()

void set_verbose_process ( bool  verbose_process)

Set verbose processing of command line arguments.

Definition at line 518 of file cmdline_parser.cpp.

◆ sort()

CmdlineParser & sort ( )

sort options by key (but not the positional parameters)

Definition at line 880 of file cmdline_parser.cpp.

◆ type_name() [1/11]

virtual const char* type_name ( ) const
pure virtual

return formatted type name to user

◆ type_name() [2/11]

const char* type_name ( ) const
inlinefinal

Definition at line 118 of file cmdline_parser.cpp.

◆ type_name() [3/11]

const char* type_name ( ) const
inlinefinal

Definition at line 146 of file cmdline_parser.cpp.

◆ type_name() [4/11]

const char* type_name ( ) const
inlinefinal

Definition at line 182 of file cmdline_parser.cpp.

◆ type_name() [5/11]

const char* type_name ( ) const
inlinefinal

Definition at line 218 of file cmdline_parser.cpp.

◆ type_name() [6/11]

const char* type_name ( ) const
inlinefinal

Definition at line 254 of file cmdline_parser.cpp.

◆ type_name() [7/11]

const char* type_name ( ) const
inlinefinal

Definition at line 287 of file cmdline_parser.cpp.

◆ type_name() [8/11]

const char* type_name ( ) const
inlinefinal

Definition at line 322 of file cmdline_parser.cpp.

◆ type_name() [9/11]

const char* type_name ( ) const
inlinefinal

Definition at line 357 of file cmdline_parser.cpp.

◆ type_name() [10/11]

const char* type_name ( ) const
inlinefinal

Definition at line 389 of file cmdline_parser.cpp.

◆ type_name() [11/11]

const char* type_name ( ) const
inlinefinal

Definition at line 421 of file cmdline_parser.cpp.

Member Data Documentation

◆ author_

std::string author_
private

user set author of program, will be wrapped

Definition at line 132 of file cmdline_parser.hpp.

◆ desc_

std::string desc_

longer description, which will be wrapped

Definition at line 58 of file cmdline_parser.cpp.

◆ description_

std::string description_
private

user set description of program, will be wrapped

Definition at line 130 of file cmdline_parser.hpp.

◆ dest_ [1/10]

bool& dest_
protected

reference to boolean to set to true

Definition at line 109 of file cmdline_parser.cpp.

◆ dest_ [2/10]

int& dest_
protected

Definition at line 137 of file cmdline_parser.cpp.

◆ dest_ [3/10]

unsigned int& dest_
protected

Definition at line 173 of file cmdline_parser.cpp.

◆ dest_ [4/10]

size_t& dest_
protected

Definition at line 209 of file cmdline_parser.cpp.

◆ dest_ [5/10]

float& dest_
protected

Definition at line 245 of file cmdline_parser.cpp.

◆ dest_ [6/10]

double& dest_
protected

Definition at line 278 of file cmdline_parser.cpp.

◆ dest_ [7/10]

uint32_t& dest_
protected

Definition at line 313 of file cmdline_parser.cpp.

◆ dest_ [8/10]

uint64_t& dest_
protected

Definition at line 348 of file cmdline_parser.cpp.

◆ dest_ [9/10]

std::string& dest_
protected

Definition at line 380 of file cmdline_parser.cpp.

◆ dest_ [10/10]

std::vector<std::string>& dest_
protected

Definition at line 410 of file cmdline_parser.cpp.

◆ found_

bool found_

found during processing of command line

Definition at line 62 of file cmdline_parser.cpp.

◆ key_

char key_

single letter short option, or 0 is none

Definition at line 52 of file cmdline_parser.cpp.

◆ keytype_

std::string keytype_

option type description, e.g. "<#>" to indicate numbers

Definition at line 56 of file cmdline_parser.cpp.

◆ line_wrap_

unsigned int line_wrap_
private

set line wrap length

Definition at line 135 of file cmdline_parser.hpp.

◆ longkey_

std::string longkey_

long option key or name for parameters

Definition at line 54 of file cmdline_parser.cpp.

◆ max_type_name_

constexpr int max_type_name_
staticconstexprprivate

maximum length of a type_name() result

Definition at line 138 of file cmdline_parser.hpp.

◆ option_list_

ArgumentList option_list_
private

list of options available

Definition at line 114 of file cmdline_parser.hpp.

◆ option_max_width_

size_t option_max_width_
private

formatting width for options, '-s, –switch <#>'

Definition at line 119 of file cmdline_parser.hpp.

◆ param_list_

ArgumentList param_list_
private

list of parameters, both required and optional

Definition at line 116 of file cmdline_parser.hpp.

◆ param_max_width_

size_t param_max_width_
private

formatting width for parameters, 'param <#>'

Definition at line 121 of file cmdline_parser.hpp.

◆ program_name_

const char* program_name_
private

argv[0] for usage.

Definition at line 124 of file cmdline_parser.hpp.

◆ repeated_

bool repeated_

repeated argument, i.e. std::vector<std::string>

Definition at line 64 of file cmdline_parser.cpp.

◆ required_

bool required_

required, process() fails if the option/parameter is not found.

Definition at line 60 of file cmdline_parser.cpp.

◆ verbose_process_

bool verbose_process_
private

verbose processing of arguments

Definition at line 127 of file cmdline_parser.hpp.


The documentation for this class was generated from the following files:
tlx::CmdlineParser
base class of all options and parameters
Definition: cmdline_parser.cpp:41
cmdline_parser.hpp
tlx::CmdlineParser::add_param_string
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
Definition: cmdline_parser.cpp:796
tlx::CmdlineParser::process
virtual bool process(int &argc, const char *const *&argv)=0
process one item from command line for this argument
tlx::CmdlineParser::set_author
void set_author(const std::string &author)
Set author of program, will be wrapped.
Definition: cmdline_parser.cpp:514
tlx::CmdlineParser::add_bytes
void add_bytes(char key, const std::string &longkey, uint32_t &dest, const std::string &desc)
add SI/IEC suffixes byte size option -key, –longkey and store to 32-bit dest
Definition: cmdline_parser.cpp:660
tlx::CmdlineParser::add_unsigned
void add_unsigned(char key, const std::string &longkey, unsigned int &dest, const std::string &desc)
add unsigned integer option -key, –longkey with description and store to dest
Definition: cmdline_parser.cpp:635
tlx::CmdlineParser::set_description
void set_description(const std::string &description)
Set description of program, text will be wrapped.
Definition: cmdline_parser.cpp:510
tlx::CmdlineParser::print_result
void print_result(std::ostream &os)
print nicely formatted result of processing
Definition: cmdline_parser.cpp:1122