Chris@16: // Chris@16: // read_at.hpp Chris@16: // ~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_READ_AT_HPP Chris@16: #define BOOST_ASIO_READ_AT_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: Chris@16: /** Chris@16: * @defgroup read_at boost::asio::read_at Chris@16: * Chris@16: * @brief Attempt to read a certain amount of data at the specified offset Chris@16: * before returning. Chris@16: */ Chris@16: /*@{*/ Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li The supplied buffers are full. That is, the bytes transferred is equal to Chris@16: * the sum of the buffer sizes. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param buffers One or more buffers into which the data will be read. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to read from the Chris@16: * device. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: * Chris@16: * @par Example Chris@16: * To read into a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::read_at(d, 42, boost::asio::buffer(data, size)); @endcode Chris@16: * See the @ref buffer documentation for information on reading into multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::read_at( Chris@16: * d, 42, buffers, Chris@16: * boost::asio::transfer_all()); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, const MutableBufferSequence& buffers); Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li The supplied buffers are full. That is, the bytes transferred is equal to Chris@16: * the sum of the buffer sizes. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param buffers One or more buffers into which the data will be read. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to read from the Chris@16: * device. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @par Example Chris@16: * To read into a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::read_at(d, 42, Chris@16: * boost::asio::buffer(data, size), ec); @endcode Chris@16: * See the @ref buffer documentation for information on reading into multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::read_at( Chris@16: * d, 42, buffers, Chris@16: * boost::asio::transfer_all(), ec); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, const MutableBufferSequence& buffers, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li The supplied buffers are full. That is, the bytes transferred is equal to Chris@16: * the sum of the buffer sizes. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param buffers One or more buffers into which the data will be read. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to read from the Chris@16: * device. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the read operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest read_some_at operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the read operation is complete. A non-zero Chris@16: * return value indicates the maximum number of bytes to be read on the next Chris@16: * call to the device's read_some_at function. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: * Chris@16: * @par Example Chris@16: * To read into a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::read_at(d, 42, boost::asio::buffer(data, size), Chris@16: * boost::asio::transfer_at_least(32)); @endcode Chris@16: * See the @ref buffer documentation for information on reading into multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, const MutableBufferSequence& buffers, Chris@16: CompletionCondition completion_condition); Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li The supplied buffers are full. That is, the bytes transferred is equal to Chris@16: * the sum of the buffer sizes. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param buffers One or more buffers into which the data will be read. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to read from the Chris@16: * device. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the read operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest read_some_at operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the read operation is complete. A non-zero Chris@16: * return value indicates the maximum number of bytes to be read on the next Chris@16: * call to the device's read_some_at function. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes read. If an error occurs, returns the total Chris@16: * number of bytes successfully transferred prior to the error. Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, const MutableBufferSequence& buffers, Chris@16: CompletionCondition completion_condition, boost::system::error_code& ec); Chris@16: Chris@16: #if !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param b The basic_streambuf object into which the data will be read. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::read_at( Chris@16: * d, 42, b, Chris@16: * boost::asio::transfer_all()); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, basic_streambuf& b); Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param b The basic_streambuf object into which the data will be read. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::read_at( Chris@16: * d, 42, b, Chris@16: * boost::asio::transfer_all(), ec); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, basic_streambuf& b, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param b The basic_streambuf object into which the data will be read. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the read operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest read_some_at operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the read operation is complete. A non-zero Chris@16: * return value indicates the maximum number of bytes to be read on the next Chris@16: * call to the device's read_some_at function. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, basic_streambuf& b, Chris@16: CompletionCondition completion_condition); Chris@16: Chris@16: /// Attempt to read a certain amount of data at the specified offset before Chris@16: /// returning. Chris@16: /** Chris@16: * This function is used to read a certain number of bytes of data from a Chris@16: * random access device at the specified offset. The call will block until one Chris@16: * of the following conditions is true: Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the SyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param b The basic_streambuf object into which the data will be read. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the read operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest read_some_at operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the read operation is complete. A non-zero Chris@16: * return value indicates the maximum number of bytes to be read on the next Chris@16: * call to the device's read_some_at function. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes read. If an error occurs, returns the total Chris@16: * number of bytes successfully transferred prior to the error. Chris@16: */ Chris@16: template Chris@16: std::size_t read_at(SyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, basic_streambuf& b, Chris@16: CompletionCondition completion_condition, boost::system::error_code& ec); Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /*@}*/ Chris@16: /** Chris@16: * @defgroup async_read_at boost::asio::async_read_at Chris@16: * Chris@16: * @brief Start an asynchronous operation to read a certain amount of data at Chris@16: * the specified offset. Chris@16: */ Chris@16: /*@{*/ Chris@16: Chris@16: /// Start an asynchronous operation to read a certain amount of data at the Chris@16: /// specified offset. Chris@16: /** Chris@16: * This function is used to asynchronously read a certain number of bytes of Chris@16: * data from a random access device at the specified offset. The function call Chris@16: * always returns immediately. The asynchronous operation will continue until Chris@16: * one of the following conditions is true: Chris@16: * Chris@16: * @li The supplied buffers are full. That is, the bytes transferred is equal to Chris@16: * the sum of the buffer sizes. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * async_read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the AsyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param buffers One or more buffers into which the data will be read. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to read from the Chris@16: * device. Although the buffers object may be copied as necessary, ownership of Chris@16: * the underlying memory blocks is retained by the caller, which must guarantee Chris@16: * that they remain valid until the handler is called. Chris@16: * Chris@16: * @param handler The handler to be called when the read operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * // Result of operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes copied into the buffers. If an error Chris@16: * // occurred, this will be the number of bytes successfully Chris@16: * // transferred prior to the error. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: * Chris@16: * @par Example Chris@16: * To read into a single data buffer use the @ref buffer function as follows: Chris@16: * @code Chris@16: * boost::asio::async_read_at(d, 42, boost::asio::buffer(data, size), handler); Chris@16: * @endcode Chris@16: * See the @ref buffer documentation for information on reading into multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::async_read_at( Chris@16: * d, 42, buffers, Chris@16: * boost::asio::transfer_all(), Chris@16: * handler); @endcode Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset, Chris@16: const MutableBufferSequence& buffers, Chris@16: BOOST_ASIO_MOVE_ARG(ReadHandler) handler); Chris@16: Chris@16: /// Start an asynchronous operation to read a certain amount of data at the Chris@16: /// specified offset. Chris@16: /** Chris@16: * This function is used to asynchronously read a certain number of bytes of Chris@16: * data from a random access device at the specified offset. The function call Chris@16: * always returns immediately. The asynchronous operation will continue until Chris@16: * one of the following conditions is true: Chris@16: * Chris@16: * @li The supplied buffers are full. That is, the bytes transferred is equal to Chris@16: * the sum of the buffer sizes. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the AsyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param buffers One or more buffers into which the data will be read. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to read from the Chris@16: * device. Although the buffers object may be copied as necessary, ownership of Chris@16: * the underlying memory blocks is retained by the caller, which must guarantee Chris@16: * that they remain valid until the handler is called. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the read operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest async_read_some_at operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the read operation is complete. A non-zero Chris@16: * return value indicates the maximum number of bytes to be read on the next Chris@16: * call to the device's async_read_some_at function. Chris@16: * Chris@16: * @param handler The handler to be called when the read operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * // Result of operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes copied into the buffers. If an error Chris@16: * // occurred, this will be the number of bytes successfully Chris@16: * // transferred prior to the error. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: * Chris@16: * @par Example Chris@16: * To read into a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::async_read_at(d, 42, Chris@16: * boost::asio::buffer(data, size), Chris@16: * boost::asio::transfer_at_least(32), Chris@16: * handler); @endcode Chris@16: * See the @ref buffer documentation for information on reading into multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_read_at(AsyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, const MutableBufferSequence& buffers, Chris@16: CompletionCondition completion_condition, Chris@16: BOOST_ASIO_MOVE_ARG(ReadHandler) handler); Chris@16: Chris@16: #if !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /// Start an asynchronous operation to read a certain amount of data at the Chris@16: /// specified offset. Chris@16: /** Chris@16: * This function is used to asynchronously read a certain number of bytes of Chris@16: * data from a random access device at the specified offset. The function call Chris@16: * always returns immediately. The asynchronous operation will continue until Chris@16: * one of the following conditions is true: Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * async_read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the AsyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param b A basic_streambuf object into which the data will be read. Ownership Chris@16: * of the streambuf is retained by the caller, which must guarantee that it Chris@16: * remains valid until the handler is called. Chris@16: * Chris@16: * @param handler The handler to be called when the read operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * // Result of operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes copied into the buffers. If an error Chris@16: * // occurred, this will be the number of bytes successfully Chris@16: * // transferred prior to the error. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::async_read_at( Chris@16: * d, 42, b, Chris@16: * boost::asio::transfer_all(), Chris@16: * handler); @endcode Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset, Chris@16: basic_streambuf& b, BOOST_ASIO_MOVE_ARG(ReadHandler) handler); Chris@16: Chris@16: /// Start an asynchronous operation to read a certain amount of data at the Chris@16: /// specified offset. Chris@16: /** Chris@16: * This function is used to asynchronously read a certain number of bytes of Chris@16: * data from a random access device at the specified offset. The function call Chris@16: * always returns immediately. The asynchronous operation will continue until Chris@16: * one of the following conditions is true: Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the device's Chris@16: * async_read_some_at function. Chris@16: * Chris@16: * @param d The device from which the data is to be read. The type must support Chris@16: * the AsyncRandomAccessReadDevice concept. Chris@16: * Chris@16: * @param offset The offset at which the data will be read. Chris@16: * Chris@16: * @param b A basic_streambuf object into which the data will be read. Ownership Chris@16: * of the streambuf is retained by the caller, which must guarantee that it Chris@16: * remains valid until the handler is called. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the read operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest async_read_some_at operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the read operation is complete. A non-zero Chris@16: * return value indicates the maximum number of bytes to be read on the next Chris@16: * call to the device's async_read_some_at function. Chris@16: * Chris@16: * @param handler The handler to be called when the read operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * // Result of operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes copied into the buffers. If an error Chris@16: * // occurred, this will be the number of bytes successfully Chris@16: * // transferred prior to the error. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_read_at(AsyncRandomAccessReadDevice& d, Chris@16: uint64_t offset, basic_streambuf& b, Chris@16: CompletionCondition completion_condition, Chris@16: BOOST_ASIO_MOVE_ARG(ReadHandler) handler); Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /*@}*/ Chris@16: Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_ASIO_READ_AT_HPP