6#ifndef OPTIONPARSER_HPP_INCLUDE
7#define OPTIONPARSER_HPP_INCLUDE
14#include "geopm/Exception.hpp"
15#include "geopm_public.h"
23 std::ostream &std_out,
24 std::ostream &err_out);
26 std::ostream &std_out,
27 std::ostream &err_out,
28 const std::string &custom_help);
32 const std::string &long_form,
33 const std::string &default_val,
34 const std::string &description);
37 const std::string &long_form,
38 const char *default_val,
39 const std::string &description);
43 const std::string &long_form,
45 const std::string &description);
48 bool parse(
int argc,
const char *
const argv[]);
50 bool is_set(
const std::string &name);
52 std::string
get_value(
const std::string &name);
63 check_add_option(
const std::string &name,
65 const std::string &long_form);
67 format_option(std::ostream &tmp,
68 const std::string &short_form,
69 const std::string &long_form,
70 std::string description);
72 static const std::string M_COPYRIGHT_TEXT;
74 std::string m_prog_name;
75 std::ostream &m_std_out;
76 std::ostream &m_err_out;
77 std::string m_custom_help;
78 std::vector<std::string> m_example_usage;
79 std::vector<std::string> m_option_order;
85 std::string long_form;
88 std::string description;
90 std::map<std::string, struct m_opt_parse_s<bool> > m_bool_opts;
91 std::map<std::string, struct m_opt_parse_s<std::string> > m_str_opts;
92 std::map<char, std::string> m_bool_short_name;
93 std::map<char, std::string> m_str_short_name;
95 std::vector<std::string> m_positional_args;
std::string get_value(const std::string &name)
Look up value of a string option by name.
Definition OptionParser.cpp:163
OptionParser(const std::string &prog_name, std::ostream &std_out, std::ostream &err_out)
Definition OptionParser.cpp:20
void add_option(const std::string &name, char short_form, const std::string &long_form, const std::string &default_val, const std::string &description)
Add an option with a string argument.
Definition OptionParser.cpp:43
void add_example_usage(const std::string &example)
Add an example to the usage output. The program name and indentation should be omitted.
Definition OptionParser.cpp:177
std::string format_help(void)
Returns the usage string containing description of all options.
Definition OptionParser.cpp:182
bool parse(int argc, const char *const argv[])
Parse and save option values. Returns whether program should exit because -h or -v was passed.
Definition OptionParser.cpp:74
std::vector< std::string > get_positional_args(void)
Returns all positional arguments after parsed options.
Definition OptionParser.cpp:173
bool is_set(const std::string &name)
Check the value of a boolean option.
Definition OptionParser.cpp:153
Definition Accumulator.cpp:12