#ifndef CBLIB_ARGUMENT_H #define CBLIB_ARGUMENT_H #include #include namespace cb::argparser { enum class Mode { POSITIONAL_MODE, REQUIRED_MODE, OPTIONAL_MODE, }; enum class Type { STRING_TYPE, BOOL_TYPE, INTEGER_TYPE, }; struct ParseArgument { std::string short_name; std::string name; std::string description; std::string default_value; Type type; Mode mode; bool is_present{false}; }; class Argument { private: std::string content; Type type{Type::STRING_TYPE}; public: Argument() = default; explicit Argument(std::string content, Type type = Type::STRING_TYPE); [[nodiscard]] const std::string &as_str() const { return content; } [[nodiscard]] bool as_bool() const { return !content.empty(); } int as_int() { assert(type == Type::INTEGER_TYPE); return std::stoi(content); } explicit operator bool() const { return as_bool(); } }; } #endif //CBLIB_ARGUMENT_H