X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0907aa4037b12b6b88ee24495d4577a064d4f8db..38f134e6a96c08fdd7d4ed07ca3550e8434d56e9:/projects/sgconf/actions.h?ds=inline diff --git a/projects/sgconf/actions.h b/projects/sgconf/actions.h index 3181a105..f23e566d 100644 --- a/projects/sgconf/actions.h +++ b/projects/sgconf/actions.h @@ -40,17 +40,15 @@ template class FUNC0_ACTION : public ACTION { public: - FUNC0_ACTION(const F & func) : m_func(func) {} + explicit FUNC0_ACTION(const F & func) : m_func(func) {} - virtual ACTION * Clone() const { return new FUNC0_ACTION(*this); } - - virtual std::string ParamDescription() const { return ""; } - virtual std::string DefaultDescription() const { return ""; } - virtual OPTION_BLOCK & Suboptions() { return m_suboptions; } - virtual PARSER_STATE Parse(int argc, char ** argv, void * /*data*/) + std::string ParamDescription() const override { return ""; } + std::string DefaultDescription() const override { return ""; } + OPTION_BLOCK & Suboptions() override { return m_suboptions; } + PARSER_STATE Parse(int argc, char ** argv, void * /*data*/) override { - m_func(); - return PARSER_STATE(true, argc, argv); + m_func(); + return PARSER_STATE(true, argc, argv); } private: @@ -60,9 +58,9 @@ class FUNC0_ACTION : public ACTION template inline -FUNC0_ACTION * MakeFunc0Action(F func) +std::unique_ptr MakeFunc0Action(F func) { -return new FUNC0_ACTION(func); +return std::make_unique>(func); } template @@ -77,7 +75,7 @@ class PARAM_ACTION : public ACTION m_description(paramDescription), m_hasDefault(true) {} - PARAM_ACTION(STG::Optional & param) + explicit PARAM_ACTION(STG::Optional & param) : m_param(param), m_hasDefault(false) {} @@ -88,13 +86,11 @@ class PARAM_ACTION : public ACTION m_hasDefault(false) {} - virtual ACTION * Clone() const { return new PARAM_ACTION(*this); } - - virtual std::string ParamDescription() const { return m_description; } - virtual std::string DefaultDescription() const; - virtual OPTION_BLOCK & Suboptions() { return m_suboptions; } - virtual PARSER_STATE Parse(int argc, char ** argv, void * /*data*/); - virtual void ParseValue(const std::string & value); + std::string ParamDescription() const override { return m_description; } + std::string DefaultDescription() const override; + OPTION_BLOCK & Suboptions() override { return m_suboptions; } + PARSER_STATE Parse(int argc, char ** argv, void * /*data*/) override; + void ParseValue(const std::string & value) override; private: STG::Optional & m_param; @@ -176,26 +172,26 @@ return PARSER_STATE(false, --argc, ++argv); template inline -PARAM_ACTION * MakeParamAction(STG::Optional & param, - const T & defaultValue, - const std::string & paramDescription) +std::unique_ptr MakeParamAction(STG::Optional & param, + const T & defaultValue, + const std::string & paramDescription) { -return new PARAM_ACTION(param, defaultValue, paramDescription); +return std::make_unique>(param, defaultValue, paramDescription); } template inline -PARAM_ACTION * MakeParamAction(STG::Optional & param) +std::unique_ptr MakeParamAction(STG::Optional & param) { -return new PARAM_ACTION(param); +return std::make_unique>(param); } template inline -PARAM_ACTION * MakeParamAction(STG::Optional & param, - const std::string & paramDescription) +std::unique_ptr MakeParamAction(STG::Optional & param, + const std::string & paramDescription) { -return new PARAM_ACTION(param, paramDescription); +return std::make_unique>(param, paramDescription); } class KV_ACTION : public ACTION @@ -207,12 +203,10 @@ class KV_ACTION : public ACTION m_description(paramDescription) {} - virtual ACTION * Clone() const { return new KV_ACTION(*this); } - - virtual std::string ParamDescription() const { return m_description; } - virtual std::string DefaultDescription() const { return ""; } - virtual OPTION_BLOCK & Suboptions() { return m_suboptions; } - virtual PARSER_STATE Parse(int argc, char ** argv, void * data); + std::string ParamDescription() const override { return m_description; } + std::string DefaultDescription() const override { return ""; } + OPTION_BLOCK & Suboptions() override { return m_suboptions; } + PARSER_STATE Parse(int argc, char ** argv, void * data) override; private: std::string m_name; @@ -234,10 +228,10 @@ return PARSER_STATE(false, --argc, ++argv); } inline -KV_ACTION * MakeKVAction(const std::string & name, - const std::string & paramDescription) +std::unique_ptr MakeKVAction(const std::string & name, + const std::string & paramDescription) { -return new KV_ACTION(name, paramDescription); +return std::make_unique(name, paramDescription); } } // namespace SGCONF