diff options
Diffstat (limited to '3rdparty/asio/include/asio/basic_socket_iostream.hpp')
-rw-r--r-- | 3rdparty/asio/include/asio/basic_socket_iostream.hpp | 157 |
1 files changed, 34 insertions, 123 deletions
diff --git a/3rdparty/asio/include/asio/basic_socket_iostream.hpp b/3rdparty/asio/include/asio/basic_socket_iostream.hpp index ad4759bec29..902898d9502 100644 --- a/3rdparty/asio/include/asio/basic_socket_iostream.hpp +++ b/3rdparty/asio/include/asio/basic_socket_iostream.hpp @@ -2,7 +2,7 @@ // basic_socket_iostream.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -23,61 +23,6 @@ #include <ostream> #include "asio/basic_socket_streambuf.hpp" -#if defined(ASIO_ENABLE_OLD_SERVICES) -# include "asio/stream_socket_service.hpp" -#endif // defined(ASIO_ENABLE_OLD_SERVICES) - -#if !defined(ASIO_HAS_VARIADIC_TEMPLATES) - -# include "asio/detail/variadic_templates.hpp" - -// A macro that should expand to: -// template <typename T1, ..., typename Tn> -// explicit basic_socket_iostream(T1 x1, ..., Tn xn) -// : std::basic_iostream<char>( -// &this->detail::socket_iostream_base< -// Protocol ASIO_SVC_TARG, Clock, -// WaitTraits ASIO_SVC_TARG1>::streambuf_) -// { -// if (rdbuf()->connect(x1, ..., xn) == 0) -// this->setstate(std::ios_base::failbit); -// } -// This macro should only persist within this file. - -# define ASIO_PRIVATE_CTR_DEF(n) \ - template <ASIO_VARIADIC_TPARAMS(n)> \ - explicit basic_socket_iostream(ASIO_VARIADIC_BYVAL_PARAMS(n)) \ - : std::basic_iostream<char>( \ - &this->detail::socket_iostream_base< \ - Protocol ASIO_SVC_TARG, Clock, \ - WaitTraits ASIO_SVC_TARG1>::streambuf_) \ - { \ - this->setf(std::ios_base::unitbuf); \ - if (rdbuf()->connect(ASIO_VARIADIC_BYVAL_ARGS(n)) == 0) \ - this->setstate(std::ios_base::failbit); \ - } \ - /**/ - -// A macro that should expand to: -// template <typename T1, ..., typename Tn> -// void connect(T1 x1, ..., Tn xn) -// { -// if (rdbuf()->connect(x1, ..., xn) == 0) -// this->setstate(std::ios_base::failbit); -// } -// This macro should only persist within this file. - -# define ASIO_PRIVATE_CONNECT_DEF(n) \ - template <ASIO_VARIADIC_TPARAMS(n)> \ - void connect(ASIO_VARIADIC_BYVAL_PARAMS(n)) \ - { \ - if (rdbuf()->connect(ASIO_VARIADIC_BYVAL_ARGS(n)) == 0) \ - this->setstate(std::ios_base::failbit); \ - } \ - /**/ - -#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) - #include "asio/detail/push_options.hpp" namespace asio { @@ -85,8 +30,7 @@ namespace detail { // A separate base class is used to ensure that the streambuf is initialised // prior to the basic_socket_iostream's basic_iostream base class. -template <typename Protocol ASIO_SVC_TPARAM, - typename Clock, typename WaitTraits ASIO_SVC_TPARAM1> +template <typename Protocol, typename Clock, typename WaitTraits> class socket_iostream_base { protected: @@ -94,7 +38,6 @@ protected: { } -#if defined(ASIO_HAS_MOVE) socket_iostream_base(socket_iostream_base&& other) : streambuf_(std::move(other.streambuf_)) { @@ -110,10 +53,8 @@ protected: streambuf_ = std::move(other.streambuf_); return *this; } -#endif // defined(ASIO_HAS_MOVE) - basic_socket_streambuf<Protocol ASIO_SVC_TARG, - Clock, WaitTraits ASIO_SVC_TARG1> streambuf_; + basic_socket_streambuf<Protocol, Clock, WaitTraits> streambuf_; }; } // namespace detail @@ -122,17 +63,17 @@ protected: #define ASIO_BASIC_SOCKET_IOSTREAM_FWD_DECL // Forward declaration with defaulted arguments. -template <typename Protocol - ASIO_SVC_TPARAM_DEF1(= stream_socket_service<Protocol>), -#if defined(ASIO_HAS_BOOST_DATE_TIME) +template <typename Protocol, +#if defined(ASIO_HAS_BOOST_DATE_TIME) \ + && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) typename Clock = boost::posix_time::ptime, - typename WaitTraits = time_traits<Clock> - ASIO_SVC_TPARAM1_DEF2(= deadline_timer_service<Clock, WaitTraits>)> -#else + typename WaitTraits = time_traits<Clock>> +#else // defined(ASIO_HAS_BOOST_DATE_TIME) + // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) typename Clock = chrono::steady_clock, - typename WaitTraits = wait_traits<Clock> - ASIO_SVC_TPARAM1_DEF1(= steady_timer::service_type)> -#endif + typename WaitTraits = wait_traits<Clock>> +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) class basic_socket_iostream; #endif // !defined(ASIO_BASIC_SOCKET_IOSTREAM_FWD_DECL) @@ -141,24 +82,25 @@ class basic_socket_iostream; #if defined(GENERATING_DOCUMENTATION) template <typename Protocol, typename Clock = chrono::steady_clock, - typename WaitTraits = wait_traits<Clock> > + typename WaitTraits = wait_traits<Clock>> #else // defined(GENERATING_DOCUMENTATION) -template <typename Protocol ASIO_SVC_TPARAM, - typename Clock, typename WaitTraits ASIO_SVC_TPARAM1> +template <typename Protocol, typename Clock, typename WaitTraits> #endif // defined(GENERATING_DOCUMENTATION) class basic_socket_iostream - : private detail::socket_iostream_base<Protocol - ASIO_SVC_TARG, Clock, WaitTraits ASIO_SVC_TARG1>, + : private detail::socket_iostream_base<Protocol, Clock, WaitTraits>, public std::basic_iostream<char> { private: // These typedefs are intended keep this class's implementation independent // of whether it's using Boost.DateClock, Boost.Chrono or std::chrono. -#if defined(ASIO_HAS_BOOST_DATE_TIME) +#if defined(ASIO_HAS_BOOST_DATE_TIME) \ + && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) typedef WaitTraits traits_helper; -#else +#else // defined(ASIO_HAS_BOOST_DATE_TIME) + // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) typedef detail::chrono_time_traits<Clock, WaitTraits> traits_helper; -#endif +#endif // defined(ASIO_HAS_BOOST_DATE_TIME) + // && defined(ASIO_USE_BOOST_DATE_TIME_FOR_SOCKET_IOSTREAM) public: /// The protocol type. @@ -195,22 +137,18 @@ public: basic_socket_iostream() : std::basic_iostream<char>( &this->detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>::streambuf_) + Protocol, Clock, WaitTraits>::streambuf_) { this->setf(std::ios_base::unitbuf); } -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Construct a basic_socket_iostream from the supplied socket. explicit basic_socket_iostream(basic_stream_socket<protocol_type> s) : detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>(std::move(s)), + Protocol, Clock, WaitTraits>(std::move(s)), std::basic_iostream<char>( &this->detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>::streambuf_) + Protocol, Clock, WaitTraits>::streambuf_) { this->setf(std::ios_base::unitbuf); } @@ -218,13 +156,11 @@ public: /// Move-construct a basic_socket_iostream from another. basic_socket_iostream(basic_socket_iostream&& other) : detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>(std::move(other)), + Protocol, Clock, WaitTraits>(std::move(other)), std::basic_iostream<char>(std::move(other)) { this->set_rdbuf(&this->detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>::streambuf_); + Protocol, Clock, WaitTraits>::streambuf_); } /// Move-assign a basic_socket_iostream from another. @@ -232,56 +168,39 @@ public: { std::basic_iostream<char>::operator=(std::move(other)); detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>::operator=(std::move(other)); + Protocol, Clock, WaitTraits>::operator=(std::move(other)); return *this; } -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) -#if defined(GENERATING_DOCUMENTATION) /// Establish a connection to an endpoint corresponding to a resolver query. /** * This constructor automatically establishes a connection based on the * supplied resolver query parameters. The arguments are used to construct * a resolver query object. */ - template <typename T1, ..., typename TN> - explicit basic_socket_iostream(T1 t1, ..., TN tn); -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) template <typename... T> explicit basic_socket_iostream(T... x) : std::basic_iostream<char>( &this->detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>::streambuf_) + Protocol, Clock, WaitTraits>::streambuf_) { this->setf(std::ios_base::unitbuf); if (rdbuf()->connect(x...) == 0) this->setstate(std::ios_base::failbit); } -#else - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_CTR_DEF) -#endif -#if defined(GENERATING_DOCUMENTATION) /// Establish a connection to an endpoint corresponding to a resolver query. /** * This function automatically establishes a connection based on the supplied * resolver query parameters. The arguments are used to construct a resolver * query object. */ - template <typename T1, ..., typename TN> - void connect(T1 t1, ..., TN tn); -#elif defined(ASIO_HAS_VARIADIC_TEMPLATES) template <typename... T> void connect(T... x) { if (rdbuf()->connect(x...) == 0) this->setstate(std::ios_base::failbit); } -#else - ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_CONNECT_DEF) -#endif /// Close the connection. void close() @@ -291,18 +210,15 @@ public: } /// Return a pointer to the underlying streambuf. - basic_socket_streambuf<Protocol ASIO_SVC_TARG, - Clock, WaitTraits ASIO_SVC_TARG1>* rdbuf() const + basic_socket_streambuf<Protocol, Clock, WaitTraits>* rdbuf() const { - return const_cast<basic_socket_streambuf<Protocol ASIO_SVC_TARG, - Clock, WaitTraits ASIO_SVC_TARG1>*>( + return const_cast<basic_socket_streambuf<Protocol, Clock, WaitTraits>*>( &this->detail::socket_iostream_base< - Protocol ASIO_SVC_TARG, Clock, - WaitTraits ASIO_SVC_TARG1>::streambuf_); + Protocol, Clock, WaitTraits>::streambuf_); } /// Get a reference to the underlying socket. - basic_socket<Protocol ASIO_SVC_TARG>& socket() + basic_socket<Protocol>& socket() { return rdbuf()->socket(); } @@ -401,20 +317,15 @@ public: private: // Disallow copying and assignment. - basic_socket_iostream(const basic_socket_iostream&) ASIO_DELETED; + basic_socket_iostream(const basic_socket_iostream&) = delete; basic_socket_iostream& operator=( - const basic_socket_iostream&) ASIO_DELETED; + const basic_socket_iostream&) = delete; }; } // namespace asio #include "asio/detail/pop_options.hpp" -#if !defined(ASIO_HAS_VARIADIC_TEMPLATES) -# undef ASIO_PRIVATE_CTR_DEF -# undef ASIO_PRIVATE_CONNECT_DEF -#endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) - #endif // !defined(ASIO_NO_IOSTREAM) #endif // ASIO_BASIC_SOCKET_IOSTREAM_HPP |