From bb20d988d78ec9a9c26e3b971e16b8a4f0b168eb Mon Sep 17 00:00:00 2001 From: Gerd von Egidy Date: Tue, 7 Sep 2010 10:40:05 +0200 Subject: [PATCH] swap and operator= for IP_RANGE --- src/ipfunc.cpp | 15 +++++++++++++++ src/ipfunc.hxx | 5 ++++- 2 files changed, 19 insertions(+), 1 deletions(-) diff --git a/src/ipfunc.cpp b/src/ipfunc.cpp index c7bda20..521c6a3 100644 --- a/src/ipfunc.cpp +++ b/src/ipfunc.cpp @@ -19,6 +19,21 @@ 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) { diff --git a/src/ipfunc.hxx b/src/ipfunc.hxx index a708179..06cef4c 100644 --- a/src/ipfunc.hxx +++ b/src/ipfunc.hxx @@ -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); -- 1.7.1