blob: 8442b163b3e1153045b97d4a12c1f479c4520064 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#ifndef ARGS_HH
#define ARGS_HH
#include <iosfwd>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
class Option {
public:
virtual ~Option() = default;
virtual bool is_set() const = 0;
protected:
Option() = default;
Option(Option const&) = delete;
Option& operator=(Option const&) = delete;
};
class OptionWithArg : public Option {
public:
virtual std::string const& arg() const = 0;
};
class Args {
public:
virtual ~Args() = default;
static std::unique_ptr<Args> create();
virtual std::shared_ptr<Option const> add_option(
char short_name,
std::string long_name,
std::string description) = 0;
virtual std::shared_ptr<OptionWithArg const> add_option_with_arg(
char short_name,
std::string long_name,
std::string description,
std::string arg_description) = 0;
virtual bool run(int argc, char** argv, std::string_view prgname,
std::ostream& err, std::vector<std::string>& out) = 0;
virtual void print_descriptions(std::ostream& out,
uint32_t column_width) const = 0;
protected:
Args() = default;
Args(Args const&) = delete;
Args& operator=(Args const&) = delete;
};
#endif // ARGS_HH
|