+class KV_ACTION : public ACTION
+{
+ public:
+ KV_ACTION(const std::string & name,
+ const std::string & paramDescription)
+ : m_name(name),
+ 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);
+
+ private:
+ std::string m_name;
+ std::string m_description;
+ OPTION_BLOCK m_suboptions;
+};
+
+inline
+PARSER_STATE KV_ACTION::Parse(int argc, char ** argv, void * data)
+{
+if (argc == 0 ||
+ argv == NULL ||
+ *argv == NULL)
+ throw ERROR("Missing argument.");
+assert(data != NULL && "Expecting container pointer.");
+std::map<std::string, std::string> & kvs = *static_cast<std::map<std::string, std::string>*>(data);
+kvs[m_name] = *argv;
+return PARSER_STATE(false, --argc, ++argv);
+}
+
+inline
+KV_ACTION * MakeKVAction(const std::string & name,
+ const std::string & paramDescription)
+{
+return new KV_ACTION(name, paramDescription);
+}
+