* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#ifndef __STG_PARSER_AUTH_BY_H__
-#define __STG_PARSER_AUTH_BY_H__
+#pragma once
#include "parser.h"
-#include <string>
+#include "stg/common.h"
-class ADMIN;
-class USERS;
+#include <string>
namespace STG
{
+
+struct Admin;
+struct Users;
+
namespace PARSER
{
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, const USERS & users)
- : m_admin(admin), m_users(users)
- {}
- virtual BASE_PARSER * create() { return new AUTH_BY(m_admin, m_users); }
+ explicit FACTORY(const Users & users) : m_users(users) {}
+ BASE_PARSER * create(const Admin & admin) override { return new AUTH_BY(admin, m_users); }
+ static void Register(REGISTRY & registry, const Users & users)
+ { registry[ToLower(tag)] = new FACTORY(users); }
private:
- const ADMIN & m_admin;
- const USERS & m_users;
+ const Users & m_users;
};
- AUTH_BY(const ADMIN & admin, const USERS & users)
- : BASE_PARSER(admin, "GetUserAuthBy"), m_users(users) {}
- int Start(void * data, const char * el, const char ** attr);
+ static const char * tag;
+
+ AUTH_BY(const Admin & admin, const Users & users)
+ : BASE_PARSER(admin, tag), m_users(users) {}
+ int Start(void * data, const char * el, const char ** attr) override;
private:
- const USERS & m_users;
+ const Users & m_users;
std::string m_login;
- void CreateAnswer();
+ void CreateAnswer() override;
};
} // namespace PARSER
} // namespace STG
-
-#endif