X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/a6680ce3d763763a6010c81c8a5a8f7a1ce052db..72797a0baa15ce75663a8dc662a132a6dd1a0de1:/include/stg/user_conf.h diff --git a/include/stg/user_conf.h b/include/stg/user_conf.h index a16b3929..a82c4f1f 100644 --- a/include/stg/user_conf.h +++ b/include/stg/user_conf.h @@ -1,23 +1,20 @@ - /* - $Revision: 1.12 $ - $Date: 2010/03/11 14:42:05 $ - $Author: faust $ - */ +#pragma once -#ifndef USER_CONF_H -#define USER_CONF_H +#include "user_ips.h" #include #include +#include +#include #include "const.h" -#include "user_ips.h" -#include "resetable.h" -#include "os_int.h" + +namespace STG +{ //----------------------------------------------------------------------------- -struct USER_CONF +struct UserConf { - USER_CONF() + UserConf() noexcept : passive(0), disabled(0), disabledDetailStat(0), @@ -27,6 +24,11 @@ struct USER_CONF creditExpire(0) {} + UserConf(const UserConf&) = default; + UserConf& operator=(const UserConf&) = default; + UserConf(UserConf&&) = default; + UserConf& operator=(UserConf&&) = default; + std::string password; int passive; int disabled; @@ -45,15 +47,39 @@ struct USER_CONF std::string nextTariff; std::vector userdata; time_t creditExpire; - USER_IPS ips; + UserIPs ips; }; //----------------------------------------------------------------------------- -struct USER_CONF_RES +struct UserConfOpt { - USER_CONF_RES() + UserConfOpt() noexcept : userdata(USERDATA_NUM) {} - USER_CONF_RES & operator=(const USER_CONF & uc) + UserConfOpt(const UserConf& data) noexcept + : password(data.password), + passive(data.passive), + disabled(data.disabled), + disabledDetailStat(data.disabledDetailStat), + alwaysOnline(data.alwaysOnline), + tariffName(data.tariffName), + address(data.address), + phone(data.phone), + email(data.email), + note(data.note), + realName(data.realName), + corp(data.corp), + group(data.group), + credit(data.credit), + nextTariff(data.nextTariff), + userdata(USERDATA_NUM), + services(data.services), + creditExpire(data.creditExpire), + ips(data.ips) + { + for (size_t i = 0; i < USERDATA_NUM; i++) + userdata[i] = data.userdata[i]; + } + UserConfOpt& operator=(const UserConf& uc) noexcept { userdata.resize(USERDATA_NUM); password = uc.password; @@ -77,54 +103,32 @@ struct USER_CONF_RES ips = uc.ips; return *this; } - USER_CONF GetData() const - { - USER_CONF uc; - uc.password = password.data(); - uc.passive = passive.data(); - uc.disabled = disabled.data(); - uc.disabledDetailStat = disabledDetailStat.data(); - uc.alwaysOnline = alwaysOnline.data(); - uc.tariffName = tariffName.data(); - uc.address = address.data(); - uc.phone = phone.data(); - uc.email = email.data(); - uc.note = note.data(); - uc.realName = realName.data(); - uc.corp = corp.data(); - uc.group = group.data(); - uc.credit = credit.data(); - uc.nextTariff = nextTariff.data(); - for (size_t i = 0; i < USERDATA_NUM; i++) - { - uc.userdata[i] = userdata[i].data(); - } - uc.services = services.data(); - uc.creditExpire = creditExpire.data(); - uc.ips = ips.data(); - return uc; - } //------------------------------------------------------------------------- - RESETABLE password; - RESETABLE passive; - RESETABLE disabled; - RESETABLE disabledDetailStat; - RESETABLE alwaysOnline; - RESETABLE tariffName; - RESETABLE address; - RESETABLE phone; - RESETABLE email; - RESETABLE note; - RESETABLE realName; - RESETABLE corp; - RESETABLE group; - RESETABLE credit; - RESETABLE nextTariff; - std::vector > userdata; - RESETABLE > services; - RESETABLE creditExpire; - RESETABLE ips; + UserConfOpt(const UserConfOpt&) = default; + UserConfOpt& operator=(const UserConfOpt&) = default; + UserConfOpt(UserConfOpt&&) = default; + UserConfOpt& operator=(UserConfOpt&&) = default; + + std::optional password; + std::optional passive; + std::optional disabled; + std::optional disabledDetailStat; + std::optional alwaysOnline; + std::optional tariffName; + std::optional address; + std::optional phone; + std::optional email; + std::optional note; + std::optional realName; + std::optional corp; + std::optional group; + std::optional credit; + std::optional nextTariff; + std::vector > userdata; + std::optional > services; + std::optional creditExpire; + std::optional ips; }; //----------------------------------------------------------------------------- -#endif +}