#include "stg/user_conf.h"
#include "stg/user_stat.h"
#include "stg/common.h"
-#include "stg/optional.h"
#include <string>
+#include <optional>
namespace STG
{
{
public:
explicit FACTORY(Users & users) : m_users(users) {}
- virtual BASE_PARSER * create(const Admin & admin) { return new GET_USERS(admin, m_users); }
+ BASE_PARSER * create(const Admin & admin) override { return new GET_USERS(admin, m_users); }
static void Register(REGISTRY & registry, Users & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
private:
GET_USERS(const Admin & admin, Users & users)
: BASE_PARSER(admin, tag), m_users(users),
m_lastUserUpdateTime(0) {}
- int Start(void * data, const char * el, const char ** attr);
+ int Start(void * data, const char * el, const char ** attr) override;
private:
Users & m_users;
time_t m_lastUserUpdateTime;
- void CreateAnswer();
+ void CreateAnswer() override;
};
class GET_USER: public BASE_PARSER
{
public:
explicit FACTORY(const Users & users) : m_users(users) {}
- virtual BASE_PARSER * create(const Admin & admin) { return new GET_USER(admin, m_users); }
+ BASE_PARSER * create(const Admin & admin) override { return new GET_USER(admin, m_users); }
static void Register(REGISTRY & registry, const Users & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
private:
GET_USER(const Admin & admin, const Users & users)
: BASE_PARSER(admin, tag), m_users(users) {}
- int Start(void * data, const char * el, const char ** attr);
+ int Start(void * data, const char * el, const char ** attr) override;
private:
const Users & m_users;
std::string m_login;
- void CreateAnswer();
+ void CreateAnswer() override;
};
class ADD_USER: public BASE_PARSER
{
public:
explicit FACTORY(Users & users) : m_users(users) {}
- virtual BASE_PARSER * create(const Admin & admin) { return new ADD_USER(admin, m_users); }
+ BASE_PARSER * create(const Admin & admin) override { return new ADD_USER(admin, m_users); }
static void Register(REGISTRY & registry, Users & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
private:
ADD_USER(const Admin & admin, Users & users)
: BASE_PARSER(admin, tag), m_users(users) {}
- int Start(void * data, const char * el, const char ** attr);
+ int Start(void * data, const char * el, const char ** attr) override;
private:
Users & m_users;
std::string m_login;
- void CreateAnswer();
+ void CreateAnswer() override;
};
class CHG_USER: public BASE_PARSER
FACTORY(Users & users, Store & store, const Tariffs & tariffs)
: m_users(users), m_store(store), m_tariffs(tariffs)
{}
- virtual BASE_PARSER * create(const Admin & admin) { return new CHG_USER(admin, m_users, m_store, m_tariffs); }
+ BASE_PARSER * create(const Admin & admin) override { return new CHG_USER(admin, m_users, m_store, m_tariffs); }
static void Register(REGISTRY & registry, Users & users, Store & store, const Tariffs & tariffs)
{ registry[ToLower(tag)] = new FACTORY(users, store, tariffs); }
private:
m_tariffs(tariffs),
m_cashMustBeAdded(false) {}
- int Start(void * data, const char * el, const char ** attr);
+ int Start(void * data, const char * el, const char ** attr) override;
private:
Users & m_users;
const Tariffs & m_tariffs;
UserStatOpt m_usr;
UserConfOpt m_ucr;
- Optional<uint64_t> m_upr[DIR_NUM];
- Optional<uint64_t> m_downr[DIR_NUM];
+ std::optional<uint64_t> m_upr[DIR_NUM];
+ std::optional<uint64_t> m_downr[DIR_NUM];
std::string m_cashMsg;
std::string m_login;
bool m_cashMustBeAdded;
int ApplyChanges();
- void CreateAnswer();
+ void CreateAnswer() override;
};
class DEL_USER: public BASE_PARSER
{
public:
explicit FACTORY(Users & users) : m_users(users) {}
- virtual BASE_PARSER * create(const Admin & admin) { return new DEL_USER(admin, m_users); }
+ BASE_PARSER * create(const Admin & admin) override { return new DEL_USER(admin, m_users); }
static void Register(REGISTRY & registry, Users & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
private:
DEL_USER(const Admin & admin, Users & users)
: BASE_PARSER(admin, tag), m_users(users), res(0), u(NULL) {}
- int Start(void * data, const char * el, const char ** attr);
- int End(void * data, const char * el);
+ int Start(void * data, const char * el, const char ** attr) override;
+ int End(void * data, const char * el) override;
private:
Users & m_users;
int res;
User * u;
- void CreateAnswer();
+ void CreateAnswer() override;
};
class CHECK_USER: public BASE_PARSER
{
public:
explicit FACTORY(const Users & users) : m_users(users) {}
- virtual BASE_PARSER * create(const Admin & admin) { return new CHECK_USER(admin, m_users); }
+ BASE_PARSER * create(const Admin & admin) override { return new CHECK_USER(admin, m_users); }
static void Register(REGISTRY & registry, const Users & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
private:
CHECK_USER(const Admin & admin, const Users & users)
: BASE_PARSER(admin, tag), m_users(users) {}
- int Start(void * data, const char * el, const char ** attr);
- int End(void * data, const char * el);
+ int Start(void * data, const char * el, const char ** attr) override;
+ int End(void * data, const char * el) override;
private:
const Users & m_users;
void CreateAnswer(const char * error);
- void CreateAnswer() {} // dummy
+ void CreateAnswer() override {} // dummy
};
} // namespace PARSER