From f384309c9c663a4b381d2e1a8545693514835395 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 21 Sep 2013 01:23:31 +0300 Subject: [PATCH] Moved base and utility classes from global scope. --- stglibs/srvconf.lib/{include/stg => }/parser.h | 0 stglibs/srvconf.lib/parser_auth_by.h | 8 ++++---- stglibs/srvconf.lib/parser_check_user.h | 7 +++---- stglibs/srvconf.lib/parser_chg_user.h | 5 +++-- stglibs/srvconf.lib/parser_get_user.cpp | 5 +++++ stglibs/srvconf.lib/parser_get_user.h | 16 +++++++--------- stglibs/srvconf.lib/parser_get_users.h | 10 +++++----- stglibs/srvconf.lib/parser_send_message.h | 6 +++--- stglibs/srvconf.lib/parser_server_info.h | 6 +++--- stglibs/srvconf.lib/property_parsers.cpp | 10 +++++----- .../{include/stg => }/property_parsers.h | 7 ++++++- 11 files changed, 44 insertions(+), 36 deletions(-) rename stglibs/srvconf.lib/{include/stg => }/parser.h (100%) rename stglibs/srvconf.lib/{include/stg => }/property_parsers.h (98%) diff --git a/stglibs/srvconf.lib/include/stg/parser.h b/stglibs/srvconf.lib/parser.h similarity index 100% rename from stglibs/srvconf.lib/include/stg/parser.h rename to stglibs/srvconf.lib/parser.h diff --git a/stglibs/srvconf.lib/parser_auth_by.h b/stglibs/srvconf.lib/parser_auth_by.h index 4e94267c..c4757cf9 100644 --- a/stglibs/srvconf.lib/parser_auth_by.h +++ b/stglibs/srvconf.lib/parser_auth_by.h @@ -21,11 +21,10 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_AUTH_BY_H__ #define __STG_STGLIBS_SRVCONF_PARSER_AUTH_BY_H__ -#include "stg/parser.h" +#include "parser.h" #include "stg/servconf_types.h" -#include #include namespace STG @@ -37,9 +36,10 @@ class PARSER: public STG::PARSER { public: PARSER(); - int ParseStart(const char *el, const char **attr); - void ParseEnd(const char *el); + int ParseStart(const char * el, const char ** attr); + void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: CALLBACK callback; void * data; diff --git a/stglibs/srvconf.lib/parser_check_user.h b/stglibs/srvconf.lib/parser_check_user.h index 11d6ab96..95658c38 100644 --- a/stglibs/srvconf.lib/parser_check_user.h +++ b/stglibs/srvconf.lib/parser_check_user.h @@ -22,10 +22,9 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_CHECK_USER_H__ #define __STG_STGLIBS_SRVCONF_PARSER_CHECK_USER_H__ -#include "stg/parser.h" -#include "stg/servconf_types.h" +#include "parser.h" -#include +#include "stg/servconf_types.h" namespace STG { @@ -35,11 +34,11 @@ namespace CHECK_USER class PARSER: public STG::PARSER { public: - PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: CALLBACK callback; void * data; diff --git a/stglibs/srvconf.lib/parser_chg_user.h b/stglibs/srvconf.lib/parser_chg_user.h index d74dea76..63c528d0 100644 --- a/stglibs/srvconf.lib/parser_chg_user.h +++ b/stglibs/srvconf.lib/parser_chg_user.h @@ -22,7 +22,8 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_CHG_USER_H__ #define __STG_STGLIBS_SRVCONF_PARSER_CHG_USER_H__ -#include "stg/parser.h" +#include "parser.h" + #include "stg/servconf_types.h" namespace STG @@ -33,11 +34,11 @@ namespace CHG_USER class PARSER: public STG::PARSER { public: - PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: CALLBACK callback; void * data; diff --git a/stglibs/srvconf.lib/parser_get_user.cpp b/stglibs/srvconf.lib/parser_get_user.cpp index 45f5e6ea..2c398914 100644 --- a/stglibs/srvconf.lib/parser_get_user.cpp +++ b/stglibs/srvconf.lib/parser_get_user.cpp @@ -31,6 +31,9 @@ using namespace STG; +namespace STG +{ + template <> bool GetValue(const char ** attr, GET_USER::STAT & value) { @@ -56,6 +59,8 @@ while (attr[pos]) return true; } +} + GET_USER::PARSER::PARSER() : callback(NULL), data(NULL), diff --git a/stglibs/srvconf.lib/parser_get_user.h b/stglibs/srvconf.lib/parser_get_user.h index 871dd211..c8c371d7 100644 --- a/stglibs/srvconf.lib/parser_get_user.h +++ b/stglibs/srvconf.lib/parser_get_user.h @@ -22,15 +22,13 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_GET_USER_H__ #define __STG_STGLIBS_SRVCONF_PARSER_GET_USER_H__ -#include "stg/parser.h" +#include "parser.h" +#include "property_parsers.h" -#include "stg/property_parsers.h" #include "stg/servconf_types.h" #include -#include - namespace STG { namespace GET_USER @@ -39,12 +37,12 @@ namespace GET_USER class PARSER: public STG::PARSER { public: - PARSER(); virtual ~PARSER(); - int ParseStart(const char *el, const char **attr); - void ParseEnd(const char *el); + int ParseStart(const char * el, const char ** attr); + void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: PROPERTY_PARSERS propertyParsers; CALLBACK callback; @@ -54,8 +52,8 @@ private: bool parsingAnswer; std::string error; - void ParseUser(const char *el, const char **attr); - void ParseUserParams(const char *el, const char **attr); + void ParseUser(const char * el, const char ** attr); + void ParseUserParams(const char * el, const char ** attr); }; } // namespace GET_USER diff --git a/stglibs/srvconf.lib/parser_get_users.h b/stglibs/srvconf.lib/parser_get_users.h index 55258186..ea9966ee 100644 --- a/stglibs/srvconf.lib/parser_get_users.h +++ b/stglibs/srvconf.lib/parser_get_users.h @@ -23,12 +23,12 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_GET_USERS_H__ #define __STG_STGLIBS_SRVCONF_PARSER_GET_USERS_H__ -#include "stg/parser.h" -#include "stg/servconf_types.h" - +#include "parser.h" #include "parser_get_user.h" -#include +#include "stg/servconf_types.h" + +#include namespace STG { @@ -38,11 +38,11 @@ namespace GET_USERS class PARSER: public STG::PARSER { public: - PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: CALLBACK callback; void * data; diff --git a/stglibs/srvconf.lib/parser_send_message.h b/stglibs/srvconf.lib/parser_send_message.h index fc1f020d..27903bc0 100644 --- a/stglibs/srvconf.lib/parser_send_message.h +++ b/stglibs/srvconf.lib/parser_send_message.h @@ -22,10 +22,9 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_SEND_MESSAGE_H__ #define __STG_STGLIBS_SRVCONF_PARSER_SEND_MESSAGE_H__ -#include "stg/parser.h" -#include "stg/servconf_types.h" +#include "parser.h" -#include +#include "stg/servconf_types.h" namespace STG { @@ -39,6 +38,7 @@ public: int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: CALLBACK callback; void * data; diff --git a/stglibs/srvconf.lib/parser_server_info.h b/stglibs/srvconf.lib/parser_server_info.h index 2e91106c..9ac23ee8 100644 --- a/stglibs/srvconf.lib/parser_server_info.h +++ b/stglibs/srvconf.lib/parser_server_info.h @@ -22,9 +22,9 @@ #ifndef __STG_STGLIBS_SRVCONF_PARSER_SERVER_INFO_H__ #define __STG_STGLIBS_SRVCONF_PARSER_SERVER_INFO_H__ -#include "stg/parser.h" +#include "parser.h" +#include "property_parsers.h" -#include "stg/property_parsers.h" #include "stg/servconf_types.h" #include @@ -37,11 +37,11 @@ namespace SERVER_INFO class PARSER: public STG::PARSER { public: - PARSER(); int ParseStart(const char * el, const char ** attr); void ParseEnd(const char * el); void SetCallback(CALLBACK f, void * data); + private: PROPERTY_PARSERS propertyParsers; CALLBACK callback; diff --git a/stglibs/srvconf.lib/property_parsers.cpp b/stglibs/srvconf.lib/property_parsers.cpp index fcb9020a..5d4577dc 100644 --- a/stglibs/srvconf.lib/property_parsers.cpp +++ b/stglibs/srvconf.lib/property_parsers.cpp @@ -18,16 +18,16 @@ * Author : Maxim Mamontov */ -#include "stg/property_parsers.h" +#include "property_parsers.h" #include -bool CheckValue(const char ** attr) +bool STG::CheckValue(const char ** attr) { return attr && attr[0] && attr[1] && strcasecmp(attr[0], "value") == 0; } -bool GetEncodedValue(const char ** attr, std::string & value) +bool STG::GetEncodedValue(const char ** attr, std::string & value) { if (!CheckValue(attr)) return false; @@ -35,7 +35,7 @@ Decode21str(value, attr[1]); return true; } -bool GetIPValue(const char ** attr, uint32_t & value) +bool STG::GetIPValue(const char ** attr, uint32_t & value) { if (!CheckValue(attr)) return false; @@ -46,7 +46,7 @@ if (value == 0 && ip != "0.0.0.0") return true; } -bool TryParse(PROPERTY_PARSERS & parsers, const std::string & name, const char ** attr) +bool STG::TryParse(PROPERTY_PARSERS & parsers, const std::string & name, const char ** attr) { PROPERTY_PARSERS::iterator it(parsers.find(name)); if (it != parsers.end()) diff --git a/stglibs/srvconf.lib/include/stg/property_parsers.h b/stglibs/srvconf.lib/property_parsers.h similarity index 98% rename from stglibs/srvconf.lib/include/stg/property_parsers.h rename to stglibs/srvconf.lib/property_parsers.h index d1e6a893..3469b987 100644 --- a/stglibs/srvconf.lib/include/stg/property_parsers.h +++ b/stglibs/srvconf.lib/property_parsers.h @@ -21,10 +21,13 @@ #ifndef __STG_STGLIBS_SRVCONF_PROPERTY_PARSERS_H__ #define __STG_STGLIBS_SRVCONF_PROPERTY_PARSERS_H__ +#include "stg/common.h" + #include #include -#include "stg/common.h" +namespace STG +{ class BASE_PROPERTY_PARSER { @@ -95,4 +98,6 @@ void AddParser(PROPERTY_PARSERS & parsers, const std::string & name, T & value, bool TryParse(PROPERTY_PARSERS & parsers, const std::string & name, const char ** attr); +} // namespace STG + #endif -- 2.44.2