diff --git a/ChangeLog b/ChangeLog index 1b97d634..4aa1d8c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-11-20 Tatsuhiro Tsujikawa + + Added CookieStorage::DomainEntry::swap(). Also added non-member + swap for it. + * src/CookieStorage.cc + * src/CookieStorage.h + 2010-11-20 Tatsuhiro Tsujikawa Made LogFactory::logger_ as SharedHandle to make dtor of diff --git a/src/CookieStorage.cc b/src/CookieStorage.cc index 430b3446..2c98b123 100644 --- a/src/CookieStorage.cc +++ b/src/CookieStorage.cc @@ -79,6 +79,19 @@ CookieStorage::DomainEntry& CookieStorage::DomainEntry::operator= return *this; } +void CookieStorage::DomainEntry::swap(CookieStorage::DomainEntry& c) +{ + using std::swap; + swap(key_, c.key_); + swap(lastAccessTime_, c.lastAccessTime_); + swap(cookies_, c.cookies_); +} + +void swap(CookieStorage::DomainEntry& a, CookieStorage::DomainEntry& b) +{ + a.swap(b); +} + bool CookieStorage::DomainEntry::addCookie(const Cookie& cookie, time_t now) { setLastAccessTime(now); @@ -395,3 +408,14 @@ bool CookieStorage::saveNsFormat(const std::string& filename) } } // namespace aria2 + +namespace std { +template<> +void swap +(aria2::CookieStorage::DomainEntry& a, + aria2::CookieStorage::DomainEntry& b) +{ + a.swap(b); +} +} // namespace std + diff --git a/src/CookieStorage.h b/src/CookieStorage.h index 8e9aa3e6..b523dc3f 100644 --- a/src/CookieStorage.h +++ b/src/CookieStorage.h @@ -67,6 +67,8 @@ public: DomainEntry(const DomainEntry& c); ~DomainEntry(); + void swap(DomainEntry& c); + DomainEntry& operator=(const DomainEntry& c); const std::string& getKey() const @@ -183,6 +185,15 @@ public: } }; +void swap(CookieStorage::DomainEntry& a, CookieStorage::DomainEntry& b); + } // namespace aria2 +namespace std { +template<> +void swap +(aria2::CookieStorage::DomainEntry& a, + aria2::CookieStorage::DomainEntry& b); +} // namespace std + #endif // D_COOKIE_STORAGE_H