]> git.stg.codes - stg.git/blobdiff - stglibs/srvconf.lib/servconf.cpp
Added corporations management.
[stg.git] / stglibs / srvconf.lib / servconf.cpp
index 11e755bad95a733526b4f96bb4d371b9fe6bda6d..e80c3ffa7f889e8371ba1417a5ccde65197c8305 100644 (file)
@@ -16,6 +16,7 @@
 
 /*
  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
+ *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
  */
 
 #include "stg/servconf.h"
 #include "parsers/get_service.h"
 #include "parsers/chg_service.h"
 
+#include "parsers/get_corporations.h"
+#include "parsers/get_corp.h"
+#include "parsers/chg_corp.h"
+
 #include "parsers/base.h"
 
 #include "stg/common.h"
@@ -275,6 +280,38 @@ int SERVCONF::DelService(const std::string & name, SIMPLE::CALLBACK f, void * da
 return pImpl->Exec<SIMPLE::PARSER>("DelService", "<DelService name=\"" + name + "\"/>", f, data);
 }
 
+// -- Corporations --
+
+int SERVCONF::GetCorporations(GET_CORPORATIONS::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_CORPORATIONS::PARSER>("<GetCorporations/>", f, data);
+}
+
+int SERVCONF::GetCorp(const std::string & name, GET_CORP::CALLBACK f, void * data)
+{
+return pImpl->Exec<GET_CORP::PARSER>("<GetCorp name=\"" + name + "\"/>", f, data);
+}
+
+int SERVCONF::ChgCorp(const CORP_CONF_RES & conf, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("SetCorp", "<SetCorp name=\"" + conf.name.data() + "\">" + CHG_CORP::Serialize(conf) + "</SetCorp>", f, data);
+}
+
+int SERVCONF::AddCorp(const std::string & name,
+                      const CORP_CONF_RES & conf,
+                      SIMPLE::CALLBACK f, void * data)
+{
+int res = pImpl->Exec<SIMPLE::PARSER>("AddCorp", "<AddCorp name=\"" + name + "\"/>", f, data);
+if (res != st_ok)
+    return res;
+return pImpl->Exec<SIMPLE::PARSER>("SetCorp", "<SetCorp name=\"" + name + "\">" + CHG_CORP::Serialize(conf) + "</SetCorp>", f, data);
+}
+
+int SERVCONF::DelCorp(const std::string & name, SIMPLE::CALLBACK f, void * data)
+{
+return pImpl->Exec<SIMPLE::PARSER>("DelCorp", "<DelCorp name=\"" + name + "\"/>", f, data);
+}
+
 const std::string & SERVCONF::GetStrError() const
 {
 return pImpl->GetStrError();