Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:33:45

0001 //
0002 // read_at.hpp
0003 // ~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_READ_AT_HPP
0012 #define BOOST_ASIO_READ_AT_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <cstddef>
0020 #include <boost/asio/async_result.hpp>
0021 #include <boost/asio/completion_condition.hpp>
0022 #include <boost/asio/detail/cstdint.hpp>
0023 #include <boost/asio/error.hpp>
0024 
0025 #if !defined(BOOST_ASIO_NO_EXTENSIONS)
0026 # include <boost/asio/basic_streambuf_fwd.hpp>
0027 #endif // !defined(BOOST_ASIO_NO_EXTENSIONS)
0028 
0029 #include <boost/asio/detail/push_options.hpp>
0030 
0031 namespace boost {
0032 namespace asio {
0033 namespace detail {
0034 
0035 template <typename> class initiate_async_read_at;
0036 #if !defined(BOOST_ASIO_NO_IOSTREAM)
0037 template <typename> class initiate_async_read_at_streambuf;
0038 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
0039 
0040 } // namespace detail
0041 
0042 /**
0043  * @defgroup read_at boost::asio::read_at
0044  *
0045  * @brief The @c read_at function is a composed operation that reads a certain
0046  * amount of data at the specified offset before returning.
0047  */
0048 /*@{*/
0049 
0050 /// Attempt to read a certain amount of data at the specified offset before
0051 /// returning.
0052 /**
0053  * This function is used to read a certain number of bytes of data from a
0054  * random access device at the specified offset. The call will block until one
0055  * of the following conditions is true:
0056  *
0057  * @li The supplied buffers are full. That is, the bytes transferred is equal to
0058  * the sum of the buffer sizes.
0059  *
0060  * @li An error occurred.
0061  *
0062  * This operation is implemented in terms of zero or more calls to the device's
0063  * read_some_at function.
0064  *
0065  * @param d The device from which the data is to be read. The type must support
0066  * the SyncRandomAccessReadDevice concept.
0067  *
0068  * @param offset The offset at which the data will be read.
0069  *
0070  * @param buffers One or more buffers into which the data will be read. The sum
0071  * of the buffer sizes indicates the maximum number of bytes to read from the
0072  * device.
0073  *
0074  * @returns The number of bytes transferred.
0075  *
0076  * @throws boost::system::system_error Thrown on failure.
0077  *
0078  * @par Example
0079  * To read into a single data buffer use the @ref buffer function as follows:
0080  * @code boost::asio::read_at(d, 42, boost::asio::buffer(data, size)); @endcode
0081  * See the @ref buffer documentation for information on reading into multiple
0082  * buffers in one go, and how to use it with arrays, boost::array or
0083  * std::vector.
0084  *
0085  * @note This overload is equivalent to calling:
0086  * @code boost::asio::read_at(
0087  *     d, 42, buffers,
0088  *     boost::asio::transfer_all()); @endcode
0089  */
0090 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
0091 std::size_t read_at(SyncRandomAccessReadDevice& d,
0092     uint64_t offset, const MutableBufferSequence& buffers);
0093 
0094 /// Attempt to read a certain amount of data at the specified offset before
0095 /// returning.
0096 /**
0097  * This function is used to read a certain number of bytes of data from a
0098  * random access device at the specified offset. The call will block until one
0099  * of the following conditions is true:
0100  *
0101  * @li The supplied buffers are full. That is, the bytes transferred is equal to
0102  * the sum of the buffer sizes.
0103  *
0104  * @li An error occurred.
0105  *
0106  * This operation is implemented in terms of zero or more calls to the device's
0107  * read_some_at function.
0108  *
0109  * @param d The device from which the data is to be read. The type must support
0110  * the SyncRandomAccessReadDevice concept.
0111  *
0112  * @param offset The offset at which the data will be read.
0113  *
0114  * @param buffers One or more buffers into which the data will be read. The sum
0115  * of the buffer sizes indicates the maximum number of bytes to read from the
0116  * device.
0117  *
0118  * @param ec Set to indicate what error occurred, if any.
0119  *
0120  * @returns The number of bytes transferred.
0121  *
0122  * @par Example
0123  * To read into a single data buffer use the @ref buffer function as follows:
0124  * @code boost::asio::read_at(d, 42,
0125  *     boost::asio::buffer(data, size), ec); @endcode
0126  * See the @ref buffer documentation for information on reading into multiple
0127  * buffers in one go, and how to use it with arrays, boost::array or
0128  * std::vector.
0129  *
0130  * @note This overload is equivalent to calling:
0131  * @code boost::asio::read_at(
0132  *     d, 42, buffers,
0133  *     boost::asio::transfer_all(), ec); @endcode
0134  */
0135 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
0136 std::size_t read_at(SyncRandomAccessReadDevice& d,
0137     uint64_t offset, const MutableBufferSequence& buffers,
0138     boost::system::error_code& ec);
0139 
0140 /// Attempt to read a certain amount of data at the specified offset before
0141 /// returning.
0142 /**
0143  * This function is used to read a certain number of bytes of data from a
0144  * random access device at the specified offset. The call will block until one
0145  * of the following conditions is true:
0146  *
0147  * @li The supplied buffers are full. That is, the bytes transferred is equal to
0148  * the sum of the buffer sizes.
0149  *
0150  * @li The completion_condition function object returns 0.
0151  *
0152  * This operation is implemented in terms of zero or more calls to the device's
0153  * read_some_at function.
0154  *
0155  * @param d The device from which the data is to be read. The type must support
0156  * the SyncRandomAccessReadDevice concept.
0157  *
0158  * @param offset The offset at which the data will be read.
0159  *
0160  * @param buffers One or more buffers into which the data will be read. The sum
0161  * of the buffer sizes indicates the maximum number of bytes to read from the
0162  * device.
0163  *
0164  * @param completion_condition The function object to be called to determine
0165  * whether the read operation is complete. The signature of the function object
0166  * must be:
0167  * @code std::size_t completion_condition(
0168  *   // Result of latest read_some_at operation.
0169  *   const boost::system::error_code& error,
0170  *
0171  *   // Number of bytes transferred so far.
0172  *   std::size_t bytes_transferred
0173  * ); @endcode
0174  * A return value of 0 indicates that the read operation is complete. A non-zero
0175  * return value indicates the maximum number of bytes to be read on the next
0176  * call to the device's read_some_at function.
0177  *
0178  * @returns The number of bytes transferred.
0179  *
0180  * @throws boost::system::system_error Thrown on failure.
0181  *
0182  * @par Example
0183  * To read into a single data buffer use the @ref buffer function as follows:
0184  * @code boost::asio::read_at(d, 42, boost::asio::buffer(data, size),
0185  *     boost::asio::transfer_at_least(32)); @endcode
0186  * See the @ref buffer documentation for information on reading into multiple
0187  * buffers in one go, and how to use it with arrays, boost::array or
0188  * std::vector.
0189  */
0190 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
0191     typename CompletionCondition>
0192 std::size_t read_at(SyncRandomAccessReadDevice& d,
0193     uint64_t offset, const MutableBufferSequence& buffers,
0194     CompletionCondition completion_condition);
0195 
0196 /// Attempt to read a certain amount of data at the specified offset before
0197 /// returning.
0198 /**
0199  * This function is used to read a certain number of bytes of data from a
0200  * random access device at the specified offset. The call will block until one
0201  * of the following conditions is true:
0202  *
0203  * @li The supplied buffers are full. That is, the bytes transferred is equal to
0204  * the sum of the buffer sizes.
0205  *
0206  * @li The completion_condition function object returns 0.
0207  *
0208  * This operation is implemented in terms of zero or more calls to the device's
0209  * read_some_at function.
0210  *
0211  * @param d The device from which the data is to be read. The type must support
0212  * the SyncRandomAccessReadDevice concept.
0213  *
0214  * @param offset The offset at which the data will be read.
0215  *
0216  * @param buffers One or more buffers into which the data will be read. The sum
0217  * of the buffer sizes indicates the maximum number of bytes to read from the
0218  * device.
0219  *
0220  * @param completion_condition The function object to be called to determine
0221  * whether the read operation is complete. The signature of the function object
0222  * must be:
0223  * @code std::size_t completion_condition(
0224  *   // Result of latest read_some_at operation.
0225  *   const boost::system::error_code& error,
0226  *
0227  *   // Number of bytes transferred so far.
0228  *   std::size_t bytes_transferred
0229  * ); @endcode
0230  * A return value of 0 indicates that the read operation is complete. A non-zero
0231  * return value indicates the maximum number of bytes to be read on the next
0232  * call to the device's read_some_at function.
0233  *
0234  * @param ec Set to indicate what error occurred, if any.
0235  *
0236  * @returns The number of bytes read. If an error occurs, returns the total
0237  * number of bytes successfully transferred prior to the error.
0238  */
0239 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
0240     typename CompletionCondition>
0241 std::size_t read_at(SyncRandomAccessReadDevice& d,
0242     uint64_t offset, const MutableBufferSequence& buffers,
0243     CompletionCondition completion_condition, boost::system::error_code& ec);
0244 
0245 #if !defined(BOOST_ASIO_NO_EXTENSIONS)
0246 #if !defined(BOOST_ASIO_NO_IOSTREAM)
0247 
0248 /// Attempt to read a certain amount of data at the specified offset before
0249 /// returning.
0250 /**
0251  * This function is used to read a certain number of bytes of data from a
0252  * random access device at the specified offset. The call will block until one
0253  * of the following conditions is true:
0254  *
0255  * @li An error occurred.
0256  *
0257  * This operation is implemented in terms of zero or more calls to the device's
0258  * read_some_at function.
0259  *
0260  * @param d The device from which the data is to be read. The type must support
0261  * the SyncRandomAccessReadDevice concept.
0262  *
0263  * @param offset The offset at which the data will be read.
0264  *
0265  * @param b The basic_streambuf object into which the data will be read.
0266  *
0267  * @returns The number of bytes transferred.
0268  *
0269  * @throws boost::system::system_error Thrown on failure.
0270  *
0271  * @note This overload is equivalent to calling:
0272  * @code boost::asio::read_at(
0273  *     d, 42, b,
0274  *     boost::asio::transfer_all()); @endcode
0275  */
0276 template <typename SyncRandomAccessReadDevice, typename Allocator>
0277 std::size_t read_at(SyncRandomAccessReadDevice& d,
0278     uint64_t offset, basic_streambuf<Allocator>& b);
0279 
0280 /// Attempt to read a certain amount of data at the specified offset before
0281 /// returning.
0282 /**
0283  * This function is used to read a certain number of bytes of data from a
0284  * random access device at the specified offset. The call will block until one
0285  * of the following conditions is true:
0286  *
0287  * @li An error occurred.
0288  *
0289  * This operation is implemented in terms of zero or more calls to the device's
0290  * read_some_at function.
0291  *
0292  * @param d The device from which the data is to be read. The type must support
0293  * the SyncRandomAccessReadDevice concept.
0294  *
0295  * @param offset The offset at which the data will be read.
0296  *
0297  * @param b The basic_streambuf object into which the data will be read.
0298  *
0299  * @param ec Set to indicate what error occurred, if any.
0300  *
0301  * @returns The number of bytes transferred.
0302  *
0303  * @note This overload is equivalent to calling:
0304  * @code boost::asio::read_at(
0305  *     d, 42, b,
0306  *     boost::asio::transfer_all(), ec); @endcode
0307  */
0308 template <typename SyncRandomAccessReadDevice, typename Allocator>
0309 std::size_t read_at(SyncRandomAccessReadDevice& d,
0310     uint64_t offset, basic_streambuf<Allocator>& b,
0311     boost::system::error_code& ec);
0312 
0313 /// Attempt to read a certain amount of data at the specified offset before
0314 /// returning.
0315 /**
0316  * This function is used to read a certain number of bytes of data from a
0317  * random access device at the specified offset. The call will block until one
0318  * of the following conditions is true:
0319  *
0320  * @li The completion_condition function object returns 0.
0321  *
0322  * This operation is implemented in terms of zero or more calls to the device's
0323  * read_some_at function.
0324  *
0325  * @param d The device from which the data is to be read. The type must support
0326  * the SyncRandomAccessReadDevice concept.
0327  *
0328  * @param offset The offset at which the data will be read.
0329  *
0330  * @param b The basic_streambuf object into which the data will be read.
0331  *
0332  * @param completion_condition The function object to be called to determine
0333  * whether the read operation is complete. The signature of the function object
0334  * must be:
0335  * @code std::size_t completion_condition(
0336  *   // Result of latest read_some_at operation.
0337  *   const boost::system::error_code& error,
0338  *
0339  *   // Number of bytes transferred so far.
0340  *   std::size_t bytes_transferred
0341  * ); @endcode
0342  * A return value of 0 indicates that the read operation is complete. A non-zero
0343  * return value indicates the maximum number of bytes to be read on the next
0344  * call to the device's read_some_at function.
0345  *
0346  * @returns The number of bytes transferred.
0347  *
0348  * @throws boost::system::system_error Thrown on failure.
0349  */
0350 template <typename SyncRandomAccessReadDevice, typename Allocator,
0351     typename CompletionCondition>
0352 std::size_t read_at(SyncRandomAccessReadDevice& d,
0353     uint64_t offset, basic_streambuf<Allocator>& b,
0354     CompletionCondition completion_condition);
0355 
0356 /// Attempt to read a certain amount of data at the specified offset before
0357 /// returning.
0358 /**
0359  * This function is used to read a certain number of bytes of data from a
0360  * random access device at the specified offset. The call will block until one
0361  * of the following conditions is true:
0362  *
0363  * @li The completion_condition function object returns 0.
0364  *
0365  * This operation is implemented in terms of zero or more calls to the device's
0366  * read_some_at function.
0367  *
0368  * @param d The device from which the data is to be read. The type must support
0369  * the SyncRandomAccessReadDevice concept.
0370  *
0371  * @param offset The offset at which the data will be read.
0372  *
0373  * @param b The basic_streambuf object into which the data will be read.
0374  *
0375  * @param completion_condition The function object to be called to determine
0376  * whether the read operation is complete. The signature of the function object
0377  * must be:
0378  * @code std::size_t completion_condition(
0379  *   // Result of latest read_some_at operation.
0380  *   const boost::system::error_code& error,
0381  *
0382  *   // Number of bytes transferred so far.
0383  *   std::size_t bytes_transferred
0384  * ); @endcode
0385  * A return value of 0 indicates that the read operation is complete. A non-zero
0386  * return value indicates the maximum number of bytes to be read on the next
0387  * call to the device's read_some_at function.
0388  *
0389  * @param ec Set to indicate what error occurred, if any.
0390  *
0391  * @returns The number of bytes read. If an error occurs, returns the total
0392  * number of bytes successfully transferred prior to the error.
0393  */
0394 template <typename SyncRandomAccessReadDevice, typename Allocator,
0395     typename CompletionCondition>
0396 std::size_t read_at(SyncRandomAccessReadDevice& d,
0397     uint64_t offset, basic_streambuf<Allocator>& b,
0398     CompletionCondition completion_condition, boost::system::error_code& ec);
0399 
0400 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
0401 #endif // !defined(BOOST_ASIO_NO_EXTENSIONS)
0402 
0403 /*@}*/
0404 /**
0405  * @defgroup async_read_at boost::asio::async_read_at
0406  *
0407  * @brief The @c async_read_at function is a composed asynchronous operation
0408  * that reads a certain amount of data at the specified offset.
0409  */
0410 /*@{*/
0411 
0412 /// Start an asynchronous operation to read a certain amount of data at the
0413 /// specified offset.
0414 /**
0415  * This function is used to asynchronously read a certain number of bytes of
0416  * data from a random access device at the specified offset. It is an
0417  * initiating function for an @ref asynchronous_operation, and always returns
0418  * immediately. The asynchronous operation will continue until one of the
0419  * following conditions is true:
0420  *
0421  * @li The supplied buffers are full. That is, the bytes transferred is equal to
0422  * the sum of the buffer sizes.
0423  *
0424  * @li An error occurred.
0425  *
0426  * This operation is implemented in terms of zero or more calls to the device's
0427  * async_read_some_at function.
0428  *
0429  * @param d The device from which the data is to be read. The type must support
0430  * the AsyncRandomAccessReadDevice concept.
0431  *
0432  * @param offset The offset at which the data will be read.
0433  *
0434  * @param buffers One or more buffers into which the data will be read. The sum
0435  * of the buffer sizes indicates the maximum number of bytes to read from the
0436  * device. Although the buffers object may be copied as necessary, ownership of
0437  * the underlying memory blocks is retained by the caller, which must guarantee
0438  * that they remain valid until the completion handler is called.
0439  *
0440  * @param token The @ref completion_token that will be used to produce a
0441  * completion handler, which will be called when the read completes.
0442  * Potential completion tokens include @ref use_future, @ref use_awaitable,
0443  * @ref yield_context, or a function object with the correct completion
0444  * signature. The function signature of the completion handler must be:
0445  * @code void handler(
0446  *   // Result of operation.
0447  *   const boost::system::error_code& error,
0448  *
0449  *   // Number of bytes copied into the buffers. If an error
0450  *   // occurred, this will be the number of bytes successfully
0451  *   // transferred prior to the error.
0452  *   std::size_t bytes_transferred
0453  * ); @endcode
0454  * Regardless of whether the asynchronous operation completes immediately or
0455  * not, the completion handler will not be invoked from within this function.
0456  * On immediate completion, invocation of the handler will be performed in a
0457  * manner equivalent to using boost::asio::post().
0458  *
0459  * @par Completion Signature
0460  * @code void(boost::system::error_code, std::size_t) @endcode
0461  *
0462  * @par Example
0463  * To read into a single data buffer use the @ref buffer function as follows:
0464  * @code
0465  * boost::asio::async_read_at(d, 42, boost::asio::buffer(data, size), handler);
0466  * @endcode
0467  * See the @ref buffer documentation for information on reading into multiple
0468  * buffers in one go, and how to use it with arrays, boost::array or
0469  * std::vector.
0470  *
0471  * @note This overload is equivalent to calling:
0472  * @code boost::asio::async_read_at(
0473  *     d, 42, buffers,
0474  *     boost::asio::transfer_all(),
0475  *     handler); @endcode
0476  *
0477  * @par Per-Operation Cancellation
0478  * This asynchronous operation supports cancellation for the following
0479  * boost::asio::cancellation_type values:
0480  *
0481  * @li @c cancellation_type::terminal
0482  *
0483  * @li @c cancellation_type::partial
0484  *
0485  * if they are also supported by the @c AsyncRandomAccessReadDevice type's
0486  * async_read_some_at operation.
0487  */
0488 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
0489     BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
0490       std::size_t)) ReadToken = default_completion_token_t<
0491         typename AsyncRandomAccessReadDevice::executor_type>>
0492 auto async_read_at(AsyncRandomAccessReadDevice& d,
0493     uint64_t offset, const MutableBufferSequence& buffers,
0494     ReadToken&& token = default_completion_token_t<
0495       typename AsyncRandomAccessReadDevice::executor_type>())
0496   -> decltype(
0497     async_initiate<ReadToken,
0498       void (boost::system::error_code, std::size_t)>(
0499         declval<detail::initiate_async_read_at<AsyncRandomAccessReadDevice>>(),
0500         token, offset, buffers, transfer_all()));
0501 
0502 /// Start an asynchronous operation to read a certain amount of data at the
0503 /// specified offset.
0504 /**
0505  * This function is used to asynchronously read a certain number of bytes of
0506  * data from a random access device at the specified offset. It is an
0507  * initiating function for an @ref asynchronous_operation, and always returns
0508  * immediately. The asynchronous operation will continue until one of the
0509  * following conditions is true:
0510  *
0511  * @li The supplied buffers are full. That is, the bytes transferred is equal to
0512  * the sum of the buffer sizes.
0513  *
0514  * @li The completion_condition function object returns 0.
0515  *
0516  * @param d The device from which the data is to be read. The type must support
0517  * the AsyncRandomAccessReadDevice concept.
0518  *
0519  * @param offset The offset at which the data will be read.
0520  *
0521  * @param buffers One or more buffers into which the data will be read. The sum
0522  * of the buffer sizes indicates the maximum number of bytes to read from the
0523  * device. Although the buffers object may be copied as necessary, ownership of
0524  * the underlying memory blocks is retained by the caller, which must guarantee
0525  * that they remain valid until the completion handler is called.
0526  *
0527  * @param completion_condition The function object to be called to determine
0528  * whether the read operation is complete. The signature of the function object
0529  * must be:
0530  * @code std::size_t completion_condition(
0531  *   // Result of latest async_read_some_at operation.
0532  *   const boost::system::error_code& error,
0533  *
0534  *   // Number of bytes transferred so far.
0535  *   std::size_t bytes_transferred
0536  * ); @endcode
0537  * A return value of 0 indicates that the read operation is complete. A non-zero
0538  * return value indicates the maximum number of bytes to be read on the next
0539  * call to the device's async_read_some_at function.
0540  *
0541  * @param token The @ref completion_token that will be used to produce a
0542  * completion handler, which will be called when the read completes.
0543  * Potential completion tokens include @ref use_future, @ref use_awaitable,
0544  * @ref yield_context, or a function object with the correct completion
0545  * signature. The function signature of the completion handler must be:
0546  * @code void handler(
0547  *   // Result of operation.
0548  *   const boost::system::error_code& error,
0549  *
0550  *   // Number of bytes copied into the buffers. If an error
0551  *   // occurred, this will be the number of bytes successfully
0552  *   // transferred prior to the error.
0553  *   std::size_t bytes_transferred
0554  * ); @endcode
0555  * Regardless of whether the asynchronous operation completes immediately or
0556  * not, the completion handler will not be invoked from within this function.
0557  * On immediate completion, invocation of the handler will be performed in a
0558  * manner equivalent to using boost::asio::post().
0559  *
0560  * @par Completion Signature
0561  * @code void(boost::system::error_code, std::size_t) @endcode
0562  *
0563  * @par Example
0564  * To read into a single data buffer use the @ref buffer function as follows:
0565  * @code boost::asio::async_read_at(d, 42,
0566  *     boost::asio::buffer(data, size),
0567  *     boost::asio::transfer_at_least(32),
0568  *     handler); @endcode
0569  * See the @ref buffer documentation for information on reading into multiple
0570  * buffers in one go, and how to use it with arrays, boost::array or
0571  * std::vector.
0572  *
0573  * @par Per-Operation Cancellation
0574  * This asynchronous operation supports cancellation for the following
0575  * boost::asio::cancellation_type values:
0576  *
0577  * @li @c cancellation_type::terminal
0578  *
0579  * @li @c cancellation_type::partial
0580  *
0581  * if they are also supported by the @c AsyncRandomAccessReadDevice type's
0582  * async_read_some_at operation.
0583  */
0584 template <typename AsyncRandomAccessReadDevice,
0585     typename MutableBufferSequence, typename CompletionCondition,
0586     BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
0587       std::size_t)) ReadToken = default_completion_token_t<
0588         typename AsyncRandomAccessReadDevice::executor_type>>
0589 auto async_read_at(AsyncRandomAccessReadDevice& d,
0590     uint64_t offset, const MutableBufferSequence& buffers,
0591     CompletionCondition completion_condition,
0592     ReadToken&& token = default_completion_token_t<
0593       typename AsyncRandomAccessReadDevice::executor_type>())
0594   -> decltype(
0595     async_initiate<ReadToken,
0596       void (boost::system::error_code, std::size_t)>(
0597         declval<detail::initiate_async_read_at<AsyncRandomAccessReadDevice>>(),
0598         token, offset, buffers,
0599         static_cast<CompletionCondition&&>(completion_condition)));
0600 
0601 #if !defined(BOOST_ASIO_NO_EXTENSIONS)
0602 #if !defined(BOOST_ASIO_NO_IOSTREAM)
0603 
0604 /// Start an asynchronous operation to read a certain amount of data at the
0605 /// specified offset.
0606 /**
0607  * This function is used to asynchronously read a certain number of bytes of
0608  * data from a random access device at the specified offset. It is an
0609  * initiating function for an @ref asynchronous_operation, and always returns
0610  * immediately. The asynchronous operation will continue until one of the
0611  * following conditions is true:
0612  *
0613  * @li An error occurred.
0614  *
0615  * This operation is implemented in terms of zero or more calls to the device's
0616  * async_read_some_at function.
0617  *
0618  * @param d The device from which the data is to be read. The type must support
0619  * the AsyncRandomAccessReadDevice concept.
0620  *
0621  * @param offset The offset at which the data will be read.
0622  *
0623  * @param b A basic_streambuf object into which the data will be read. Ownership
0624  * of the streambuf is retained by the caller, which must guarantee that it
0625  * remains valid until the completion handler is called.
0626  *
0627  * @param token The @ref completion_token that will be used to produce a
0628  * completion handler, which will be called when the read completes.
0629  * Potential completion tokens include @ref use_future, @ref use_awaitable,
0630  * @ref yield_context, or a function object with the correct completion
0631  * signature. The function signature of the completion handler must be:
0632  * @code void handler(
0633  *   // Result of operation.
0634  *   const boost::system::error_code& error,
0635  *
0636  *   // Number of bytes copied into the buffers. If an error
0637  *   // occurred, this will be the number of bytes successfully
0638  *   // transferred prior to the error.
0639  *   std::size_t bytes_transferred
0640  * ); @endcode
0641  * Regardless of whether the asynchronous operation completes immediately or
0642  * not, the completion handler will not be invoked from within this function.
0643  * On immediate completion, invocation of the handler will be performed in a
0644  * manner equivalent to using boost::asio::post().
0645  *
0646  * @par Completion Signature
0647  * @code void(boost::system::error_code, std::size_t) @endcode
0648  *
0649  * @note This overload is equivalent to calling:
0650  * @code boost::asio::async_read_at(
0651  *     d, 42, b,
0652  *     boost::asio::transfer_all(),
0653  *     handler); @endcode
0654  *
0655  * @par Per-Operation Cancellation
0656  * This asynchronous operation supports cancellation for the following
0657  * boost::asio::cancellation_type values:
0658  *
0659  * @li @c cancellation_type::terminal
0660  *
0661  * @li @c cancellation_type::partial
0662  *
0663  * if they are also supported by the @c AsyncRandomAccessReadDevice type's
0664  * async_read_some_at operation.
0665  */
0666 template <typename AsyncRandomAccessReadDevice, typename Allocator,
0667     BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
0668       std::size_t)) ReadToken = default_completion_token_t<
0669         typename AsyncRandomAccessReadDevice::executor_type>>
0670 auto async_read_at(AsyncRandomAccessReadDevice& d,
0671     uint64_t offset, basic_streambuf<Allocator>& b,
0672     ReadToken&& token = default_completion_token_t<
0673       typename AsyncRandomAccessReadDevice::executor_type>())
0674   -> decltype(
0675     async_initiate<ReadToken,
0676       void (boost::system::error_code, std::size_t)>(
0677         declval<detail::initiate_async_read_at_streambuf<
0678           AsyncRandomAccessReadDevice>>(),
0679         token, offset, &b, transfer_all()));
0680 
0681 /// Start an asynchronous operation to read a certain amount of data at the
0682 /// specified offset.
0683 /**
0684  * This function is used to asynchronously read a certain number of bytes of
0685  * data from a random access device at the specified offset. It is an
0686  * initiating function for an @ref asynchronous_operation, and always returns
0687  * immediately. The asynchronous operation will continue until one of the
0688  * following conditions is true:
0689  *
0690  * @li The completion_condition function object returns 0.
0691  *
0692  * This operation is implemented in terms of zero or more calls to the device's
0693  * async_read_some_at function.
0694  *
0695  * @param d The device from which the data is to be read. The type must support
0696  * the AsyncRandomAccessReadDevice concept.
0697  *
0698  * @param offset The offset at which the data will be read.
0699  *
0700  * @param b A basic_streambuf object into which the data will be read. Ownership
0701  * of the streambuf is retained by the caller, which must guarantee that it
0702  * remains valid until the completion handler is called.
0703  *
0704  * @param completion_condition The function object to be called to determine
0705  * whether the read operation is complete. The signature of the function object
0706  * must be:
0707  * @code std::size_t completion_condition(
0708  *   // Result of latest async_read_some_at operation.
0709  *   const boost::system::error_code& error,
0710  *
0711  *   // Number of bytes transferred so far.
0712  *   std::size_t bytes_transferred
0713  * ); @endcode
0714  * A return value of 0 indicates that the read operation is complete. A non-zero
0715  * return value indicates the maximum number of bytes to be read on the next
0716  * call to the device's async_read_some_at function.
0717  *
0718  * @param token The @ref completion_token that will be used to produce a
0719  * completion handler, which will be called when the read completes.
0720  * Potential completion tokens include @ref use_future, @ref use_awaitable,
0721  * @ref yield_context, or a function object with the correct completion
0722  * signature. The function signature of the completion handler must be:
0723  * @code void handler(
0724  *   // Result of operation.
0725  *   const boost::system::error_code& error,
0726  *
0727  *   // Number of bytes copied into the buffers. If an error
0728  *   // occurred, this will be the number of bytes successfully
0729  *   // transferred prior to the error.
0730  *   std::size_t bytes_transferred
0731  * ); @endcode
0732  * Regardless of whether the asynchronous operation completes immediately or
0733  * not, the completion handler will not be invoked from within this function.
0734  * On immediate completion, invocation of the handler will be performed in a
0735  * manner equivalent to using boost::asio::post().
0736  *
0737  * @par Completion Signature
0738  * @code void(boost::system::error_code, std::size_t) @endcode
0739  *
0740  * @par Per-Operation Cancellation
0741  * This asynchronous operation supports cancellation for the following
0742  * boost::asio::cancellation_type values:
0743  *
0744  * @li @c cancellation_type::terminal
0745  *
0746  * @li @c cancellation_type::partial
0747  *
0748  * if they are also supported by the @c AsyncRandomAccessReadDevice type's
0749  * async_read_some_at operation.
0750  */
0751 template <typename AsyncRandomAccessReadDevice,
0752     typename Allocator, typename CompletionCondition,
0753     BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
0754       std::size_t)) ReadToken = default_completion_token_t<
0755         typename AsyncRandomAccessReadDevice::executor_type>>
0756 auto async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
0757     basic_streambuf<Allocator>& b, CompletionCondition completion_condition,
0758     ReadToken&& token = default_completion_token_t<
0759       typename AsyncRandomAccessReadDevice::executor_type>())
0760   -> decltype(
0761     async_initiate<ReadToken,
0762       void (boost::system::error_code, std::size_t)>(
0763         declval<detail::initiate_async_read_at_streambuf<
0764           AsyncRandomAccessReadDevice>>(),
0765         token, offset, &b,
0766         static_cast<CompletionCondition&&>(completion_condition)));
0767 
0768 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
0769 #endif // !defined(BOOST_ASIO_NO_EXTENSIONS)
0770 
0771 /*@}*/
0772 
0773 } // namespace asio
0774 } // namespace boost
0775 
0776 #include <boost/asio/detail/pop_options.hpp>
0777 
0778 #include <boost/asio/impl/read_at.hpp>
0779 
0780 #endif // BOOST_ASIO_READ_AT_HPP