Chris@16
|
1 //
|
Chris@16
|
2 // read_at.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_READ_AT_HPP
|
Chris@16
|
12 #define BOOST_ASIO_READ_AT_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/detail/config.hpp>
|
Chris@16
|
19 #include <cstddef>
|
Chris@16
|
20 #include <boost/asio/async_result.hpp>
|
Chris@16
|
21 #include <boost/asio/basic_streambuf_fwd.hpp>
|
Chris@16
|
22 #include <boost/asio/detail/cstdint.hpp>
|
Chris@16
|
23 #include <boost/asio/error.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost {
|
Chris@16
|
28 namespace asio {
|
Chris@16
|
29
|
Chris@16
|
30 /**
|
Chris@16
|
31 * @defgroup read_at boost::asio::read_at
|
Chris@16
|
32 *
|
Chris@16
|
33 * @brief Attempt to read a certain amount of data at the specified offset
|
Chris@16
|
34 * before returning.
|
Chris@16
|
35 */
|
Chris@16
|
36 /*@{*/
|
Chris@16
|
37
|
Chris@16
|
38 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
39 /// returning.
|
Chris@16
|
40 /**
|
Chris@16
|
41 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
42 * random access device at the specified offset. The call will block until one
|
Chris@16
|
43 * of the following conditions is true:
|
Chris@16
|
44 *
|
Chris@16
|
45 * @li The supplied buffers are full. That is, the bytes transferred is equal to
|
Chris@16
|
46 * the sum of the buffer sizes.
|
Chris@16
|
47 *
|
Chris@16
|
48 * @li An error occurred.
|
Chris@16
|
49 *
|
Chris@16
|
50 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
51 * read_some_at function.
|
Chris@16
|
52 *
|
Chris@16
|
53 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
54 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
55 *
|
Chris@16
|
56 * @param offset The offset at which the data will be read.
|
Chris@16
|
57 *
|
Chris@16
|
58 * @param buffers One or more buffers into which the data will be read. The sum
|
Chris@16
|
59 * of the buffer sizes indicates the maximum number of bytes to read from the
|
Chris@16
|
60 * device.
|
Chris@16
|
61 *
|
Chris@16
|
62 * @returns The number of bytes transferred.
|
Chris@16
|
63 *
|
Chris@16
|
64 * @throws boost::system::system_error Thrown on failure.
|
Chris@16
|
65 *
|
Chris@16
|
66 * @par Example
|
Chris@16
|
67 * To read into a single data buffer use the @ref buffer function as follows:
|
Chris@16
|
68 * @code boost::asio::read_at(d, 42, boost::asio::buffer(data, size)); @endcode
|
Chris@16
|
69 * See the @ref buffer documentation for information on reading into multiple
|
Chris@16
|
70 * buffers in one go, and how to use it with arrays, boost::array or
|
Chris@16
|
71 * std::vector.
|
Chris@16
|
72 *
|
Chris@16
|
73 * @note This overload is equivalent to calling:
|
Chris@16
|
74 * @code boost::asio::read_at(
|
Chris@16
|
75 * d, 42, buffers,
|
Chris@16
|
76 * boost::asio::transfer_all()); @endcode
|
Chris@16
|
77 */
|
Chris@16
|
78 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
|
Chris@16
|
79 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
80 uint64_t offset, const MutableBufferSequence& buffers);
|
Chris@16
|
81
|
Chris@16
|
82 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
83 /// returning.
|
Chris@16
|
84 /**
|
Chris@16
|
85 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
86 * random access device at the specified offset. The call will block until one
|
Chris@16
|
87 * of the following conditions is true:
|
Chris@16
|
88 *
|
Chris@16
|
89 * @li The supplied buffers are full. That is, the bytes transferred is equal to
|
Chris@16
|
90 * the sum of the buffer sizes.
|
Chris@16
|
91 *
|
Chris@16
|
92 * @li An error occurred.
|
Chris@16
|
93 *
|
Chris@16
|
94 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
95 * read_some_at function.
|
Chris@16
|
96 *
|
Chris@16
|
97 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
98 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
99 *
|
Chris@16
|
100 * @param offset The offset at which the data will be read.
|
Chris@16
|
101 *
|
Chris@16
|
102 * @param buffers One or more buffers into which the data will be read. The sum
|
Chris@16
|
103 * of the buffer sizes indicates the maximum number of bytes to read from the
|
Chris@16
|
104 * device.
|
Chris@16
|
105 *
|
Chris@16
|
106 * @param ec Set to indicate what error occurred, if any.
|
Chris@16
|
107 *
|
Chris@16
|
108 * @returns The number of bytes transferred.
|
Chris@16
|
109 *
|
Chris@16
|
110 * @par Example
|
Chris@16
|
111 * To read into a single data buffer use the @ref buffer function as follows:
|
Chris@16
|
112 * @code boost::asio::read_at(d, 42,
|
Chris@16
|
113 * boost::asio::buffer(data, size), ec); @endcode
|
Chris@16
|
114 * See the @ref buffer documentation for information on reading into multiple
|
Chris@16
|
115 * buffers in one go, and how to use it with arrays, boost::array or
|
Chris@16
|
116 * std::vector.
|
Chris@16
|
117 *
|
Chris@16
|
118 * @note This overload is equivalent to calling:
|
Chris@16
|
119 * @code boost::asio::read_at(
|
Chris@16
|
120 * d, 42, buffers,
|
Chris@16
|
121 * boost::asio::transfer_all(), ec); @endcode
|
Chris@16
|
122 */
|
Chris@16
|
123 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
|
Chris@16
|
124 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
125 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
126 boost::system::error_code& ec);
|
Chris@16
|
127
|
Chris@16
|
128 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
129 /// returning.
|
Chris@16
|
130 /**
|
Chris@16
|
131 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
132 * random access device at the specified offset. The call will block until one
|
Chris@16
|
133 * of the following conditions is true:
|
Chris@16
|
134 *
|
Chris@16
|
135 * @li The supplied buffers are full. That is, the bytes transferred is equal to
|
Chris@16
|
136 * the sum of the buffer sizes.
|
Chris@16
|
137 *
|
Chris@16
|
138 * @li The completion_condition function object returns 0.
|
Chris@16
|
139 *
|
Chris@16
|
140 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
141 * read_some_at function.
|
Chris@16
|
142 *
|
Chris@16
|
143 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
144 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
145 *
|
Chris@16
|
146 * @param offset The offset at which the data will be read.
|
Chris@16
|
147 *
|
Chris@16
|
148 * @param buffers One or more buffers into which the data will be read. The sum
|
Chris@16
|
149 * of the buffer sizes indicates the maximum number of bytes to read from the
|
Chris@16
|
150 * device.
|
Chris@16
|
151 *
|
Chris@16
|
152 * @param completion_condition The function object to be called to determine
|
Chris@16
|
153 * whether the read operation is complete. The signature of the function object
|
Chris@16
|
154 * must be:
|
Chris@16
|
155 * @code std::size_t completion_condition(
|
Chris@16
|
156 * // Result of latest read_some_at operation.
|
Chris@16
|
157 * const boost::system::error_code& error,
|
Chris@16
|
158 *
|
Chris@16
|
159 * // Number of bytes transferred so far.
|
Chris@16
|
160 * std::size_t bytes_transferred
|
Chris@16
|
161 * ); @endcode
|
Chris@16
|
162 * A return value of 0 indicates that the read operation is complete. A non-zero
|
Chris@16
|
163 * return value indicates the maximum number of bytes to be read on the next
|
Chris@16
|
164 * call to the device's read_some_at function.
|
Chris@16
|
165 *
|
Chris@16
|
166 * @returns The number of bytes transferred.
|
Chris@16
|
167 *
|
Chris@16
|
168 * @throws boost::system::system_error Thrown on failure.
|
Chris@16
|
169 *
|
Chris@16
|
170 * @par Example
|
Chris@16
|
171 * To read into a single data buffer use the @ref buffer function as follows:
|
Chris@16
|
172 * @code boost::asio::read_at(d, 42, boost::asio::buffer(data, size),
|
Chris@16
|
173 * boost::asio::transfer_at_least(32)); @endcode
|
Chris@16
|
174 * See the @ref buffer documentation for information on reading into multiple
|
Chris@16
|
175 * buffers in one go, and how to use it with arrays, boost::array or
|
Chris@16
|
176 * std::vector.
|
Chris@16
|
177 */
|
Chris@16
|
178 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
179 typename CompletionCondition>
|
Chris@16
|
180 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
181 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
182 CompletionCondition completion_condition);
|
Chris@16
|
183
|
Chris@16
|
184 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
185 /// returning.
|
Chris@16
|
186 /**
|
Chris@16
|
187 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
188 * random access device at the specified offset. The call will block until one
|
Chris@16
|
189 * of the following conditions is true:
|
Chris@16
|
190 *
|
Chris@16
|
191 * @li The supplied buffers are full. That is, the bytes transferred is equal to
|
Chris@16
|
192 * the sum of the buffer sizes.
|
Chris@16
|
193 *
|
Chris@16
|
194 * @li The completion_condition function object returns 0.
|
Chris@16
|
195 *
|
Chris@16
|
196 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
197 * read_some_at function.
|
Chris@16
|
198 *
|
Chris@16
|
199 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
200 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
201 *
|
Chris@16
|
202 * @param offset The offset at which the data will be read.
|
Chris@16
|
203 *
|
Chris@16
|
204 * @param buffers One or more buffers into which the data will be read. The sum
|
Chris@16
|
205 * of the buffer sizes indicates the maximum number of bytes to read from the
|
Chris@16
|
206 * device.
|
Chris@16
|
207 *
|
Chris@16
|
208 * @param completion_condition The function object to be called to determine
|
Chris@16
|
209 * whether the read operation is complete. The signature of the function object
|
Chris@16
|
210 * must be:
|
Chris@16
|
211 * @code std::size_t completion_condition(
|
Chris@16
|
212 * // Result of latest read_some_at operation.
|
Chris@16
|
213 * const boost::system::error_code& error,
|
Chris@16
|
214 *
|
Chris@16
|
215 * // Number of bytes transferred so far.
|
Chris@16
|
216 * std::size_t bytes_transferred
|
Chris@16
|
217 * ); @endcode
|
Chris@16
|
218 * A return value of 0 indicates that the read operation is complete. A non-zero
|
Chris@16
|
219 * return value indicates the maximum number of bytes to be read on the next
|
Chris@16
|
220 * call to the device's read_some_at function.
|
Chris@16
|
221 *
|
Chris@16
|
222 * @param ec Set to indicate what error occurred, if any.
|
Chris@16
|
223 *
|
Chris@16
|
224 * @returns The number of bytes read. If an error occurs, returns the total
|
Chris@16
|
225 * number of bytes successfully transferred prior to the error.
|
Chris@16
|
226 */
|
Chris@16
|
227 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
228 typename CompletionCondition>
|
Chris@16
|
229 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
230 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
231 CompletionCondition completion_condition, boost::system::error_code& ec);
|
Chris@16
|
232
|
Chris@16
|
233 #if !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
234
|
Chris@16
|
235 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
236 /// returning.
|
Chris@16
|
237 /**
|
Chris@16
|
238 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
239 * random access device at the specified offset. The call will block until one
|
Chris@16
|
240 * of the following conditions is true:
|
Chris@16
|
241 *
|
Chris@16
|
242 * @li An error occurred.
|
Chris@16
|
243 *
|
Chris@16
|
244 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
245 * read_some_at function.
|
Chris@16
|
246 *
|
Chris@16
|
247 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
248 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
249 *
|
Chris@16
|
250 * @param offset The offset at which the data will be read.
|
Chris@16
|
251 *
|
Chris@16
|
252 * @param b The basic_streambuf object into which the data will be read.
|
Chris@16
|
253 *
|
Chris@16
|
254 * @returns The number of bytes transferred.
|
Chris@16
|
255 *
|
Chris@16
|
256 * @throws boost::system::system_error Thrown on failure.
|
Chris@16
|
257 *
|
Chris@16
|
258 * @note This overload is equivalent to calling:
|
Chris@16
|
259 * @code boost::asio::read_at(
|
Chris@16
|
260 * d, 42, b,
|
Chris@16
|
261 * boost::asio::transfer_all()); @endcode
|
Chris@16
|
262 */
|
Chris@16
|
263 template <typename SyncRandomAccessReadDevice, typename Allocator>
|
Chris@16
|
264 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
265 uint64_t offset, basic_streambuf<Allocator>& b);
|
Chris@16
|
266
|
Chris@16
|
267 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
268 /// returning.
|
Chris@16
|
269 /**
|
Chris@16
|
270 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
271 * random access device at the specified offset. The call will block until one
|
Chris@16
|
272 * of the following conditions is true:
|
Chris@16
|
273 *
|
Chris@16
|
274 * @li An error occurred.
|
Chris@16
|
275 *
|
Chris@16
|
276 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
277 * read_some_at function.
|
Chris@16
|
278 *
|
Chris@16
|
279 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
280 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
281 *
|
Chris@16
|
282 * @param offset The offset at which the data will be read.
|
Chris@16
|
283 *
|
Chris@16
|
284 * @param b The basic_streambuf object into which the data will be read.
|
Chris@16
|
285 *
|
Chris@16
|
286 * @param ec Set to indicate what error occurred, if any.
|
Chris@16
|
287 *
|
Chris@16
|
288 * @returns The number of bytes transferred.
|
Chris@16
|
289 *
|
Chris@16
|
290 * @note This overload is equivalent to calling:
|
Chris@16
|
291 * @code boost::asio::read_at(
|
Chris@16
|
292 * d, 42, b,
|
Chris@16
|
293 * boost::asio::transfer_all(), ec); @endcode
|
Chris@16
|
294 */
|
Chris@16
|
295 template <typename SyncRandomAccessReadDevice, typename Allocator>
|
Chris@16
|
296 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
297 uint64_t offset, basic_streambuf<Allocator>& b,
|
Chris@16
|
298 boost::system::error_code& ec);
|
Chris@16
|
299
|
Chris@16
|
300 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
301 /// returning.
|
Chris@16
|
302 /**
|
Chris@16
|
303 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
304 * random access device at the specified offset. The call will block until one
|
Chris@16
|
305 * of the following conditions is true:
|
Chris@16
|
306 *
|
Chris@16
|
307 * @li The completion_condition function object returns 0.
|
Chris@16
|
308 *
|
Chris@16
|
309 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
310 * read_some_at function.
|
Chris@16
|
311 *
|
Chris@16
|
312 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
313 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
314 *
|
Chris@16
|
315 * @param offset The offset at which the data will be read.
|
Chris@16
|
316 *
|
Chris@16
|
317 * @param b The basic_streambuf object into which the data will be read.
|
Chris@16
|
318 *
|
Chris@16
|
319 * @param completion_condition The function object to be called to determine
|
Chris@16
|
320 * whether the read operation is complete. The signature of the function object
|
Chris@16
|
321 * must be:
|
Chris@16
|
322 * @code std::size_t completion_condition(
|
Chris@16
|
323 * // Result of latest read_some_at operation.
|
Chris@16
|
324 * const boost::system::error_code& error,
|
Chris@16
|
325 *
|
Chris@16
|
326 * // Number of bytes transferred so far.
|
Chris@16
|
327 * std::size_t bytes_transferred
|
Chris@16
|
328 * ); @endcode
|
Chris@16
|
329 * A return value of 0 indicates that the read operation is complete. A non-zero
|
Chris@16
|
330 * return value indicates the maximum number of bytes to be read on the next
|
Chris@16
|
331 * call to the device's read_some_at function.
|
Chris@16
|
332 *
|
Chris@16
|
333 * @returns The number of bytes transferred.
|
Chris@16
|
334 *
|
Chris@16
|
335 * @throws boost::system::system_error Thrown on failure.
|
Chris@16
|
336 */
|
Chris@16
|
337 template <typename SyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
338 typename CompletionCondition>
|
Chris@16
|
339 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
340 uint64_t offset, basic_streambuf<Allocator>& b,
|
Chris@16
|
341 CompletionCondition completion_condition);
|
Chris@16
|
342
|
Chris@16
|
343 /// Attempt to read a certain amount of data at the specified offset before
|
Chris@16
|
344 /// returning.
|
Chris@16
|
345 /**
|
Chris@16
|
346 * This function is used to read a certain number of bytes of data from a
|
Chris@16
|
347 * random access device at the specified offset. The call will block until one
|
Chris@16
|
348 * of the following conditions is true:
|
Chris@16
|
349 *
|
Chris@16
|
350 * @li The completion_condition function object returns 0.
|
Chris@16
|
351 *
|
Chris@16
|
352 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
353 * read_some_at function.
|
Chris@16
|
354 *
|
Chris@16
|
355 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
356 * the SyncRandomAccessReadDevice concept.
|
Chris@16
|
357 *
|
Chris@16
|
358 * @param offset The offset at which the data will be read.
|
Chris@16
|
359 *
|
Chris@16
|
360 * @param b The basic_streambuf object into which the data will be read.
|
Chris@16
|
361 *
|
Chris@16
|
362 * @param completion_condition The function object to be called to determine
|
Chris@16
|
363 * whether the read operation is complete. The signature of the function object
|
Chris@16
|
364 * must be:
|
Chris@16
|
365 * @code std::size_t completion_condition(
|
Chris@16
|
366 * // Result of latest read_some_at operation.
|
Chris@16
|
367 * const boost::system::error_code& error,
|
Chris@16
|
368 *
|
Chris@16
|
369 * // Number of bytes transferred so far.
|
Chris@16
|
370 * std::size_t bytes_transferred
|
Chris@16
|
371 * ); @endcode
|
Chris@16
|
372 * A return value of 0 indicates that the read operation is complete. A non-zero
|
Chris@16
|
373 * return value indicates the maximum number of bytes to be read on the next
|
Chris@16
|
374 * call to the device's read_some_at function.
|
Chris@16
|
375 *
|
Chris@16
|
376 * @param ec Set to indicate what error occurred, if any.
|
Chris@16
|
377 *
|
Chris@16
|
378 * @returns The number of bytes read. If an error occurs, returns the total
|
Chris@16
|
379 * number of bytes successfully transferred prior to the error.
|
Chris@16
|
380 */
|
Chris@16
|
381 template <typename SyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
382 typename CompletionCondition>
|
Chris@16
|
383 std::size_t read_at(SyncRandomAccessReadDevice& d,
|
Chris@16
|
384 uint64_t offset, basic_streambuf<Allocator>& b,
|
Chris@16
|
385 CompletionCondition completion_condition, boost::system::error_code& ec);
|
Chris@16
|
386
|
Chris@16
|
387 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
388
|
Chris@16
|
389 /*@}*/
|
Chris@16
|
390 /**
|
Chris@16
|
391 * @defgroup async_read_at boost::asio::async_read_at
|
Chris@16
|
392 *
|
Chris@16
|
393 * @brief Start an asynchronous operation to read a certain amount of data at
|
Chris@16
|
394 * the specified offset.
|
Chris@16
|
395 */
|
Chris@16
|
396 /*@{*/
|
Chris@16
|
397
|
Chris@16
|
398 /// Start an asynchronous operation to read a certain amount of data at the
|
Chris@16
|
399 /// specified offset.
|
Chris@16
|
400 /**
|
Chris@16
|
401 * This function is used to asynchronously read a certain number of bytes of
|
Chris@16
|
402 * data from a random access device at the specified offset. The function call
|
Chris@16
|
403 * always returns immediately. The asynchronous operation will continue until
|
Chris@16
|
404 * one of the following conditions is true:
|
Chris@16
|
405 *
|
Chris@16
|
406 * @li The supplied buffers are full. That is, the bytes transferred is equal to
|
Chris@16
|
407 * the sum of the buffer sizes.
|
Chris@16
|
408 *
|
Chris@16
|
409 * @li An error occurred.
|
Chris@16
|
410 *
|
Chris@16
|
411 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
412 * async_read_some_at function.
|
Chris@16
|
413 *
|
Chris@16
|
414 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
415 * the AsyncRandomAccessReadDevice concept.
|
Chris@16
|
416 *
|
Chris@16
|
417 * @param offset The offset at which the data will be read.
|
Chris@16
|
418 *
|
Chris@16
|
419 * @param buffers One or more buffers into which the data will be read. The sum
|
Chris@16
|
420 * of the buffer sizes indicates the maximum number of bytes to read from the
|
Chris@16
|
421 * device. Although the buffers object may be copied as necessary, ownership of
|
Chris@16
|
422 * the underlying memory blocks is retained by the caller, which must guarantee
|
Chris@16
|
423 * that they remain valid until the handler is called.
|
Chris@16
|
424 *
|
Chris@16
|
425 * @param handler The handler to be called when the read operation completes.
|
Chris@16
|
426 * Copies will be made of the handler as required. The function signature of the
|
Chris@16
|
427 * handler must be:
|
Chris@16
|
428 * @code void handler(
|
Chris@16
|
429 * // Result of operation.
|
Chris@16
|
430 * const boost::system::error_code& error,
|
Chris@16
|
431 *
|
Chris@16
|
432 * // Number of bytes copied into the buffers. If an error
|
Chris@16
|
433 * // occurred, this will be the number of bytes successfully
|
Chris@16
|
434 * // transferred prior to the error.
|
Chris@16
|
435 * std::size_t bytes_transferred
|
Chris@16
|
436 * ); @endcode
|
Chris@16
|
437 * Regardless of whether the asynchronous operation completes immediately or
|
Chris@16
|
438 * not, the handler will not be invoked from within this function. Invocation of
|
Chris@16
|
439 * the handler will be performed in a manner equivalent to using
|
Chris@16
|
440 * boost::asio::io_service::post().
|
Chris@16
|
441 *
|
Chris@16
|
442 * @par Example
|
Chris@16
|
443 * To read into a single data buffer use the @ref buffer function as follows:
|
Chris@16
|
444 * @code
|
Chris@16
|
445 * boost::asio::async_read_at(d, 42, boost::asio::buffer(data, size), handler);
|
Chris@16
|
446 * @endcode
|
Chris@16
|
447 * See the @ref buffer documentation for information on reading into multiple
|
Chris@16
|
448 * buffers in one go, and how to use it with arrays, boost::array or
|
Chris@16
|
449 * std::vector.
|
Chris@16
|
450 *
|
Chris@16
|
451 * @note This overload is equivalent to calling:
|
Chris@16
|
452 * @code boost::asio::async_read_at(
|
Chris@16
|
453 * d, 42, buffers,
|
Chris@16
|
454 * boost::asio::transfer_all(),
|
Chris@16
|
455 * handler); @endcode
|
Chris@16
|
456 */
|
Chris@16
|
457 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
458 typename ReadHandler>
|
Chris@16
|
459 BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
460 void (boost::system::error_code, std::size_t))
|
Chris@16
|
461 async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
|
Chris@16
|
462 const MutableBufferSequence& buffers,
|
Chris@16
|
463 BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
|
Chris@16
|
464
|
Chris@16
|
465 /// Start an asynchronous operation to read a certain amount of data at the
|
Chris@16
|
466 /// specified offset.
|
Chris@16
|
467 /**
|
Chris@16
|
468 * This function is used to asynchronously read a certain number of bytes of
|
Chris@16
|
469 * data from a random access device at the specified offset. The function call
|
Chris@16
|
470 * always returns immediately. The asynchronous operation will continue until
|
Chris@16
|
471 * one of the following conditions is true:
|
Chris@16
|
472 *
|
Chris@16
|
473 * @li The supplied buffers are full. That is, the bytes transferred is equal to
|
Chris@16
|
474 * the sum of the buffer sizes.
|
Chris@16
|
475 *
|
Chris@16
|
476 * @li The completion_condition function object returns 0.
|
Chris@16
|
477 *
|
Chris@16
|
478 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
479 * the AsyncRandomAccessReadDevice concept.
|
Chris@16
|
480 *
|
Chris@16
|
481 * @param offset The offset at which the data will be read.
|
Chris@16
|
482 *
|
Chris@16
|
483 * @param buffers One or more buffers into which the data will be read. The sum
|
Chris@16
|
484 * of the buffer sizes indicates the maximum number of bytes to read from the
|
Chris@16
|
485 * device. Although the buffers object may be copied as necessary, ownership of
|
Chris@16
|
486 * the underlying memory blocks is retained by the caller, which must guarantee
|
Chris@16
|
487 * that they remain valid until the handler is called.
|
Chris@16
|
488 *
|
Chris@16
|
489 * @param completion_condition The function object to be called to determine
|
Chris@16
|
490 * whether the read operation is complete. The signature of the function object
|
Chris@16
|
491 * must be:
|
Chris@16
|
492 * @code std::size_t completion_condition(
|
Chris@16
|
493 * // Result of latest async_read_some_at operation.
|
Chris@16
|
494 * const boost::system::error_code& error,
|
Chris@16
|
495 *
|
Chris@16
|
496 * // Number of bytes transferred so far.
|
Chris@16
|
497 * std::size_t bytes_transferred
|
Chris@16
|
498 * ); @endcode
|
Chris@16
|
499 * A return value of 0 indicates that the read operation is complete. A non-zero
|
Chris@16
|
500 * return value indicates the maximum number of bytes to be read on the next
|
Chris@16
|
501 * call to the device's async_read_some_at function.
|
Chris@16
|
502 *
|
Chris@16
|
503 * @param handler The handler to be called when the read operation completes.
|
Chris@16
|
504 * Copies will be made of the handler as required. The function signature of the
|
Chris@16
|
505 * handler must be:
|
Chris@16
|
506 * @code void handler(
|
Chris@16
|
507 * // Result of operation.
|
Chris@16
|
508 * const boost::system::error_code& error,
|
Chris@16
|
509 *
|
Chris@16
|
510 * // Number of bytes copied into the buffers. If an error
|
Chris@16
|
511 * // occurred, this will be the number of bytes successfully
|
Chris@16
|
512 * // transferred prior to the error.
|
Chris@16
|
513 * std::size_t bytes_transferred
|
Chris@16
|
514 * ); @endcode
|
Chris@16
|
515 * Regardless of whether the asynchronous operation completes immediately or
|
Chris@16
|
516 * not, the handler will not be invoked from within this function. Invocation of
|
Chris@16
|
517 * the handler will be performed in a manner equivalent to using
|
Chris@16
|
518 * boost::asio::io_service::post().
|
Chris@16
|
519 *
|
Chris@16
|
520 * @par Example
|
Chris@16
|
521 * To read into a single data buffer use the @ref buffer function as follows:
|
Chris@16
|
522 * @code boost::asio::async_read_at(d, 42,
|
Chris@16
|
523 * boost::asio::buffer(data, size),
|
Chris@16
|
524 * boost::asio::transfer_at_least(32),
|
Chris@16
|
525 * handler); @endcode
|
Chris@16
|
526 * See the @ref buffer documentation for information on reading into multiple
|
Chris@16
|
527 * buffers in one go, and how to use it with arrays, boost::array or
|
Chris@16
|
528 * std::vector.
|
Chris@16
|
529 */
|
Chris@16
|
530 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
|
Chris@16
|
531 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
532 BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
533 void (boost::system::error_code, std::size_t))
|
Chris@16
|
534 async_read_at(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
535 uint64_t offset, const MutableBufferSequence& buffers,
|
Chris@16
|
536 CompletionCondition completion_condition,
|
Chris@16
|
537 BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
|
Chris@16
|
538
|
Chris@16
|
539 #if !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
540
|
Chris@16
|
541 /// Start an asynchronous operation to read a certain amount of data at the
|
Chris@16
|
542 /// specified offset.
|
Chris@16
|
543 /**
|
Chris@16
|
544 * This function is used to asynchronously read a certain number of bytes of
|
Chris@16
|
545 * data from a random access device at the specified offset. The function call
|
Chris@16
|
546 * always returns immediately. The asynchronous operation will continue until
|
Chris@16
|
547 * one of the following conditions is true:
|
Chris@16
|
548 *
|
Chris@16
|
549 * @li An error occurred.
|
Chris@16
|
550 *
|
Chris@16
|
551 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
552 * async_read_some_at function.
|
Chris@16
|
553 *
|
Chris@16
|
554 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
555 * the AsyncRandomAccessReadDevice concept.
|
Chris@16
|
556 *
|
Chris@16
|
557 * @param offset The offset at which the data will be read.
|
Chris@16
|
558 *
|
Chris@16
|
559 * @param b A basic_streambuf object into which the data will be read. Ownership
|
Chris@16
|
560 * of the streambuf is retained by the caller, which must guarantee that it
|
Chris@16
|
561 * remains valid until the handler is called.
|
Chris@16
|
562 *
|
Chris@16
|
563 * @param handler The handler to be called when the read operation completes.
|
Chris@16
|
564 * Copies will be made of the handler as required. The function signature of the
|
Chris@16
|
565 * handler must be:
|
Chris@16
|
566 * @code void handler(
|
Chris@16
|
567 * // Result of operation.
|
Chris@16
|
568 * const boost::system::error_code& error,
|
Chris@16
|
569 *
|
Chris@16
|
570 * // Number of bytes copied into the buffers. If an error
|
Chris@16
|
571 * // occurred, this will be the number of bytes successfully
|
Chris@16
|
572 * // transferred prior to the error.
|
Chris@16
|
573 * std::size_t bytes_transferred
|
Chris@16
|
574 * ); @endcode
|
Chris@16
|
575 * Regardless of whether the asynchronous operation completes immediately or
|
Chris@16
|
576 * not, the handler will not be invoked from within this function. Invocation of
|
Chris@16
|
577 * the handler will be performed in a manner equivalent to using
|
Chris@16
|
578 * boost::asio::io_service::post().
|
Chris@16
|
579 *
|
Chris@16
|
580 * @note This overload is equivalent to calling:
|
Chris@16
|
581 * @code boost::asio::async_read_at(
|
Chris@16
|
582 * d, 42, b,
|
Chris@16
|
583 * boost::asio::transfer_all(),
|
Chris@16
|
584 * handler); @endcode
|
Chris@16
|
585 */
|
Chris@16
|
586 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
587 typename ReadHandler>
|
Chris@16
|
588 BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
589 void (boost::system::error_code, std::size_t))
|
Chris@16
|
590 async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset,
|
Chris@16
|
591 basic_streambuf<Allocator>& b, BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
|
Chris@16
|
592
|
Chris@16
|
593 /// Start an asynchronous operation to read a certain amount of data at the
|
Chris@16
|
594 /// specified offset.
|
Chris@16
|
595 /**
|
Chris@16
|
596 * This function is used to asynchronously read a certain number of bytes of
|
Chris@16
|
597 * data from a random access device at the specified offset. The function call
|
Chris@16
|
598 * always returns immediately. The asynchronous operation will continue until
|
Chris@16
|
599 * one of the following conditions is true:
|
Chris@16
|
600 *
|
Chris@16
|
601 * @li The completion_condition function object returns 0.
|
Chris@16
|
602 *
|
Chris@16
|
603 * This operation is implemented in terms of zero or more calls to the device's
|
Chris@16
|
604 * async_read_some_at function.
|
Chris@16
|
605 *
|
Chris@16
|
606 * @param d The device from which the data is to be read. The type must support
|
Chris@16
|
607 * the AsyncRandomAccessReadDevice concept.
|
Chris@16
|
608 *
|
Chris@16
|
609 * @param offset The offset at which the data will be read.
|
Chris@16
|
610 *
|
Chris@16
|
611 * @param b A basic_streambuf object into which the data will be read. Ownership
|
Chris@16
|
612 * of the streambuf is retained by the caller, which must guarantee that it
|
Chris@16
|
613 * remains valid until the handler is called.
|
Chris@16
|
614 *
|
Chris@16
|
615 * @param completion_condition The function object to be called to determine
|
Chris@16
|
616 * whether the read operation is complete. The signature of the function object
|
Chris@16
|
617 * must be:
|
Chris@16
|
618 * @code std::size_t completion_condition(
|
Chris@16
|
619 * // Result of latest async_read_some_at operation.
|
Chris@16
|
620 * const boost::system::error_code& error,
|
Chris@16
|
621 *
|
Chris@16
|
622 * // Number of bytes transferred so far.
|
Chris@16
|
623 * std::size_t bytes_transferred
|
Chris@16
|
624 * ); @endcode
|
Chris@16
|
625 * A return value of 0 indicates that the read operation is complete. A non-zero
|
Chris@16
|
626 * return value indicates the maximum number of bytes to be read on the next
|
Chris@16
|
627 * call to the device's async_read_some_at function.
|
Chris@16
|
628 *
|
Chris@16
|
629 * @param handler The handler to be called when the read operation completes.
|
Chris@16
|
630 * Copies will be made of the handler as required. The function signature of the
|
Chris@16
|
631 * handler must be:
|
Chris@16
|
632 * @code void handler(
|
Chris@16
|
633 * // Result of operation.
|
Chris@16
|
634 * const boost::system::error_code& error,
|
Chris@16
|
635 *
|
Chris@16
|
636 * // Number of bytes copied into the buffers. If an error
|
Chris@16
|
637 * // occurred, this will be the number of bytes successfully
|
Chris@16
|
638 * // transferred prior to the error.
|
Chris@16
|
639 * std::size_t bytes_transferred
|
Chris@16
|
640 * ); @endcode
|
Chris@16
|
641 * Regardless of whether the asynchronous operation completes immediately or
|
Chris@16
|
642 * not, the handler will not be invoked from within this function. Invocation of
|
Chris@16
|
643 * the handler will be performed in a manner equivalent to using
|
Chris@16
|
644 * boost::asio::io_service::post().
|
Chris@16
|
645 */
|
Chris@16
|
646 template <typename AsyncRandomAccessReadDevice, typename Allocator,
|
Chris@16
|
647 typename CompletionCondition, typename ReadHandler>
|
Chris@16
|
648 BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
Chris@16
|
649 void (boost::system::error_code, std::size_t))
|
Chris@16
|
650 async_read_at(AsyncRandomAccessReadDevice& d,
|
Chris@16
|
651 uint64_t offset, basic_streambuf<Allocator>& b,
|
Chris@16
|
652 CompletionCondition completion_condition,
|
Chris@16
|
653 BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
|
Chris@16
|
654
|
Chris@16
|
655 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
|
Chris@16
|
656
|
Chris@16
|
657 /*@}*/
|
Chris@16
|
658
|
Chris@16
|
659 } // namespace asio
|
Chris@16
|
660 } // namespace boost
|
Chris@16
|
661
|
Chris@16
|
662 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
663
|
Chris@16
|
664 #include <boost/asio/impl/read_at.hpp>
|
Chris@16
|
665
|
Chris@16
|
666 #endif // BOOST_ASIO_READ_AT_HPP
|