From b90c2119e010c073ac79280693751be5c05bb1b9 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Tue, 8 Oct 2013 00:33:02 +0300 Subject: [PATCH] Removed redundant methods from SERVCONF implementation. --- stglibs/srvconf.lib/servconf.cpp | 63 +++++--------------------------- 1 file changed, 10 insertions(+), 53 deletions(-) diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index 62266871..2970cf39 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -47,32 +47,19 @@ public: int ServerInfo(SERVER_INFO::CALLBACK f, void * data); - int GetAdmins(GET_ADMINS::CALLBACK f, void * data); - int GetAdmin(const std::string & login, GET_ADMIN::CALLBACK f, void * data); - int ChgAdmin(const std::string & login, const ADMIN_CONF_RES & conf, CHG_ADMIN::CALLBACK f, void * data); - int AddAdmin(const std::string & login, const ADMIN_CONF & conf, GET_ADMIN::CALLBACK f, void * data); - int DelAdmin(const std::string & login, DEL_ADMIN::CALLBACK f, void * data); - - int GetUsers(GET_USERS::CALLBACK f, void * data); - int GetUser(const std::string & login, GET_USER::CALLBACK f, void * data); - int ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data); - int AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data); - int SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data); - int CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data); - const std::string & GetStrError() const; static void Start(void * data, const char * el, const char ** attr); static void End(void * data, const char * el); + template + int Exec(const std::string & request, C callback, void * data); + private: NETTRANSACT nt; std::string errorMsg; XML_Parser parser; - template - int Exec(const std::string & request, C callback, void * data); - static bool AnsRecv(void * data, const std::string & chunk, bool final); }; @@ -100,32 +87,32 @@ SERVCONF::SERVCONF(const std::string & server, uint16_t port, SERVCONF::~SERVCONF() { - delete pImpl; +delete pImpl; } int SERVCONF::GetUsers(GET_USERS::CALLBACK f, void * data) { - return pImpl->GetUsers( f, data ); +return pImpl->Exec("", f, data); } int SERVCONF::GetUser(const std::string & login, GET_USER::CALLBACK f, void * data) { - return pImpl->GetUser(login, f, data); +return pImpl->Exec("", f, data); } int SERVCONF::ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data) { - return pImpl->ChgUser(request, f, data); +return pImpl->Exec(request, f, data); } int SERVCONF::AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data) { - return pImpl->AuthBy(login, f, data); +return pImpl->Exec("", f, data); } int SERVCONF::SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data) { - return pImpl->SendMessage(request, f, data); +return pImpl->Exec(request, f, data); } int SERVCONF::ServerInfo(SERVER_INFO::CALLBACK f, void * data) @@ -135,7 +122,7 @@ int SERVCONF::ServerInfo(SERVER_INFO::CALLBACK f, void * data) int SERVCONF::CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data) { - return pImpl->CheckUser(login, password, f, data); +return pImpl->Exec("", f, data); } const std::string & SERVCONF::GetStrError() const @@ -152,41 +139,11 @@ parser = XML_ParserCreate(NULL); nt.SetRxCallback(this, AnsRecv); } //----------------------------------------------------------------------------- -int SERVCONF::IMPL::GetUser(const std::string & login, GET_USER::CALLBACK f, void * data) -{ -return Exec("", f, data); -} -//----------------------------------------------------------------------------- -int SERVCONF::IMPL::AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data) -{ -return Exec("", f, data); -} -//----------------------------------------------------------------------------- -int SERVCONF::IMPL::GetUsers(GET_USERS::CALLBACK f, void * data) -{ -return Exec("", f, data); -} -//----------------------------------------------------------------------------- int SERVCONF::IMPL::ServerInfo(SERVER_INFO::CALLBACK f, void * data) { return Exec("", f, data); } //----------------------------------------------------------------------------- -int SERVCONF::IMPL::ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data) -{ -return Exec(request, f, data); -} -//----------------------------------------------------------------------------- -int SERVCONF::IMPL::SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data) -{ -return Exec(request, f, data); -} -//----------------------------------------------------------------------------- -int SERVCONF::IMPL::CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data) -{ -return Exec("", f, data); -} -//----------------------------------------------------------------------------- void SERVCONF::IMPL::Start(void * data, const char * el, const char ** attr) { PARSER * currParser = static_cast(data); -- 2.43.2