class BASE_PARSER
{
public:
+ struct FACTORY
+ {
+ virtual BASE_PARSER * create() = 0;
+ };
+
BASE_PARSER(const ADMIN & admin, const std::string & t)
: m_currAdmin(admin),
m_depth(0),
{
if (strcasecmp(el, m_tag.c_str()) == 0)
{
- admin = attr[1];
+ m_admin = attr[1];
return 0;
}
return -1;
void DEL_ADMIN::CreateAnswer()
{
- if (m_admins.Del(admin, &m_currAdmin) == 0)
+ if (m_admins.Del(m_admin, &m_currAdmin) == 0)
m_answer = "<" + m_tag + " Result=\"Ok\"/>";
else
m_answer = "<" + m_tag + " Result=\"Error. " + m_admins.GetStrError() + "\"/>";
{
if (strcasecmp(el, m_tag.c_str()) == 0)
{
- admin = attr[1];
+ m_admin = attr[1];
return 0;
}
return -1;
void ADD_ADMIN::CreateAnswer()
{
- if (m_admins.Add(admin, &m_currAdmin) == 0)
+ if (m_admins.Add(m_admin, &m_currAdmin) == 0)
m_answer = "<" + m_tag + " Result=\"Ok\"/>";
else
m_answer = "<" + m_tag + " Result=\"Error. " + m_admins.GetStrError() + "\"/>";
class GET_ADMINS: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, const ADMINS & admins)
+ : m_admin(admin), m_admins(admins)
+ {}
+ virtual BASE_PARSER * create() { return new GET_ADMINS(m_admin, m_admins); }
+ private:
+ const ADMIN & m_admin;
+ const ADMINS & m_admins;
+ };
+
GET_ADMINS(const ADMIN & admin, const ADMINS & admins)
: BASE_PARSER(admin, "GetAdmins"), m_admins(admins) {}
class ADD_ADMIN: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, ADMINS & admins)
+ : m_admin(admin), m_admins(admins)
+ {}
+ virtual BASE_PARSER * create() { return new ADD_ADMIN(m_admin, m_admins); }
+ private:
+ const ADMIN & m_admin;
+ ADMINS & m_admins;
+ };
+
ADD_ADMIN(const ADMIN & admin, ADMINS & admins)
: BASE_PARSER(admin, "AddAdmin"), m_admins(admins) {}
int Start(void * data, const char * el, const char ** attr);
private:
- std::string admin;
+ std::string m_admin;
ADMINS & m_admins;
void CreateAnswer();
class DEL_ADMIN: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, ADMINS & admins)
+ : m_admin(admin), m_admins(admins)
+ {}
+ virtual BASE_PARSER * create() { return new DEL_ADMIN(m_admin, m_admins); }
+ private:
+ const ADMIN & m_admin;
+ ADMINS & m_admins;
+ };
+
DEL_ADMIN(const ADMIN & admin, ADMINS & admins)
: BASE_PARSER(admin, "DelAdmin"), m_admins(admins) {}
int Start(void * data, const char * el, const char ** attr);
private:
- std::string admin;
+ std::string m_admin;
ADMINS & m_admins;
void CreateAnswer();
class CHG_ADMIN: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, ADMINS & admins)
+ : m_admin(admin), m_admins(admins)
+ {}
+ virtual BASE_PARSER * create() { return new CHG_ADMIN(m_admin, m_admins); }
+ private:
+ const ADMIN & m_admin;
+ ADMINS & m_admins;
+ };
+
CHG_ADMIN(const ADMIN & admin, ADMINS & admins)
: BASE_PARSER(admin, "ChgAdmin"), m_admins(admins) {}
int Start(void * data, const char * el, const char ** attr);
void CreateAnswer();
};
-}
-}
+} // namespace PARSER
+} // namespace STG
#endif
class AUTH_BY : public BASE_PARSER
{
public:
+ 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); }
+ private:
+ const ADMIN & m_admin;
+ 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);
void CreateAnswer();
};
-}
-}
+} // namespace PARSER
+} // namespace STG
#endif
class SEND_MESSAGE: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, USERS & users)
+ : m_admin(admin), m_users(users)
+ {}
+ virtual BASE_PARSER * create() { return new SEND_MESSAGE(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ USERS & m_users;
+ };
+
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);
void CreateAnswer();
};
-}
-}
+} // namespace PARSER
+} // namespace STG
#endif
class GET_TARIFFS: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, const TARIFFS & tariffs)
+ : m_admin(admin), m_tariffs(tariffs)
+ {}
+ virtual BASE_PARSER * create() { return new GET_TARIFFS(m_admin, m_tariffs); }
+ private:
+ const ADMIN & m_admin;
+ const TARIFFS & m_tariffs;
+ };
+
GET_TARIFFS(const ADMIN & admin, const TARIFFS & tariffs)
: BASE_PARSER(admin, "GetTariffs"), m_tariffs(tariffs) {}
class ADD_TARIFF: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, TARIFFS & tariffs)
+ : m_admin(admin), m_tariffs(tariffs)
+ {}
+ virtual BASE_PARSER * create() { return new ADD_TARIFF(m_admin, m_tariffs); }
+ private:
+ const ADMIN & m_admin;
+ TARIFFS & m_tariffs;
+ };
+
ADD_TARIFF(const ADMIN & admin, TARIFFS & tariffs)
: BASE_PARSER(admin, "AddTariff"), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
class DEL_TARIFF: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, TARIFFS & tariffs, const USERS & users)
+ : m_admin(admin), m_tariffs(tariffs), m_users(users)
+ {}
+ virtual BASE_PARSER * create() { return new DEL_TARIFF(m_admin, m_users, m_tariffs); }
+ private:
+ const ADMIN & m_admin;
+ TARIFFS & m_tariffs;
+ const USERS & m_users;
+ };
+
DEL_TARIFF(const ADMIN & admin, const USERS & users, TARIFFS & tariffs)
: BASE_PARSER(admin, "DelTariff"), m_users(users), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
class CHG_TARIFF: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, TARIFFS & tariffs)
+ : m_admin(admin), m_tariffs(tariffs)
+ {}
+ virtual BASE_PARSER * create() { return new CHG_TARIFF(m_admin, m_tariffs); }
+ private:
+ const ADMIN & m_admin;
+ TARIFFS & m_tariffs;
+ };
+
CHG_TARIFF(const ADMIN & admin, TARIFFS & tariffs)
: BASE_PARSER(admin, "SetTariff"), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
void CreateAnswer();
};
-}
-}
+} // namespace PARSER
+} // namespace STG
#endif
class USER_INFO : public BASE_PARSER
{
public:
+ 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 USER_INFO(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ const USERS & m_users;
+ };
+
USER_INFO(const ADMIN & admin, const USERS & users)
: BASE_PARSER(admin, "GetUserInfo"), m_users(users) {}
int Start(void * data, const char * el, const char ** attr);
void CreateAnswer();
};
-}
-}
+} // namespace PARSER
+} // namespace STG
#endif
class GET_USERS: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, USERS & users)
+ : m_admin(admin), m_users(users)
+ {}
+ virtual BASE_PARSER * create() { return new GET_USERS(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ USERS & m_users;
+ };
+
GET_USERS(const ADMIN & admin, USERS & users)
: BASE_PARSER(admin, "GetUsers"), m_users(users),
m_lastUserUpdateTime(0) {}
class GET_USER: public BASE_PARSER
{
public:
+ 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 GET_USER(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ const USERS & m_users;
+ };
+
GET_USER(const ADMIN & admin, const USERS & users)
: BASE_PARSER(admin, "GetUser"), m_users(users) {}
int Start(void * data, const char * el, const char ** attr);
class ADD_USER: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, USERS & users)
+ : m_admin(admin), m_users(users)
+ {}
+ virtual BASE_PARSER * create() { return new ADD_USER(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ USERS & m_users;
+ };
+
ADD_USER(const ADMIN & admin, USERS & users)
: BASE_PARSER(admin, "AddUser"), m_users(users) {}
int Start(void * data, const char * el, const char ** attr);
class CHG_USER: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, USERS & users, STORE & store, const TARIFFS & tariffs)
+ : m_admin(admin), m_users(users), m_store(store), m_tariffs(tariffs)
+ {}
+ virtual BASE_PARSER * create() { return new CHG_USER(m_admin, m_users, m_store, m_tariffs); }
+ private:
+ const ADMIN & m_admin;
+ USERS & m_users;
+ STORE & m_store;
+ const TARIFFS & m_tariffs;
+ };
+
CHG_USER(const ADMIN & admin, USERS & users,
STORE & store, const TARIFFS & tariffs)
: BASE_PARSER(admin, "SetUser"),
class DEL_USER: public BASE_PARSER
{
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const ADMIN & admin, USERS & users)
+ : m_admin(admin), m_users(users)
+ {}
+ virtual BASE_PARSER * create() { return new DEL_USER(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ USERS & m_users;
+ };
+
DEL_USER(const ADMIN & admin, USERS & users)
: BASE_PARSER(admin, "DelUser"), m_users(users), res(0), u(NULL) {}
int Start(void * data, const char * el, const char ** attr);
class CHECK_USER: public BASE_PARSER
{
public:
+ 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 CHECK_USER(m_admin, m_users); }
+ private:
+ const ADMIN & m_admin;
+ const USERS & m_users;
+ };
+
CHECK_USER(const ADMIN & admin, const USERS & users)
: BASE_PARSER(admin, "CheckUser"), m_users(users) {}
int Start(void * data, const char * el, const char ** attr);
const USERS & m_users;
void CreateAnswer(const char * error);
+ void CreateAnswer() {} // dummy
};
-}
-}
+} // namespace PARSER
+} // namespace STG
#endif