X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/df2bb45e41303b5132feb6b264caaa01c31b8bb5..d625e80d62fc8b98c18a95c65e6fa329b7fcc85b:/projects/sgconf/actions.h diff --git a/projects/sgconf/actions.h b/projects/sgconf/actions.h index 739fbf14..886e17e2 100644 --- a/projects/sgconf/actions.h +++ b/projects/sgconf/actions.h @@ -35,29 +35,37 @@ namespace SGCONF typedef void (* FUNC0)(); +template class FUNC0_ACTION : public ACTION { public: - FUNC0_ACTION(FUNC0 func) : m_func(func) {} + 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); + virtual PARSER_STATE Parse(int argc, char ** argv) + { + m_func(); + return PARSER_STATE(true, argc, argv); + } private: - FUNC0 m_func; + F m_func; OPTION_BLOCK m_suboptions; }; +template inline -FUNC0_ACTION * MakeFunc0Action(FUNC0 func) +FUNC0_ACTION * MakeFunc0Action(F func) { -return new FUNC0_ACTION(func); +return new FUNC0_ACTION(func); } template -class PARAM_ACTION: public ACTION +class PARAM_ACTION : public ACTION { public: PARAM_ACTION(RESETABLE & param, @@ -75,6 +83,8 @@ 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; }