diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/impl/read_at.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/impl/read_at.hpp | 209 |
1 files changed, 183 insertions, 26 deletions
diff --git a/3rdParty/Boost/src/boost/asio/impl/read_at.hpp b/3rdParty/Boost/src/boost/asio/impl/read_at.hpp index dcf2c33..14fddc4 100644 --- a/3rdParty/Boost/src/boost/asio/impl/read_at.hpp +++ b/3rdParty/Boost/src/boost/asio/impl/read_at.hpp @@ -23,6 +23,7 @@ #include <boost/asio/detail/consuming_buffers.hpp> #include <boost/asio/detail/handler_alloc_helpers.hpp> #include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/handler_type_requirements.hpp> #include <boost/asio/detail/throw_error.hpp> #include <boost/asio/error.hpp> @@ -62,10 +63,18 @@ inline std::size_t read_at(SyncRandomAccessReadDevice& d, boost::system::error_code ec; std::size_t bytes_transferred = read_at( d, offset, buffers, transfer_all(), ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } +template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence> +inline std::size_t read_at(SyncRandomAccessReadDevice& d, + boost::uint64_t offset, const MutableBufferSequence& buffers, + boost::system::error_code& ec) +{ + return read_at(d, offset, buffers, transfer_all(), ec); +} + template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> inline std::size_t read_at(SyncRandomAccessReadDevice& d, @@ -75,7 +84,7 @@ inline std::size_t read_at(SyncRandomAccessReadDevice& d, boost::system::error_code ec; std::size_t bytes_transferred = read_at( d, offset, buffers, completion_condition, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } @@ -112,10 +121,18 @@ inline std::size_t read_at(SyncRandomAccessReadDevice& d, boost::system::error_code ec; std::size_t bytes_transferred = read_at( d, offset, b, transfer_all(), ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } +template <typename SyncRandomAccessReadDevice, typename Allocator> +inline std::size_t read_at(SyncRandomAccessReadDevice& d, + boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, + boost::system::error_code& ec) +{ + return read_at(d, offset, b, transfer_all(), ec); +} + template <typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> inline std::size_t read_at(SyncRandomAccessReadDevice& d, @@ -125,7 +142,7 @@ inline std::size_t read_at(SyncRandomAccessReadDevice& d, boost::system::error_code ec; std::size_t bytes_transferred = read_at( d, offset, b, completion_condition, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } @@ -142,16 +159,38 @@ namespace detail public: read_at_op(AsyncRandomAccessReadDevice& device, boost::uint64_t offset, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, ReadHandler handler) + CompletionCondition completion_condition, ReadHandler& handler) : detail::base_from_completion_cond< CompletionCondition>(completion_condition), device_(device), offset_(offset), buffers_(buffers), total_transferred_(0), - handler_(handler) + handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) + read_at_op(const read_at_op& other) + : detail::base_from_completion_cond<CompletionCondition>(other), + device_(other.device_), + offset_(other.offset_), + buffers_(other.buffers_), + total_transferred_(other.total_transferred_), + handler_(other.handler_) + { + } + + read_at_op(read_at_op&& other) + : detail::base_from_completion_cond<CompletionCondition>(other), + device_(other.device_), + offset_(other.offset_), + buffers_(other.buffers_), + total_transferred_(other.total_transferred_), + handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_)) { } +#endif // defined(BOOST_ASIO_HAS_MOVE) void operator()(const boost::system::error_code& ec, std::size_t bytes_transferred, int start = 0) @@ -162,8 +201,8 @@ namespace detail buffers_.prepare(this->check_for_completion(ec, total_transferred_)); for (;;) { - device_.async_read_some_at( - offset_ + total_transferred_, buffers_, *this); + device_.async_read_some_at(offset_ + total_transferred_, + buffers_, BOOST_ASIO_MOVE_CAST(read_at_op)(*this)); return; default: total_transferred_ += bytes_transferred; buffers_.consume(bytes_transferred); @@ -195,17 +234,39 @@ namespace detail public: read_at_op(AsyncRandomAccessReadDevice& device, boost::uint64_t offset, const boost::asio::mutable_buffers_1& buffers, - CompletionCondition completion_condition, ReadHandler handler) + CompletionCondition completion_condition, ReadHandler& handler) : detail::base_from_completion_cond< CompletionCondition>(completion_condition), device_(device), offset_(offset), buffer_(buffers), total_transferred_(0), - handler_(handler) + handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) + read_at_op(const read_at_op& other) + : detail::base_from_completion_cond<CompletionCondition>(other), + device_(other.device_), + offset_(other.offset_), + buffer_(other.buffer_), + total_transferred_(other.total_transferred_), + handler_(other.handler_) { } + read_at_op(read_at_op&& other) + : detail::base_from_completion_cond<CompletionCondition>(other), + device_(other.device_), + offset_(other.offset_), + buffer_(other.buffer_), + total_transferred_(other.total_transferred_), + handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_)) + { + } +#endif // defined(BOOST_ASIO_HAS_MOVE) + void operator()(const boost::system::error_code& ec, std::size_t bytes_transferred, int start = 0) { @@ -217,7 +278,8 @@ namespace detail for (;;) { device_.async_read_some_at(offset_ + total_transferred_, - boost::asio::buffer(buffer_ + total_transferred_, n), *this); + boost::asio::buffer(buffer_ + total_transferred_, n), + BOOST_ASIO_MOVE_CAST(read_at_op)(*this)); return; default: total_transferred_ += bytes_transferred; if ((!ec && bytes_transferred == 0) @@ -263,6 +325,17 @@ namespace detail template <typename Function, typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition, typename ReadHandler> + inline void asio_handler_invoke(Function& function, + read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, + CompletionCondition, ReadHandler>* this_handler) + { + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); + } + + template <typename Function, typename AsyncRandomAccessReadDevice, + typename MutableBufferSequence, typename CompletionCondition, + typename ReadHandler> inline void asio_handler_invoke(const Function& function, read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, CompletionCondition, ReadHandler>* this_handler) @@ -270,17 +343,36 @@ namespace detail boost_asio_handler_invoke_helpers::invoke( function, this_handler->handler_); } + + template <typename AsyncRandomAccessReadDevice, + typename MutableBufferSequence, typename CompletionCondition, + typename ReadHandler> + inline read_at_op<AsyncRandomAccessReadDevice, + MutableBufferSequence, CompletionCondition, ReadHandler> + make_read_at_op(AsyncRandomAccessReadDevice& d, + boost::uint64_t offset, const MutableBufferSequence& buffers, + CompletionCondition completion_condition, ReadHandler handler) + { + return read_at_op<AsyncRandomAccessReadDevice, + MutableBufferSequence, CompletionCondition, ReadHandler>( + d, offset, buffers, completion_condition, handler); + } } // namespace detail template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition, typename ReadHandler> inline void async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, ReadHandler handler) + CompletionCondition completion_condition, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - detail::read_at_op<AsyncRandomAccessReadDevice, - MutableBufferSequence, CompletionCondition, ReadHandler>( - d, offset, buffers, completion_condition, 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; + + detail::make_read_at_op( + d, offset, buffers, completion_condition, + BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))( boost::system::error_code(), 0, 1); } @@ -288,9 +380,16 @@ template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename ReadHandler> inline void async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset, const MutableBufferSequence& buffers, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - async_read_at(d, offset, buffers, transfer_all(), 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; + + detail::make_read_at_op( + d, offset, buffers, transfer_all(), + BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))( + boost::system::error_code(), 0, 1); } #if !defined(BOOST_NO_IOSTREAM) @@ -305,17 +404,39 @@ namespace detail public: read_at_streambuf_op(AsyncRandomAccessReadDevice& device, boost::uint64_t offset, basic_streambuf<Allocator>& streambuf, - CompletionCondition completion_condition, ReadHandler handler) + CompletionCondition completion_condition, ReadHandler& handler) : detail::base_from_completion_cond< CompletionCondition>(completion_condition), device_(device), offset_(offset), streambuf_(streambuf), total_transferred_(0), - handler_(handler) + handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) + read_at_streambuf_op(const read_at_streambuf_op& other) + : detail::base_from_completion_cond<CompletionCondition>(other), + device_(other.device_), + offset_(other.offset_), + streambuf_(other.streambuf_), + total_transferred_(other.total_transferred_), + handler_(other.handler_) { } + read_at_streambuf_op(read_at_streambuf_op&& other) + : detail::base_from_completion_cond<CompletionCondition>(other), + device_(other.device_), + offset_(other.offset_), + streambuf_(other.streambuf_), + total_transferred_(other.total_transferred_), + handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_)) + { + } +#endif // defined(BOOST_ASIO_HAS_MOVE) + void operator()(const boost::system::error_code& ec, std::size_t bytes_transferred, int start = 0) { @@ -328,7 +449,8 @@ namespace detail for (;;) { device_.async_read_some_at(offset_ + total_transferred_, - streambuf_.prepare(bytes_available), *this); + streambuf_.prepare(bytes_available), + BOOST_ASIO_MOVE_CAST(read_at_streambuf_op)(*this)); return; default: total_transferred_ += bytes_transferred; streambuf_.commit(bytes_transferred); @@ -372,6 +494,16 @@ namespace detail template <typename Function, typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> + inline void asio_handler_invoke(Function& function, + read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, + CompletionCondition, ReadHandler>* this_handler) + { + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); + } + + template <typename Function, typename AsyncRandomAccessReadDevice, + typename Allocator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_invoke(const Function& function, read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>* this_handler) @@ -379,17 +511,35 @@ namespace detail boost_asio_handler_invoke_helpers::invoke( function, this_handler->handler_); } + + template <typename AsyncRandomAccessReadDevice, typename Allocator, + typename CompletionCondition, typename ReadHandler> + inline read_at_streambuf_op<AsyncRandomAccessReadDevice, + Allocator, CompletionCondition, ReadHandler> + make_read_at_streambuf_op(AsyncRandomAccessReadDevice& d, + boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, + CompletionCondition completion_condition, ReadHandler handler) + { + return read_at_streambuf_op<AsyncRandomAccessReadDevice, + Allocator, CompletionCondition, ReadHandler>( + d, offset, b, completion_condition, handler); + } } // namespace detail template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline void async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, ReadHandler handler) + CompletionCondition completion_condition, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, - Allocator, CompletionCondition, ReadHandler>( - d, offset, b, completion_condition, 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; + + detail::make_read_at_streambuf_op( + d, offset, b, completion_condition, + BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))( boost::system::error_code(), 0, 1); } @@ -397,9 +547,16 @@ template <typename AsyncRandomAccessReadDevice, typename Allocator, typename ReadHandler> inline void async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - async_read_at(d, offset, b, transfer_all(), 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; + + detail::make_read_at_streambuf_op( + d, offset, b, transfer_all(), + BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))( + boost::system::error_code(), 0, 1); } #endif // !defined(BOOST_NO_IOSTREAM) |