diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-01-27 22:06:49 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-01-27 22:06:49 +0100 |
| commit | 06950aab233de6a2f47293d59575bb42f6131660 (patch) | |
| tree | 62f6eed4a6d35414f656d22b9ac7420849018a11 /src/args.hh | |
| parent | 1ef9c463f1efc1adfb62e42ab3dd17e8c6394373 (diff) | |
Complete rewrite using C++ and with shared state support
Diffstat (limited to 'src/args.hh')
| -rw-r--r-- | src/args.hh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/args.hh b/src/args.hh new file mode 100644 index 0000000..b581307 --- /dev/null +++ b/src/args.hh @@ -0,0 +1,53 @@ +#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; + virtual std::string const& arg() const = 0; + +protected: + Option() = default; + Option(Option const&) = delete; + Option& operator=(Option const&) = delete; +}; + +class Args { +public: + virtual ~Args() = default; + + static std::unique_ptr<Args> create(); + + // Returned Option is owned by Args instance. + virtual Option const* add_option( + char short_name, + std::string long_name, + std::string description) = 0; + + virtual Option 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 |
