From 06950aab233de6a2f47293d59575bb42f6131660 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 27 Jan 2021 22:06:49 +0100 Subject: Complete rewrite using C++ and with shared state support --- src/args.hh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/args.hh (limited to 'src/args.hh') 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 +#include +#include +#include +#include + +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 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* 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 -- cgit v1.2.3-70-g09d2