From 97f1f905311bcb76c3b500e3e49c1b9f49dff491 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 21 Sep 2013 01:04:12 +0300 Subject: [PATCH] Moved CHG_USER and SEND_MESSAGE parsers from global scope. --- stglibs/srvconf.lib/include/stg/servconf.h | 7 ++----- .../srvconf.lib/include/stg/servconf_types.h | 14 ++++++++++++++ stglibs/srvconf.lib/parser_chg_user.cpp | 12 ++++++------ .../{include/stg => }/parser_chg_user.h | 13 +++++++------ stglibs/srvconf.lib/parser_send_message.cpp | 12 ++++++------ .../{include/stg => }/parser_send_message.h | 12 +++++++----- stglibs/srvconf.lib/servconf.cpp | 18 ++++++++++-------- 7 files changed, 52 insertions(+), 36 deletions(-) rename stglibs/srvconf.lib/{include/stg => }/parser_chg_user.h (87%) rename stglibs/srvconf.lib/{include/stg => }/parser_send_message.h (88%) diff --git a/stglibs/srvconf.lib/include/stg/servconf.h b/stglibs/srvconf.lib/include/stg/servconf.h index 8ecb59cd..f709528f 100644 --- a/stglibs/srvconf.lib/include/stg/servconf.h +++ b/stglibs/srvconf.lib/include/stg/servconf.h @@ -27,9 +27,6 @@ #ifndef __STG_STGLIBS_SERVCONF_H__ #define __STG_STGLIBS_SERVCONF_H__ -#include "stg/parser_chg_user.h" -#include "stg/parser_send_message.h" - #include "stg/servconf_types.h" #include "stg/os_int.h" @@ -48,9 +45,9 @@ public: 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, PARSER_CHG_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, PARSER_SEND_MESSAGE::CALLBACK f, void * data); + int SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data); int ServerInfo(SERVER_INFO::CALLBACK f, void * data); int CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data); diff --git a/stglibs/srvconf.lib/include/stg/servconf_types.h b/stglibs/srvconf.lib/include/stg/servconf_types.h index 81677c42..6aef40cf 100644 --- a/stglibs/srvconf.lib/include/stg/servconf_types.h +++ b/stglibs/srvconf.lib/include/stg/servconf_types.h @@ -147,6 +147,20 @@ typedef void (* CALLBACK)(bool result, const std::string & reason, const INFO & } // namespace GET_USERS +namespace CHG_USER +{ + +typedef void (* CALLBACK)(bool result, const std::string & reason, void * data); + +} + +namespace SEND_MESSAGE +{ + +typedef void (* CALLBACK)(bool result, const std::string & reason, void * data); + +} + } // namespace STG #endif diff --git a/stglibs/srvconf.lib/parser_chg_user.cpp b/stglibs/srvconf.lib/parser_chg_user.cpp index 084b0cc8..b5f4eb73 100644 --- a/stglibs/srvconf.lib/parser_chg_user.cpp +++ b/stglibs/srvconf.lib/parser_chg_user.cpp @@ -19,7 +19,7 @@ * Author : Maxim Mamontov */ -#include "stg/parser_chg_user.h" +#include "parser_chg_user.h" #include @@ -27,14 +27,14 @@ using namespace STG; -PARSER_CHG_USER::PARSER_CHG_USER() +CHG_USER::PARSER::PARSER() : callback(NULL), data(NULL), depth(0) { } //----------------------------------------------------------------------------- -int PARSER_CHG_USER::ParseStart(const char *el, const char **attr) +int CHG_USER::PARSER::ParseStart(const char *el, const char **attr) { depth++; if (depth == 1) @@ -49,12 +49,12 @@ if (depth == 1) return 0; } //----------------------------------------------------------------------------- -void PARSER_CHG_USER::ParseEnd(const char *) +void CHG_USER::PARSER::ParseEnd(const char *) { depth--; } //----------------------------------------------------------------------------- -void PARSER_CHG_USER::ParseAnswer(const char * /*el*/, const char ** attr) +void CHG_USER::PARSER::ParseAnswer(const char * /*el*/, const char ** attr) { if (!callback) return; @@ -64,7 +64,7 @@ else callback(false, "Invalid response.", data); } //----------------------------------------------------------------------------- -void PARSER_CHG_USER::SetCallback(CALLBACK f, void * d) +void CHG_USER::PARSER::SetCallback(CALLBACK f, void * d) { callback = f; data = d; diff --git a/stglibs/srvconf.lib/include/stg/parser_chg_user.h b/stglibs/srvconf.lib/parser_chg_user.h similarity index 87% rename from stglibs/srvconf.lib/include/stg/parser_chg_user.h rename to stglibs/srvconf.lib/parser_chg_user.h index 75431ae1..d74dea76 100644 --- a/stglibs/srvconf.lib/include/stg/parser_chg_user.h +++ b/stglibs/srvconf.lib/parser_chg_user.h @@ -22,19 +22,19 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_CHG_USER_H__ #define __STG_STGLIBS_SRVCONF_PARSER_CHG_USER_H__ -#include "parser.h" - -#include +#include "stg/parser.h" +#include "stg/servconf_types.h" namespace STG { +namespace CHG_USER +{ -class PARSER_CHG_USER: public PARSER +class PARSER: public STG::PARSER { public: - typedef void (* CALLBACK)(bool result, const std::string& reason, void * data); - PARSER_CHG_USER(); + PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); @@ -46,6 +46,7 @@ private: void ParseAnswer(const char * el, const char ** attr); }; +} // namespace CHG_USER } // namespace STG #endif diff --git a/stglibs/srvconf.lib/parser_send_message.cpp b/stglibs/srvconf.lib/parser_send_message.cpp index 08b60462..318cc8eb 100644 --- a/stglibs/srvconf.lib/parser_send_message.cpp +++ b/stglibs/srvconf.lib/parser_send_message.cpp @@ -19,7 +19,7 @@ * Author : Maxim Mamontov */ -#include "stg/parser_send_message.h" +#include "parser_send_message.h" #include @@ -27,14 +27,14 @@ using namespace STG; -PARSER_SEND_MESSAGE::PARSER_SEND_MESSAGE() +SEND_MESSAGE::PARSER::PARSER() : callback(NULL), data(NULL), depth(0) { } //----------------------------------------------------------------------------- -int PARSER_SEND_MESSAGE::ParseStart(const char * el, const char ** attr) +int SEND_MESSAGE::PARSER::ParseStart(const char * el, const char ** attr) { depth++; if (depth == 1) @@ -43,12 +43,12 @@ if (depth == 1) return 0; } //----------------------------------------------------------------------------- -void PARSER_SEND_MESSAGE::ParseEnd(const char * /*el*/) +void SEND_MESSAGE::PARSER::ParseEnd(const char * /*el*/) { depth--; } //----------------------------------------------------------------------------- -void PARSER_SEND_MESSAGE::ParseAnswer(const char * /*el*/, const char **attr) +void SEND_MESSAGE::PARSER::ParseAnswer(const char * /*el*/, const char **attr) { if (!callback) return; @@ -58,7 +58,7 @@ else callback(false, "Invalid response.", data); } //----------------------------------------------------------------------------- -void PARSER_SEND_MESSAGE::SetCallback(CALLBACK f, void * d) +void SEND_MESSAGE::PARSER::SetCallback(CALLBACK f, void * d) { callback = f; data = d; diff --git a/stglibs/srvconf.lib/include/stg/parser_send_message.h b/stglibs/srvconf.lib/parser_send_message.h similarity index 88% rename from stglibs/srvconf.lib/include/stg/parser_send_message.h rename to stglibs/srvconf.lib/parser_send_message.h index 912d507e..fc1f020d 100644 --- a/stglibs/srvconf.lib/include/stg/parser_send_message.h +++ b/stglibs/srvconf.lib/parser_send_message.h @@ -22,19 +22,20 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_SEND_MESSAGE_H__ #define __STG_STGLIBS_SRVCONF_PARSER_SEND_MESSAGE_H__ -#include "parser.h" +#include "stg/parser.h" +#include "stg/servconf_types.h" #include namespace STG { +namespace SEND_MESSAGE +{ -class PARSER_SEND_MESSAGE: public PARSER +class PARSER: public STG::PARSER { public: - typedef void (* CALLBACK)(bool result, const std::string& reason, void * data); - - PARSER_SEND_MESSAGE(); + PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); @@ -46,6 +47,7 @@ private: void ParseAnswer(const char * el, const char ** attr); }; +} // namespace SEND_MESSAGE } // namespace STG #endif diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index 1b90f77c..3684dd54 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -26,6 +26,8 @@ #include "parser_check_user.h" #include "parser_get_users.h" #include "parser_get_user.h" +#include "parser_chg_user.h" +#include "parser_send_message.h" #include "stg/common.h" @@ -44,9 +46,9 @@ public: 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, PARSER_CHG_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, PARSER_SEND_MESSAGE::CALLBACK f, void * data); + int SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data); int ServerInfo(SERVER_INFO::CALLBACK f, void * data); int CheckUser(const std::string & login, const std::string & password, CHECK_USER::CALLBACK f, void * data); @@ -59,9 +61,9 @@ private: GET_USER::PARSER parserGetUser; AUTH_BY::PARSER parserAuthBy; SERVER_INFO::PARSER parserServerInfo; - PARSER_CHG_USER parserChgUser; + CHG_USER::PARSER parserChgUser; CHECK_USER::PARSER parserCheckUser; - PARSER_SEND_MESSAGE parserSendMessage; + SEND_MESSAGE::PARSER parserSendMessage; NETTRANSACT nt; @@ -110,7 +112,7 @@ int SERVCONF::GetUser(const std::string & login, GET_USER::CALLBACK f, void * da return pImpl->GetUser(login, f, data); } -int SERVCONF::ChgUser(const std::string & request, PARSER_CHG_USER::CALLBACK f, void * data) +int SERVCONF::ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data) { return pImpl->ChgUser(request, f, data); } @@ -120,7 +122,7 @@ int SERVCONF::AuthBy(const std::string & login, AUTH_BY::CALLBACK f, void * data return pImpl->AuthBy(login, f, data); } -int SERVCONF::SendMessage(const std::string & request, PARSER_SEND_MESSAGE::CALLBACK f, void * data) +int SERVCONF::SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data) { return pImpl->SendMessage(request, f, data); } @@ -173,13 +175,13 @@ parserServerInfo.SetCallback(f, data); return Exec("", parserServerInfo); } //----------------------------------------------------------------------------- -int SERVCONF::IMPL::ChgUser(const std::string & request, PARSER_CHG_USER::CALLBACK f, void * data) +int SERVCONF::IMPL::ChgUser(const std::string & request, CHG_USER::CALLBACK f, void * data) { parserChgUser.SetCallback(f, data); return Exec(request, parserChgUser); } //----------------------------------------------------------------------------- -int SERVCONF::IMPL::SendMessage(const std::string & request, PARSER_SEND_MESSAGE::CALLBACK f, void * data) +int SERVCONF::IMPL::SendMessage(const std::string & request, SEND_MESSAGE::CALLBACK f, void * data) { parserSendMessage.SetCallback(f, data); return Exec(request, parserSendMessage); -- 2.43.2