]> git.stg.codes - stg.git/blobdiff - projects/sgconf/api_action.cpp
Added suboptions to tariffs and admins.
[stg.git] / projects / sgconf / api_action.cpp
index 1ff0e5967915faa0c9a9c678dc3737081986bbee..420f5f0a91029e5d258c5c25677108b8764aeef6 100644 (file)
@@ -1,5 +1,6 @@
 #include "api_action.h"
 
+#include "actions.h"
 #include "parser_state.h"
 
 SGCONF::PARSER_STATE SGCONF::API_ACTION::Parse(int argc, char ** argv)
@@ -19,3 +20,21 @@ m_suboptions.Parse(state.argc, state.argv);
 m_commands.Add(m_funPtr, m_argument, m_params);
 return state;
 }
+
+SGCONF::API_ACTION::API_ACTION(COMMANDS & commands,
+                               const std::string & paramDescription,
+                               bool needArgument,
+                               const std::vector<PARAM> & params,
+                               API_FUNCTION funPtr)
+    : m_commands(commands),
+      m_description(paramDescription),
+      m_argument(needArgument ? "1" : ""), // Hack
+      m_funPtr(funPtr)
+{
+std::vector<PARAM>::const_iterator it(params.begin());
+while (it != params.end())
+    {
+    m_suboptions.Add(it->name, MakeKVAction(it->name, m_params, it->shortDescr), it->longDescr);
+    ++it;
+    }
+}