diff options
Diffstat (limited to 'src/args.hh')
| -rw-r--r-- | src/args.hh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/args.hh b/src/args.hh new file mode 100644 index 0000000..8442b16 --- /dev/null +++ b/src/args.hh @@ -0,0 +1,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 |
