X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0c109e9e61ae3624f30621b5fd328f354bfa6524..95d54ec2f747d0b89fff42965a781689e7d4db1e:/projects/sgconf/options.h diff --git a/projects/sgconf/options.h b/projects/sgconf/options.h index 696255ff..6b33ee8c 100644 --- a/projects/sgconf/options.h +++ b/projects/sgconf/options.h @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include // size_t @@ -49,7 +51,9 @@ class OPTION void Help(size_t level = 0) const; PARSER_STATE Parse(int argc, char ** argv); + void ParseValue(const std::string & value); bool Check(const char * arg) const; + const std::string & Name() const { return m_longName; } class ERROR : public std::runtime_error { @@ -68,20 +72,46 @@ class OPTION class OPTION_BLOCK { public: - void Add(const std::string & shortName, - const std::string & longName, - ACTION * action, - const std::string & description); - void Add(const std::string & longName, - ACTION * action, - const std::string & description); + OPTION_BLOCK() {} + OPTION_BLOCK(const std::string & description) + : m_description(description) {} + OPTION_BLOCK & Add(const std::string & shortName, + const std::string & longName, + ACTION * action, + const std::string & description); + OPTION_BLOCK & Add(const std::string & longName, + ACTION * action, + const std::string & description); void Help(size_t level) const; PARSER_STATE Parse(int argc, char ** argv); + void ParseFile(const std::string & filePath); + + class ERROR : public std::runtime_error + { + public: + ERROR(const std::string & message) + : std::runtime_error(message.c_str()) {} + }; private: std::vector