diff --git a/inc/sockcopy.hpp b/inc/sockcopy.hpp index 05899e6cc3f8db72650f3354e3c6cb229b54608b..364accd123c0978a07fd17f9152dd8c84b006dfa 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 0000000000000000000000000000000000000000..9c4b4b6bb011845aa8b1daa1c1d6455880d6b9b8 --- /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