#pragma once #include #include #include #include class ArgParser { public: struct StringOption { std::string name; std::string default_value; std::string help; bool required; }; struct IntOption { std::string name; int default_value; std::string help; bool required; }; explicit ArgParser(std::string program_name); void addString(const std::string &name, const std::string &default_value, const std::string &help, bool required = false); void addInt(const std::string &name, int default_value, const std::string &help, bool required = false); bool parse(int argc, char **argv, std::string *error); bool has(const std::string &name) const; std::string getString(const std::string &name) const; int getInt(const std::string &name) const; std::string helpText() const; private: enum class OptionType { kString, kInt }; struct OptionMeta { OptionType type; std::string help; bool required; }; std::string program_name_; std::vector order_; std::unordered_map meta_; std::unordered_map string_values_; std::unordered_map int_values_; std::unordered_map provided_; };