]> git.stg.codes - stg.git/blob - include/stg/user_conf.h
Fix compilation.
[stg.git] / include / stg / user_conf.h
1 #pragma once
2
3 #include "user_ips.h"
4
5 #include <string>
6 #include <vector>
7 #include <optional>
8 #include <cstdint>
9 #include "const.h"
10
11 namespace STG
12 {
13
14 //-----------------------------------------------------------------------------
15 struct UserConf
16 {
17     UserConf() noexcept
18         : passive(0),
19           disabled(0),
20           disabledDetailStat(0),
21           alwaysOnline(0),
22           credit(0),
23           userdata(USERDATA_NUM),
24           creditExpire(0)
25     {}
26
27     UserConf(const UserConf&) = default;
28     UserConf& operator=(const UserConf&) = default;
29     UserConf(UserConf&&) = default;
30     UserConf& operator=(UserConf&&) = default;
31
32     std::string              password;
33     int                      passive;
34     int                      disabled;
35     int                      disabledDetailStat;
36     int                      alwaysOnline;
37     std::string              tariffName;
38     std::string              address;
39     std::string              phone;
40     std::string              email;
41     std::string              note;
42     std::string              realName;
43     std::string              corp;
44     std::vector<std::string> services;
45     std::string              group;
46     double                   credit;
47     std::string              nextTariff;
48     std::vector<std::string> userdata;
49     time_t                   creditExpire;
50     UserIPs                  ips;
51 };
52 //-----------------------------------------------------------------------------
53 struct UserConfOpt
54 {
55     UserConfOpt() noexcept
56         : userdata(USERDATA_NUM)
57     {}
58     UserConfOpt(const UserConf& data) noexcept
59         : password(data.password),
60           passive(data.passive),
61           disabled(data.disabled),
62           disabledDetailStat(data.disabledDetailStat),
63           alwaysOnline(data.alwaysOnline),
64           tariffName(data.tariffName),
65           address(data.address),
66           phone(data.phone),
67           email(data.email),
68           note(data.note),
69           realName(data.realName),
70           corp(data.corp),
71           group(data.group),
72           credit(data.credit),
73           nextTariff(data.nextTariff),
74           userdata(USERDATA_NUM),
75           services(data.services),
76           creditExpire(data.creditExpire),
77           ips(data.ips)
78     {
79         for (size_t i = 0; i < USERDATA_NUM; i++)
80             userdata[i]  = data.userdata[i];
81     }
82     UserConfOpt& operator=(const UserConf& uc) noexcept
83     {
84         userdata.resize(USERDATA_NUM);
85         password     = uc.password;
86         passive      = uc.passive;
87         disabled     = uc.disabled;
88         disabledDetailStat = uc.disabledDetailStat;
89         alwaysOnline = uc.alwaysOnline;
90         tariffName   = uc.tariffName;
91         address      = uc.address;
92         phone        = uc.phone;
93         email        = uc.email;
94         note         = uc.note;
95         realName     = uc.realName;
96         corp         = uc.corp;
97         group        = uc.group;
98         credit       = uc.credit;
99         nextTariff   = uc.nextTariff;
100         for (size_t i = 0; i < USERDATA_NUM; i++) userdata[i]  = uc.userdata[i];
101         services     = uc.services;
102         creditExpire = uc.creditExpire;
103         ips          = uc.ips;
104         return *this;
105     }
106     //-------------------------------------------------------------------------
107
108     UserConfOpt(const UserConfOpt&) = default;
109     UserConfOpt& operator=(const UserConfOpt&) = default;
110     UserConfOpt(UserConfOpt&&) = default;
111     UserConfOpt& operator=(UserConfOpt&&) = default;
112
113     std::optional<std::string>               password;
114     std::optional<int>                       passive;
115     std::optional<int>                       disabled;
116     std::optional<int>                       disabledDetailStat;
117     std::optional<int>                       alwaysOnline;
118     std::optional<std::string>               tariffName;
119     std::optional<std::string>               address;
120     std::optional<std::string>               phone;
121     std::optional<std::string>               email;
122     std::optional<std::string>               note;
123     std::optional<std::string>               realName;
124     std::optional<std::string>               corp;
125     std::optional<std::string>               group;
126     std::optional<double>                    credit;
127     std::optional<std::string>               nextTariff;
128     std::vector<std::optional<std::string> > userdata;
129     std::optional<std::vector<std::string> > services;
130     std::optional<time_t>                    creditExpire;
131     std::optional<UserIPs>                   ips;
132 };
133 //-----------------------------------------------------------------------------
134 }