11 #ifndef TLX_CMDLINE_PARSER_HEADER 12 #define TLX_CMDLINE_PARSER_HEADER 84 struct ArgumentUnsigned;
87 struct ArgumentDouble;
88 struct ArgumentBytes32;
89 struct ArgumentBytes64;
90 struct ArgumentString;
91 struct ArgumentStringlist;
137 size_t wraplen,
size_t indent_first = 0,
size_t indent_rest = 0,
138 size_t current = 0,
size_t indent_newline = 0);
215 std::vector<std::string>& dest,
const std::string& desc);
273 std::vector<std::string>& dest,
const std::string& desc);
361 const std::string& keytype, std::vector<std::string>& dest,
422 const std::string& name, std::vector<std::string>& dest,
485 const std::string& name, std::vector<std::string>& dest,
503 const Argument* arg, std::ostream& os);
507 const Argument* arg, std::ostream& os);
518 int argc,
const char*
const* argv, std::ostream& os);
524 bool process(
int argc,
const char*
const* argv);
535 #endif // !TLX_CMDLINE_PARSER_HEADER void add_opt_param_bytes(const std::string &name, uint32_t &dest, const std::string &desc)
void add_unsigned(char key, const std::string &longkey, unsigned int &dest, const std::string &desc)
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)
void add_uint(char key, const std::string &longkey, unsigned int &dest, const std::string &desc)
CmdlineParser & sort()
sort options by key (but not the positional parameters)
void add_param_double(const std::string &name, double &dest, const std::string &desc)
add double parameter [name] with description and store to dest
ArgumentList option_list_
list of options available
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
void set_description(const std::string &description)
Set description of program, text will be wrapped.
~CmdlineParser()
Delete all added arguments.
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
void print_option_error(int argc, const char *const *argv, const Argument *arg, std::ostream &os)
print error about option.
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
bool verbose_process_
verbose processing of arguments
void add_opt_param_uint(const std::string &name, unsigned int &dest, const std::string &desc)
void calc_option_max(const Argument *arg)
update maximum formatting width for new option
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
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
void calc_param_max(const Argument *arg)
update maximum formatting width for new parameter
void add_opt_param_unsigned(const std::string &name, unsigned int &dest, const std::string &desc)
void print_result()
print nicely formatted result of processing to std::cout
ArgumentList param_list_
list of parameters, both required and optional
void add_param_bytes(const std::string &name, uint32_t &dest, const std::string &desc)
CmdlineParser()
Constructor.
void add_param_uint(const std::string &name, unsigned int &dest, const std::string &desc)
void add_bytes(char key, const std::string &longkey, uint32_t &dest, const std::string &desc)
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
static constexpr int max_type_name_
maximum length of a type_name() result
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
std::vector< Argument * > ArgumentList
option and parameter list type
const char * program_name_
argv[0] for usage.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
std::string description_
user set description of program, will be wrapped
Command line parser which automatically fills variables and prints nice usage messages.
size_t param_max_width_
formatting width for parameters, 'param <#>'
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
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
std::string author_
user set author of program, will be wrapped
unsigned int line_wrap_
set line wrap length
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
void add_param_float(const std::string &name, float &dest, const std::string &desc)
add float parameter [name] with description and store to dest
void add_param_stringlist(const std::string &name, std::vector< std::string > &dest, const std::string &desc)
void add_opt_param_int(const std::string &name, int &dest, const std::string &desc)
void set_verbose_process(bool verbose_process)
Set verbose processing of command line arguments.
void add_bool(char key, const std::string &longkey, bool &dest, const std::string &desc)
size_t option_max_width_
formatting width for options, '-s, –switch <#>'
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
void add_opt_param_stringlist(const std::string &name, std::vector< std::string > &dest, const std::string &desc)
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
void set_author(const std::string &author)
Set author of program, will be wrapped.
void add_flag(char key, const std::string &longkey, bool &dest, const std::string &desc)
void add_int(char key, const std::string &longkey, int &dest, const std::string &desc)
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
bool process(int argc, const char *const *argv, std::ostream &os)
void print_param_error(int argc, const char *const *argv, const Argument *arg, std::ostream &os)
print error about parameter.