X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/ad0da4b1a6f6cf0afd5a234b1523bdbf0f6321d8..289d396c8d0684e23c2233291164febfec3947bf:/projects/sgconf/actions.h diff --git a/projects/sgconf/actions.h b/projects/sgconf/actions.h index c88de14d..33a11347 100644 --- a/projects/sgconf/actions.h +++ b/projects/sgconf/actions.h @@ -89,6 +89,7 @@ class PARAM_ACTION : public ACTION virtual std::string DefaultDescription() const; virtual OPTION_BLOCK & Suboptions() { return m_suboptions; } virtual PARSER_STATE Parse(int argc, char ** argv); + virtual void ParseValue(const std::string & value); private: RESETABLE & m_param; @@ -129,6 +130,25 @@ m_param = value; return PARSER_STATE(false, --argc, ++argv); } +template +inline +void PARAM_ACTION::ParseValue(const std::string & stringValue) +{ +if (stringValue.empty()) + throw ERROR("Missing value."); +T value; +if (str2x(stringValue, value)) + throw ERROR(std::string("Bad value: '") + stringValue + "'"); +m_param = value; +} + +template <> +inline +void PARAM_ACTION::ParseValue(const std::string & stringValue) +{ +m_param = stringValue; +} + template <> inline PARSER_STATE PARAM_ACTION::Parse(int argc, char ** argv)