X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/250a7d6e7a4c8ffd644931b7b3964289a8f99151..1c324d5b2380a68f209e65969079677dbaf1c511:/projects/stargazer/plugins/configuration/sgconfig/parser_message.h diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_message.h b/projects/stargazer/plugins/configuration/sgconfig/parser_message.h index e7c12f4f..379c2b70 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_message.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_message.h @@ -19,44 +19,56 @@ * Author : Maxim Mamontov */ -#ifndef __STG_SGCONFIG_PARSER_USERS_H__ -#define __STG_SGCONFIG_PARSER_USERS_H__ +#pragma once #include "parser.h" #include "stg/message.h" +#include "stg/common.h" #include #include -class USERS; -class USER; - namespace STG { + +struct Users; +struct User; + namespace PARSER { class SEND_MESSAGE: public BASE_PARSER { public: - SEND_MESSAGE(const ADMIN & admin, USERS & users) - : BASE_PARSER(admin, "Message"), m_users(users), m_result(res_ok), m_user(NULL) {} - int Start(void *data, const char *el, const char **attr); - int End(void *data, const char *el); + class FACTORY : public BASE_PARSER::FACTORY + { + public: + explicit FACTORY(Users & users) : m_users(users) {} + BASE_PARSER * create(const Admin & admin) override { return new SEND_MESSAGE(admin, m_users); } + static void Register(REGISTRY & registry, Users & users) + { registry[ToLower(tag)] = new FACTORY(users); } + private: + Users & m_users; + }; + + static const char * tag; + + SEND_MESSAGE(const Admin & admin, Users & users) + : BASE_PARSER(admin, tag), m_users(users), m_result(res_ok), m_user(NULL) {} + int Start(void *data, const char *el, const char **attr) override; + int End(void *data, const char *el) override; private: - USERS & m_users; + Users & m_users; std::vector m_logins; enum { res_ok, res_params_error, res_unknown } m_result; - STG_MSG m_msg; - USER * m_user; + STG::Message m_msg; + User * m_user; int ParseLogins(const char * logins); - void CreateAnswer(); + void CreateAnswer() override; }; -} -} - -#endif +} // namespace PARSER +} // namespace STG