From ab2f71e27873a18565cd1d5aca891ebb89dec32a Mon Sep 17 00:00:00 2001 From: Daniel M <daniel.q.mueller@stud.h-da.de> Date: Sat, 29 May 2021 15:28:20 +0200 Subject: [PATCH] Fix sockcopy compile issue --- inc/sockcopy.hpp | 36 ++++++------------------------------ src/sockcopy.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 src/sockcopy.cpp diff --git a/inc/sockcopy.hpp b/inc/sockcopy.hpp index 05899e6..364accd 100644 --- a/inc/sockcopy.hpp +++ b/inc/sockcopy.hpp @@ -95,42 +95,18 @@ public: }; -SockCopy<TcpStream> wrapCopy(TcpStream & other, bool disableAutoclose = true) -{ - if (disableAutoclose) other.setAutoclose(false); - return SockCopy<TcpStream>(other); -} +SockCopy<TcpStream> wrapCopy(TcpStream & other, bool disableAutoclose = true); -SockCopy<TcpListener> wrapCopy(TcpListener & other, bool disableAutoclose = true) -{ - if (disableAutoclose) other.setAutoclose(false); - return SockCopy<TcpListener>(other); -} +SockCopy<TcpListener> wrapCopy(TcpListener & other, bool disableAutoclose = true); -SockCopy<UdpSocket> wrapCopy(UdpSocket & other, bool disableAutoclose = true) -{ - if (disableAutoclose) other.setAutoclose(false); - return SockCopy<UdpSocket>(other); -} +SockCopy<UdpSocket> wrapCopy(UdpSocket & other, bool disableAutoclose = true); -SockCopy<TcpStream> wrapCopy(TcpStream && other, bool disableAutoclose = true) -{ - if (disableAutoclose) other.setAutoclose(false); - return SockCopy<TcpStream>(std::move(other)); -} +SockCopy<TcpStream> wrapCopy(TcpStream && other, bool disableAutoclose = true); -SockCopy<TcpListener> wrapCopy(TcpListener && other, bool disableAutoclose = true) -{ - if (disableAutoclose) other.setAutoclose(false); - return SockCopy<TcpListener>(std::move(other)); -} +SockCopy<TcpListener> wrapCopy(TcpListener && other, bool disableAutoclose = true); -SockCopy<UdpSocket> wrapCopy(UdpSocket && other, bool disableAutoclose = true) -{ - if (disableAutoclose) other.setAutoclose(false); - return SockCopy<UdpSocket>(std::move(other)); -} +SockCopy<UdpSocket> wrapCopy(UdpSocket && other, bool disableAutoclose = true); } // namespace netlib diff --git a/src/sockcopy.cpp b/src/sockcopy.cpp new file mode 100644 index 0000000..9c4b4b6 --- /dev/null +++ b/src/sockcopy.cpp @@ -0,0 +1,45 @@ +#include "sockcopy.hpp" + +namespace netlib +{ + + +SockCopy<TcpStream> wrapCopy(TcpStream & other, bool disableAutoclose = true) +{ + if (disableAutoclose) other.setAutoclose(false); + return SockCopy<TcpStream>(other); +} + +SockCopy<TcpListener> wrapCopy(TcpListener & other, bool disableAutoclose = true) +{ + if (disableAutoclose) other.setAutoclose(false); + return SockCopy<TcpListener>(other); +} + +SockCopy<UdpSocket> wrapCopy(UdpSocket & other, bool disableAutoclose = true) +{ + if (disableAutoclose) other.setAutoclose(false); + return SockCopy<UdpSocket>(other); +} + + +SockCopy<TcpStream> wrapCopy(TcpStream && other, bool disableAutoclose = true) +{ + if (disableAutoclose) other.setAutoclose(false); + return SockCopy<TcpStream>(std::move(other)); +} + +SockCopy<TcpListener> wrapCopy(TcpListener && other, bool disableAutoclose = true) +{ + if (disableAutoclose) other.setAutoclose(false); + return SockCopy<TcpListener>(std::move(other)); +} + +SockCopy<UdpSocket> wrapCopy(UdpSocket && other, bool disableAutoclose = true) +{ + if (disableAutoclose) other.setAutoclose(false); + return SockCopy<UdpSocket>(std::move(other)); +} + + +} // namespace netlib -- GitLab