From: Maxim Mamontov <faust.madf@gmail.com>
Date: Sun, 18 Feb 2018 15:31:17 +0000 (+0200)
Subject: Remove redindand ctors from USER_IPS.
X-Git-Tag: 2.409~26
X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/49083e0e0d34cae603af6b7cdf60948747b738f0

Remove redindand ctors from USER_IPS.
---

diff --git a/include/stg/user_ips.h b/include/stg/user_ips.h
index 52e5df77..fa107fc9 100644
--- a/include/stg/user_ips.h
+++ b/include/stg/user_ips.h
@@ -48,7 +48,6 @@
 struct IP_MASK
 {
 IP_MASK() : ip(0), mask(0) {}
-IP_MASK(const IP_MASK & ipm) : ip(ipm.ip), mask(ipm.mask)  {}
 uint32_t ip;
 uint32_t mask;
 };
@@ -56,24 +55,19 @@ uint32_t mask;
 class USER_IPS
 {
     friend std::ostream & operator<< (std::ostream & o, const USER_IPS & i);
-    //friend stringstream & operator<< (stringstream & s, const USER_IPS & i);
     friend const USER_IPS StrToIPS(const std::string & ipsStr);
 
 public:
     typedef std::vector<IP_MASK> ContainerType;
     typedef ContainerType::size_type IndexType;
 
-    USER_IPS();
-    USER_IPS(const USER_IPS &);
-    USER_IPS & operator=(const USER_IPS &);
-    const IP_MASK & operator[](IndexType idx) const;
+    const IP_MASK & operator[](IndexType idx) const { return ips[idx]; }
     std::string GetIpStr() const;
     bool IsIPInIPS(uint32_t ip) const;
     bool OnlyOneIP() const;
     bool IsAnyIP() const;
-    size_t  Count() const;
-    void Add(const IP_MASK &im);
-    void Erase();
+    size_t Count() const { return ips.size(); }
+    void Add(const IP_MASK &im) { ips.push_back(im); }
 
 private:
     uint32_t CalcMask(unsigned int msk) const;
@@ -81,29 +75,6 @@ private:
 };
 //-------------------------------------------------------------------------
 
-//-----------------------------------------------------------------------------
-inline
-USER_IPS::USER_IPS()
-    : ips()
-{}
-//-----------------------------------------------------------------------------
-inline
-USER_IPS::USER_IPS(const USER_IPS & i)
-    : ips(i.ips)
-{}
-//-----------------------------------------------------------------------------
-inline
-USER_IPS & USER_IPS::operator=(const USER_IPS & i)
-{
-ips = i.ips;
-return *this;
-}
-//-----------------------------------------------------------------------------
-inline
-const IP_MASK & USER_IPS::operator[](IndexType idx) const
-{
-return ips[idx];
-}
 //-----------------------------------------------------------------------------
 inline
 std::string USER_IPS::GetIpStr() const
@@ -130,12 +101,6 @@ return s.str();
 }
 //-----------------------------------------------------------------------------
 inline
-size_t USER_IPS::Count() const
-{
-return ips.size();
-}
-//-----------------------------------------------------------------------------
-inline
 uint32_t USER_IPS::CalcMask(unsigned int msk) const
 {
 if (msk > 32)
@@ -179,30 +144,11 @@ bool USER_IPS::IsAnyIP() const
 }
 //-----------------------------------------------------------------------------
 inline
-void USER_IPS::Add(const IP_MASK &im)
-{
-ips.push_back(im);
-}
-//-----------------------------------------------------------------------------
-inline
-void USER_IPS::Erase()
-{
-ips.erase(ips.begin(), ips.end());
-}
-//-----------------------------------------------------------------------------
-inline
 std::ostream & operator<<(std::ostream & o, const USER_IPS & i)
 {
 return o << i.GetIpStr();
 }
 //-----------------------------------------------------------------------------
-/*inline
-stringstream & operator<<(std::stringstream & s, const USER_IPS & i)
-{
-s << i.GetIpStr();
-return s;
-}*/
-//-----------------------------------------------------------------------------
 inline
 const USER_IPS StrToIPS(const std::string & ipsStr)
 {
diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp
index 2e92603e..d98d7929 100644
--- a/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp
+++ b/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp
@@ -537,14 +537,15 @@ try
                  where fk_user = ?");
     st->Set(1, uid);
     st->Execute();
-    conf->ips.Erase();
+    USER_IPS ips;
     while (st->Fetch())
         {
         IP_MASK im;
         st->Get(1, (int32_t &)im.ip);
         st->Get(2, (int32_t &)im.mask);
-        conf->ips.Add(im);
+        ips.Add(im);
         }
+    conf->ips = ips;
 
     tr->Commit();
     }
diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp
index 519074b1..47999efc 100644
--- a/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp
+++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp
@@ -954,26 +954,22 @@ if (PQresultStatus(result) != PGRES_TUPLES_OK)
 
 tuples = PQntuples(result);
 
-conf->ips.Erase();
+USER_IPS ips;
 for (int i = 0; i < tuples; ++i)
     {
-    IP_MASK ipm;
+    IP_MASK im;
 
-    int ip, mask;
+    im.ip = inet_strington(PQgetvalue(result, i, 0));
 
-    ip = inet_strington(PQgetvalue(result, i, 0));
-
-    if (str2x(PQgetvalue(result, i, 1), mask))
+    if (str2x(PQgetvalue(result, i, 1), im.mask))
         {
         printfd(__FILE__, "POSTGRESQL_STORE::RestoreUserConf(): 'Failed to fetch mask'\n");
         continue;
         }
 
-    ipm.ip = ip;
-    ipm.mask = mask;
-
-    conf->ips.Add(ipm);
+    ips.Add(im);
     }
+conf->ips = ips;
 
 PQclear(result);