]> git.stg.codes - stg.git/blobdiff - include/stg/user_conf.h
Build and test in both Debug and Release mode.
[stg.git] / include / stg / user_conf.h
index 599336583a4ebc159e400e76279b15e12292b9bb..a82c4f1f76790926661dad38964fae2539cd54ce 100644 (file)
@@ -1,44 +1,34 @@
- /*
- $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 <string>
 #include <vector>
 
 #include <string>
 #include <vector>
+#include <optional>
+#include <cstdint>
 #include "const.h"
 #include "const.h"
-#include "user_ips.h"
-#include "resetable.h"
-#include "os_int.h"
+
+namespace STG
+{
 
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
-struct USER_CONF
+struct UserConf
 {
 {
-    USER_CONF()
-        : password(),
-          passive(0),
+    UserConf() noexcept
+        : passive(0),
           disabled(0),
           disabledDetailStat(0),
           alwaysOnline(0),
           disabled(0),
           disabledDetailStat(0),
           alwaysOnline(0),
-          tariffName(),
-          address(),
-          phone(),
-          email(),
-          note(),
-          realName(),
-          corp(),
-          service(),
-          group(),
           credit(0),
           credit(0),
-          nextTariff(),
           userdata(USERDATA_NUM),
           userdata(USERDATA_NUM),
-          creditExpire(0),
-          ips()
+          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;
     std::string              password;
     int                      passive;
     int                      disabled;
@@ -51,39 +41,45 @@ struct USER_CONF
     std::string              note;
     std::string              realName;
     std::string              corp;
     std::string              note;
     std::string              realName;
     std::string              corp;
-    std::vector<std::string> service;
+    std::vector<std::string> services;
     std::string              group;
     double                   credit;
     std::string              nextTariff;
     std::vector<std::string> userdata;
     time_t                   creditExpire;
     std::string              group;
     double                   credit;
     std::string              nextTariff;
     std::vector<std::string> userdata;
     time_t                   creditExpire;
-    USER_IPS                 ips;
+    UserIPs                  ips;
 };
 //-----------------------------------------------------------------------------
 };
 //-----------------------------------------------------------------------------
-struct USER_CONF_RES
+struct UserConfOpt
 {
 {
-    USER_CONF_RES()
-        : password(),
-          passive(),
-          disabled(),
-          disabledDetailStat(),
-          alwaysOnline(),
-          tariffName(),
-          address(),
-          phone(),
-          email(),
-          note(),
-          realName(),
-          group(),
-          credit(),
-          nextTariff(),
-          userdata(USERDATA_NUM, RESETABLE<std::string>()),
-          creditExpire(),
-          ips()
+    UserConfOpt() noexcept
+        : userdata(USERDATA_NUM)
+    {}
+    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];
     }
     }
-
-    USER_CONF_RES & operator=(const USER_CONF & uc)
+    UserConfOpt& operator=(const UserConf& uc) noexcept
     {
         userdata.resize(USERDATA_NUM);
         password     = uc.password;
     {
         userdata.resize(USERDATA_NUM);
         password     = uc.password;
@@ -97,62 +93,42 @@ struct USER_CONF_RES
         email        = uc.email;
         note         = uc.note;
         realName     = uc.realName;
         email        = uc.email;
         note         = uc.note;
         realName     = uc.realName;
+        corp         = uc.corp;
         group        = uc.group;
         credit       = uc.credit;
         nextTariff   = uc.nextTariff;
         group        = uc.group;
         credit       = uc.credit;
         nextTariff   = uc.nextTariff;
-        for (int i = 0; i < USERDATA_NUM; i++)
-            {
-            userdata[i]  = uc.userdata[i];
-            }
+        for (size_t i = 0; i < USERDATA_NUM; i++) userdata[i]  = uc.userdata[i];
+        services     = uc.services;
         creditExpire = uc.creditExpire;
         ips          = uc.ips;
         return *this;
     }
         creditExpire = uc.creditExpire;
         ips          = uc.ips;
         return *this;
     }
-    operator USER_CONF() const
-    {
-        USER_CONF uc;
-        uc.password     = password;
-        uc.passive      = passive;
-        uc.disabled     = disabled;
-        uc.disabledDetailStat = disabledDetailStat;
-        uc.alwaysOnline = alwaysOnline;
-        uc.tariffName   = tariffName;
-        uc.address      = address;
-        uc.phone        = phone;
-        uc.email        = email;
-        uc.note         = note;
-        uc.realName     = realName;
-        uc.group        = group;
-        uc.credit       = credit;
-        uc.nextTariff   = nextTariff;
-        for (int i = 0; i < USERDATA_NUM; i++)
-            {
-            uc.userdata[i]  = userdata[i];
-            }
-        uc.creditExpire = creditExpire;
-        uc.ips          = ips;
-        return uc;
-    }
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
 
-    RESETABLE<std::string>               password;
-    RESETABLE<int>                       passive;
-    RESETABLE<int>                       disabled;
-    RESETABLE<int>                       disabledDetailStat;
-    RESETABLE<int>                       alwaysOnline;
-    RESETABLE<std::string>               tariffName;
-    RESETABLE<std::string>               address;
-    RESETABLE<std::string>               phone;
-    RESETABLE<std::string>               email;
-    RESETABLE<std::string>               note;
-    RESETABLE<std::string>               realName;
-    RESETABLE<std::string>               group;
-    RESETABLE<double>                    credit;
-    RESETABLE<std::string>               nextTariff;
-    std::vector<RESETABLE<std::string> > userdata;
-    RESETABLE<time_t>                    creditExpire;
-    RESETABLE<USER_IPS>                  ips;
+    UserConfOpt(const UserConfOpt&) = default;
+    UserConfOpt& operator=(const UserConfOpt&) = default;
+    UserConfOpt(UserConfOpt&&) = default;
+    UserConfOpt& operator=(UserConfOpt&&) = default;
+
+    std::optional<std::string>               password;
+    std::optional<int>                       passive;
+    std::optional<int>                       disabled;
+    std::optional<int>                       disabledDetailStat;
+    std::optional<int>                       alwaysOnline;
+    std::optional<std::string>               tariffName;
+    std::optional<std::string>               address;
+    std::optional<std::string>               phone;
+    std::optional<std::string>               email;
+    std::optional<std::string>               note;
+    std::optional<std::string>               realName;
+    std::optional<std::string>               corp;
+    std::optional<std::string>               group;
+    std::optional<double>                    credit;
+    std::optional<std::string>               nextTariff;
+    std::vector<std::optional<std::string> > userdata;
+    std::optional<std::vector<std::string> > services;
+    std::optional<time_t>                    creditExpire;
+    std::optional<UserIPs>                   ips;
 };
 //-----------------------------------------------------------------------------
 };
 //-----------------------------------------------------------------------------
-#endif
-
+}