swap and operator= for IP_RANGE
authorGerd von Egidy <gerd.von.egidy@intra2net.com>
Tue, 7 Sep 2010 08:40:05 +0000 (10:40 +0200)
committerGerd von Egidy <gerd.von.egidy@intra2net.com>
Tue, 7 Sep 2010 08:40:05 +0000 (10:40 +0200)
src/ipfunc.cpp
src/ipfunc.hxx

index c7bda20..521c6a3 100644 (file)
 using namespace std;
 using namespace ip_type;
 
+IP_RANGE& IP_RANGE::operator=(const IP_RANGE& other)
+{
+    IP_RANGE temp(other);
+    temp.swap(*this);
+    return *this;
+}
+
+void IP_RANGE::swap(IP_RANGE& other)
+{
+    std::swap(ip,other.ip);
+    std::swap(mask,other.mask);
+    std::swap(end,other.end);
+    std::swap(t,other.t);
+}
+
 // can decode IP, IP-IP (as range) and IP/MASK (as network)
 void IP_RANGE::load(const std::string& ip)
 {
index a708179..06cef4c 100644 (file)
@@ -44,7 +44,10 @@ class IP_RANGE
             { load(t,ip,mask_or_end); }
         IP_RANGE(ip_type::type t, unsigned int ip, unsigned int mask_or_end=0)
             { load(t,ip,mask_or_end); }
-        
+
+        IP_RANGE& operator=(const IP_RANGE& other);
+        void swap(IP_RANGE& other);
+
         void load(const std::string& ip);                     // can decode IP-IP (as range) and IP/MASK (as network)
         void load(ip_type::type t, const std::string& ip, const std::string& mask_or_end="");
         void load(ip_type::type t, unsigned int ip, unsigned int mask_or_end=0);