diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/windows/basic_stream_handle.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/windows/basic_stream_handle.hpp | 87 |
1 files changed, 71 insertions, 16 deletions
diff --git a/3rdParty/Boost/src/boost/asio/windows/basic_stream_handle.hpp b/3rdParty/Boost/src/boost/asio/windows/basic_stream_handle.hpp index 105b041..ccc8f09 100644 --- a/3rdParty/Boost/src/boost/asio/windows/basic_stream_handle.hpp +++ b/3rdParty/Boost/src/boost/asio/windows/basic_stream_handle.hpp @@ -2,7 +2,7 @@ // windows/basic_stream_handle.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 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) @@ -21,10 +21,11 @@ || defined(GENERATING_DOCUMENTATION) #include <cstddef> +#include <boost/asio/detail/handler_type_requirements.hpp> +#include <boost/asio/detail/throw_error.hpp> #include <boost/asio/error.hpp> #include <boost/asio/windows/basic_handle.hpp> #include <boost/asio/windows/stream_handle_service.hpp> -#include <boost/asio/detail/throw_error.hpp> #include <boost/asio/detail/push_options.hpp> @@ -49,8 +50,12 @@ class basic_stream_handle : public basic_handle<StreamHandleService> { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// handle. + typedef typename StreamHandleService::native_handle_type native_type; + /// The native representation of a handle. - typedef typename StreamHandleService::native_type native_type; + typedef typename StreamHandleService::native_handle_type native_handle_type; /// Construct a basic_stream_handle without opening it. /** @@ -74,16 +79,52 @@ public: * @param io_service The io_service object that the stream handle will use to * dispatch handlers for any asynchronous operations performed on the handle. * - * @param native_handle The new underlying handle implementation. + * @param handle The new underlying handle implementation. * * @throws boost::system::system_error Thrown on failure. */ basic_stream_handle(boost::asio::io_service& io_service, - const native_type& native_handle) - : basic_handle<StreamHandleService>(io_service, native_handle) + const native_handle_type& handle) + : basic_handle<StreamHandleService>(io_service, handle) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_stream_handle from another. + /** + * This constructor moves a stream handle from one object to another. + * + * @param other The other basic_stream_handle object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_stream_handle(io_service&) constructor. + */ + basic_stream_handle(basic_stream_handle&& other) + : basic_handle<StreamHandleService>( + BOOST_ASIO_MOVE_CAST(basic_stream_handle)(other)) { } + /// Move-assign a basic_stream_handle from another. + /** + * This assignment operator moves a stream handle from one object to + * another. + * + * @param other The other basic_stream_handle object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_stream_handle(io_service&) constructor. + */ + basic_stream_handle& operator=(basic_stream_handle&& other) + { + basic_handle<StreamHandleService>::operator=( + BOOST_ASIO_MOVE_CAST(basic_stream_handle)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Write some data to the handle. /** * This function is used to write data to the stream handle. The function call @@ -115,8 +156,9 @@ public: std::size_t write_some(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.write_some(this->implementation, buffers, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().write_some( + this->get_implementation(), buffers, ec); + boost::asio::detail::throw_error(ec, "write_some"); return s; } @@ -140,7 +182,8 @@ public: std::size_t write_some(const ConstBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.write_some(this->implementation, buffers, ec); + return this->get_service().write_some( + this->get_implementation(), buffers, ec); } /// Start an asynchronous write. @@ -180,9 +223,14 @@ public: */ template <typename ConstBufferSequence, typename WriteHandler> void async_write_some(const ConstBufferSequence& buffers, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_write_some(this->implementation, buffers, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_write_some(this->get_implementation(), + buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Read some data from the handle. @@ -217,8 +265,9 @@ public: std::size_t read_some(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.read_some(this->implementation, buffers, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().read_some( + this->get_implementation(), buffers, ec); + boost::asio::detail::throw_error(ec, "read_some"); return s; } @@ -243,7 +292,8 @@ public: std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.read_some(this->implementation, buffers, ec); + return this->get_service().read_some( + this->get_implementation(), buffers, ec); } /// Start an asynchronous read. @@ -284,9 +334,14 @@ public: */ template <typename MutableBufferSequence, typename ReadHandler> void async_read_some(const MutableBufferSequence& buffers, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_read_some(this->implementation, buffers, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_read_some(this->get_implementation(), + buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; |