~twpol/dcplusplus/trunk

« back to all changes in this revision

Viewing changes to boost/boost/asio/windows/basic_random_access_handle.hpp

  • Committer: James Ross
  • Date: 2010-07-05 00:03:18 UTC
  • mfrom: (1524.1.650 dcplusplus)
  • Revision ID: silver@warwickcompsoc.co.uk-20100705000318-awwqm8ocpp5m47yz
Merged to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// basic_random_access_handle.hpp
3
 
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
 
//
5
 
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
 
//
7
 
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
 
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
 
//
10
 
 
11
 
#ifndef BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
12
 
#define BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
13
 
 
14
 
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15
 
# pragma once
16
 
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
 
 
18
 
#include <boost/asio/detail/push_options.hpp>
19
 
 
20
 
#include <boost/asio/detail/push_options.hpp>
21
 
#include <cstddef>
22
 
#include <boost/config.hpp>
23
 
#include <boost/asio/detail/pop_options.hpp>
24
 
 
25
 
#include <boost/asio/error.hpp>
26
 
#include <boost/asio/windows/basic_handle.hpp>
27
 
#include <boost/asio/windows/random_access_handle_service.hpp>
28
 
#include <boost/asio/detail/throw_error.hpp>
29
 
 
30
 
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
31
 
  || defined(GENERATING_DOCUMENTATION)
32
 
 
33
 
namespace boost {
34
 
namespace asio {
35
 
namespace windows {
36
 
 
37
 
/// Provides random-access handle functionality.
38
 
/**
39
 
 * The windows::basic_random_access_handle class template provides asynchronous
40
 
 * and blocking random-access handle functionality.
41
 
 *
42
 
 * @par Thread Safety
43
 
 * @e Distinct @e objects: Safe.@n
44
 
 * @e Shared @e objects: Unsafe.
45
 
 */
46
 
template <typename RandomAccessHandleService = random_access_handle_service>
47
 
class basic_random_access_handle
48
 
  : public basic_handle<RandomAccessHandleService>
49
 
{
50
 
public:
51
 
  /// The native representation of a handle.
52
 
  typedef typename RandomAccessHandleService::native_type native_type;
53
 
 
54
 
  /// Construct a basic_random_access_handle without opening it.
55
 
  /**
56
 
   * This constructor creates a random-access handle without opening it. The
57
 
   * handle needs to be opened before data can be written to or or read from it.
58
 
   *
59
 
   * @param io_service The io_service object that the random-access handle will
60
 
   * use to dispatch handlers for any asynchronous operations performed on the
61
 
   * handle.
62
 
   */
63
 
  explicit basic_random_access_handle(boost::asio::io_service& io_service)
64
 
    : basic_handle<RandomAccessHandleService>(io_service)
65
 
  {
66
 
  }
67
 
 
68
 
  /// Construct a basic_random_access_handle on an existing native handle.
69
 
  /**
70
 
   * This constructor creates a random-access handle object to hold an existing
71
 
   * native handle.
72
 
   *
73
 
   * @param io_service The io_service object that the random-access handle will
74
 
   * use to dispatch handlers for any asynchronous operations performed on the
75
 
   * handle.
76
 
   *
77
 
   * @param native_handle The new underlying handle implementation.
78
 
   *
79
 
   * @throws boost::system::system_error Thrown on failure.
80
 
   */
81
 
  basic_random_access_handle(boost::asio::io_service& io_service,
82
 
      const native_type& native_handle)
83
 
    : basic_handle<RandomAccessHandleService>(io_service, native_handle)
84
 
  {
85
 
  }
86
 
 
87
 
  /// Write some data to the handle at the specified offset.
88
 
  /**
89
 
   * This function is used to write data to the random-access handle. The
90
 
   * function call will block until one or more bytes of the data has been
91
 
   * written successfully, or until an error occurs.
92
 
   *
93
 
   * @param offset The offset at which the data will be written.
94
 
   *
95
 
   * @param buffers One or more data buffers to be written to the handle.
96
 
   *
97
 
   * @returns The number of bytes written.
98
 
   *
99
 
   * @throws boost::system::system_error Thrown on failure. An error code of
100
 
   * boost::asio::error::eof indicates that the connection was closed by the
101
 
   * peer.
102
 
   *
103
 
   * @note The write_some_at operation may not write all of the data. Consider
104
 
   * using the @ref write_at function if you need to ensure that all data is
105
 
   * written before the blocking operation completes.
106
 
   *
107
 
   * @par Example
108
 
   * To write a single data buffer use the @ref buffer function as follows:
109
 
   * @code
110
 
   * handle.write_some_at(42, boost::asio::buffer(data, size));
111
 
   * @endcode
112
 
   * See the @ref buffer documentation for information on writing multiple
113
 
   * buffers in one go, and how to use it with arrays, boost::array or
114
 
   * std::vector.
115
 
   */
116
 
  template <typename ConstBufferSequence>
117
 
  std::size_t write_some_at(boost::uint64_t offset,
118
 
      const ConstBufferSequence& buffers)
119
 
  {
120
 
    boost::system::error_code ec;
121
 
    std::size_t s = this->service.write_some_at(
122
 
        this->implementation, offset, buffers, ec);
123
 
    boost::asio::detail::throw_error(ec);
124
 
    return s;
125
 
  }
126
 
 
127
 
  /// Write some data to the handle at the specified offset.
128
 
  /**
129
 
   * This function is used to write data to the random-access handle. The
130
 
   * function call will block until one or more bytes of the data has been
131
 
   * written successfully, or until an error occurs.
132
 
   *
133
 
   * @param offset The offset at which the data will be written.
134
 
   *
135
 
   * @param buffers One or more data buffers to be written to the handle.
136
 
   *
137
 
   * @param ec Set to indicate what error occurred, if any.
138
 
   *
139
 
   * @returns The number of bytes written. Returns 0 if an error occurred.
140
 
   *
141
 
   * @note The write_some operation may not transmit all of the data to the
142
 
   * peer. Consider using the @ref write_at function if you need to ensure that
143
 
   * all data is written before the blocking operation completes.
144
 
   */
145
 
  template <typename ConstBufferSequence>
146
 
  std::size_t write_some_at(boost::uint64_t offset,
147
 
      const ConstBufferSequence& buffers, boost::system::error_code& ec)
148
 
  {
149
 
    return this->service.write_some_at(
150
 
        this->implementation, offset, buffers, ec);
151
 
  }
152
 
 
153
 
  /// Start an asynchronous write at the specified offset.
154
 
  /**
155
 
   * This function is used to asynchronously write data to the random-access
156
 
   * handle. The function call always returns immediately.
157
 
   *
158
 
   * @param offset The offset at which the data will be written.
159
 
   *
160
 
   * @param buffers One or more data buffers to be written to the handle.
161
 
   * Although the buffers object may be copied as necessary, ownership of the
162
 
   * underlying memory blocks is retained by the caller, which must guarantee
163
 
   * that they remain valid until the handler is called.
164
 
   *
165
 
   * @param handler The handler to be called when the write operation completes.
166
 
   * Copies will be made of the handler as required. The function signature of
167
 
   * the handler must be:
168
 
   * @code void handler(
169
 
   *   const boost::system::error_code& error, // Result of operation.
170
 
   *   std::size_t bytes_transferred           // Number of bytes written.
171
 
   * ); @endcode
172
 
   * Regardless of whether the asynchronous operation completes immediately or
173
 
   * not, the handler will not be invoked from within this function. Invocation
174
 
   * of the handler will be performed in a manner equivalent to using
175
 
   * boost::asio::io_service::post().
176
 
   *
177
 
   * @note The write operation may not transmit all of the data to the peer.
178
 
   * Consider using the @ref async_write_at function if you need to ensure that
179
 
   * all data is written before the asynchronous operation completes.
180
 
   *
181
 
   * @par Example
182
 
   * To write a single data buffer use the @ref buffer function as follows:
183
 
   * @code
184
 
   * handle.async_write_some_at(42, boost::asio::buffer(data, size), handler);
185
 
   * @endcode
186
 
   * See the @ref buffer documentation for information on writing multiple
187
 
   * buffers in one go, and how to use it with arrays, boost::array or
188
 
   * std::vector.
189
 
   */
190
 
  template <typename ConstBufferSequence, typename WriteHandler>
191
 
  void async_write_some_at(boost::uint64_t offset,
192
 
      const ConstBufferSequence& buffers, WriteHandler handler)
193
 
  {
194
 
    this->service.async_write_some_at(
195
 
        this->implementation, offset, buffers, handler);
196
 
  }
197
 
 
198
 
  /// Read some data from the handle at the specified offset.
199
 
  /**
200
 
   * This function is used to read data from the random-access handle. The
201
 
   * function call will block until one or more bytes of data has been read
202
 
   * successfully, or until an error occurs.
203
 
   *
204
 
   * @param offset The offset at which the data will be read.
205
 
   *
206
 
   * @param buffers One or more buffers into which the data will be read.
207
 
   *
208
 
   * @returns The number of bytes read.
209
 
   *
210
 
   * @throws boost::system::system_error Thrown on failure. An error code of
211
 
   * boost::asio::error::eof indicates that the connection was closed by the
212
 
   * peer.
213
 
   *
214
 
   * @note The read_some operation may not read all of the requested number of
215
 
   * bytes. Consider using the @ref read_at function if you need to ensure that
216
 
   * the requested amount of data is read before the blocking operation
217
 
   * completes.
218
 
   *
219
 
   * @par Example
220
 
   * To read into a single data buffer use the @ref buffer function as follows:
221
 
   * @code
222
 
   * handle.read_some_at(42, boost::asio::buffer(data, size));
223
 
   * @endcode
224
 
   * See the @ref buffer documentation for information on reading into multiple
225
 
   * buffers in one go, and how to use it with arrays, boost::array or
226
 
   * std::vector.
227
 
   */
228
 
  template <typename MutableBufferSequence>
229
 
  std::size_t read_some_at(boost::uint64_t offset,
230
 
      const MutableBufferSequence& buffers)
231
 
  {
232
 
    boost::system::error_code ec;
233
 
    std::size_t s = this->service.read_some_at(
234
 
        this->implementation, offset, buffers, ec);
235
 
    boost::asio::detail::throw_error(ec);
236
 
    return s;
237
 
  }
238
 
 
239
 
  /// Read some data from the handle at the specified offset.
240
 
  /**
241
 
   * This function is used to read data from the random-access handle. The
242
 
   * function call will block until one or more bytes of data has been read
243
 
   * successfully, or until an error occurs.
244
 
   *
245
 
   * @param offset The offset at which the data will be read.
246
 
   *
247
 
   * @param buffers One or more buffers into which the data will be read.
248
 
   *
249
 
   * @param ec Set to indicate what error occurred, if any.
250
 
   *
251
 
   * @returns The number of bytes read. Returns 0 if an error occurred.
252
 
   *
253
 
   * @note The read_some operation may not read all of the requested number of
254
 
   * bytes. Consider using the @ref read_at function if you need to ensure that
255
 
   * the requested amount of data is read before the blocking operation
256
 
   * completes.
257
 
   */
258
 
  template <typename MutableBufferSequence>
259
 
  std::size_t read_some_at(boost::uint64_t offset,
260
 
      const MutableBufferSequence& buffers, boost::system::error_code& ec)
261
 
  {
262
 
    return this->service.read_some_at(
263
 
        this->implementation, offset, buffers, ec);
264
 
  }
265
 
 
266
 
  /// Start an asynchronous read at the specified offset.
267
 
  /**
268
 
   * This function is used to asynchronously read data from the random-access
269
 
   * handle. The function call always returns immediately.
270
 
   *
271
 
   * @param offset The offset at which the data will be read.
272
 
   *
273
 
   * @param buffers One or more buffers into which the data will be read.
274
 
   * Although the buffers object may be copied as necessary, ownership of the
275
 
   * underlying memory blocks is retained by the caller, which must guarantee
276
 
   * that they remain valid until the handler is called.
277
 
   *
278
 
   * @param handler The handler to be called when the read operation completes.
279
 
   * Copies will be made of the handler as required. The function signature of
280
 
   * the handler must be:
281
 
   * @code void handler(
282
 
   *   const boost::system::error_code& error, // Result of operation.
283
 
   *   std::size_t bytes_transferred           // Number of bytes read.
284
 
   * ); @endcode
285
 
   * Regardless of whether the asynchronous operation completes immediately or
286
 
   * not, the handler will not be invoked from within this function. Invocation
287
 
   * of the handler will be performed in a manner equivalent to using
288
 
   * boost::asio::io_service::post().
289
 
   *
290
 
   * @note The read operation may not read all of the requested number of bytes.
291
 
   * Consider using the @ref async_read_at function if you need to ensure that
292
 
   * the requested amount of data is read before the asynchronous operation
293
 
   * completes.
294
 
   *
295
 
   * @par Example
296
 
   * To read into a single data buffer use the @ref buffer function as follows:
297
 
   * @code
298
 
   * handle.async_read_some_at(42, boost::asio::buffer(data, size), handler);
299
 
   * @endcode
300
 
   * See the @ref buffer documentation for information on reading into multiple
301
 
   * buffers in one go, and how to use it with arrays, boost::array or
302
 
   * std::vector.
303
 
   */
304
 
  template <typename MutableBufferSequence, typename ReadHandler>
305
 
  void async_read_some_at(boost::uint64_t offset,
306
 
      const MutableBufferSequence& buffers, ReadHandler handler)
307
 
  {
308
 
    this->service.async_read_some_at(
309
 
        this->implementation, offset, buffers, handler);
310
 
  }
311
 
};
312
 
 
313
 
} // namespace windows
314
 
} // namespace asio
315
 
} // namespace boost
316
 
 
317
 
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
318
 
       //   || defined(GENERATING_DOCUMENTATION)
319
 
 
320
 
#include <boost/asio/detail/pop_options.hpp>
321
 
 
322
 
#endif // BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
 
1
//
 
2
// basic_random_access_handle.hpp
 
3
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
4
//
 
5
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 
6
//
 
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
 
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
9
//
 
10
 
 
11
#ifndef BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
 
12
#define BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
 
13
 
 
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
 
15
# pragma once
 
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
17
 
 
18
#include <boost/asio/detail/push_options.hpp>
 
19
 
 
20
#include <boost/asio/detail/push_options.hpp>
 
21
#include <cstddef>
 
22
#include <boost/config.hpp>
 
23
#include <boost/asio/detail/pop_options.hpp>
 
24
 
 
25
#include <boost/asio/error.hpp>
 
26
#include <boost/asio/windows/basic_handle.hpp>
 
27
#include <boost/asio/windows/random_access_handle_service.hpp>
 
28
#include <boost/asio/detail/throw_error.hpp>
 
29
 
 
30
#if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
 
31
  || defined(GENERATING_DOCUMENTATION)
 
32
 
 
33
namespace boost {
 
34
namespace asio {
 
35
namespace windows {
 
36
 
 
37
/// Provides random-access handle functionality.
 
38
/**
 
39
 * The windows::basic_random_access_handle class template provides asynchronous
 
40
 * and blocking random-access handle functionality.
 
41
 *
 
42
 * @par Thread Safety
 
43
 * @e Distinct @e objects: Safe.@n
 
44
 * @e Shared @e objects: Unsafe.
 
45
 */
 
46
template <typename RandomAccessHandleService = random_access_handle_service>
 
47
class basic_random_access_handle
 
48
  : public basic_handle<RandomAccessHandleService>
 
49
{
 
50
public:
 
51
  /// The native representation of a handle.
 
52
  typedef typename RandomAccessHandleService::native_type native_type;
 
53
 
 
54
  /// Construct a basic_random_access_handle without opening it.
 
55
  /**
 
56
   * This constructor creates a random-access handle without opening it. The
 
57
   * handle needs to be opened before data can be written to or or read from it.
 
58
   *
 
59
   * @param io_service The io_service object that the random-access handle will
 
60
   * use to dispatch handlers for any asynchronous operations performed on the
 
61
   * handle.
 
62
   */
 
63
  explicit basic_random_access_handle(boost::asio::io_service& io_service)
 
64
    : basic_handle<RandomAccessHandleService>(io_service)
 
65
  {
 
66
  }
 
67
 
 
68
  /// Construct a basic_random_access_handle on an existing native handle.
 
69
  /**
 
70
   * This constructor creates a random-access handle object to hold an existing
 
71
   * native handle.
 
72
   *
 
73
   * @param io_service The io_service object that the random-access handle will
 
74
   * use to dispatch handlers for any asynchronous operations performed on the
 
75
   * handle.
 
76
   *
 
77
   * @param native_handle The new underlying handle implementation.
 
78
   *
 
79
   * @throws boost::system::system_error Thrown on failure.
 
80
   */
 
81
  basic_random_access_handle(boost::asio::io_service& io_service,
 
82
      const native_type& native_handle)
 
83
    : basic_handle<RandomAccessHandleService>(io_service, native_handle)
 
84
  {
 
85
  }
 
86
 
 
87
  /// Write some data to the handle at the specified offset.
 
88
  /**
 
89
   * This function is used to write data to the random-access handle. The
 
90
   * function call will block until one or more bytes of the data has been
 
91
   * written successfully, or until an error occurs.
 
92
   *
 
93
   * @param offset The offset at which the data will be written.
 
94
   *
 
95
   * @param buffers One or more data buffers to be written to the handle.
 
96
   *
 
97
   * @returns The number of bytes written.
 
98
   *
 
99
   * @throws boost::system::system_error Thrown on failure. An error code of
 
100
   * boost::asio::error::eof indicates that the connection was closed by the
 
101
   * peer.
 
102
   *
 
103
   * @note The write_some_at operation may not write all of the data. Consider
 
104
   * using the @ref write_at function if you need to ensure that all data is
 
105
   * written before the blocking operation completes.
 
106
   *
 
107
   * @par Example
 
108
   * To write a single data buffer use the @ref buffer function as follows:
 
109
   * @code
 
110
   * handle.write_some_at(42, boost::asio::buffer(data, size));
 
111
   * @endcode
 
112
   * See the @ref buffer documentation for information on writing multiple
 
113
   * buffers in one go, and how to use it with arrays, boost::array or
 
114
   * std::vector.
 
115
   */
 
116
  template <typename ConstBufferSequence>
 
117
  std::size_t write_some_at(boost::uint64_t offset,
 
118
      const ConstBufferSequence& buffers)
 
119
  {
 
120
    boost::system::error_code ec;
 
121
    std::size_t s = this->service.write_some_at(
 
122
        this->implementation, offset, buffers, ec);
 
123
    boost::asio::detail::throw_error(ec);
 
124
    return s;
 
125
  }
 
126
 
 
127
  /// Write some data to the handle at the specified offset.
 
128
  /**
 
129
   * This function is used to write data to the random-access handle. The
 
130
   * function call will block until one or more bytes of the data has been
 
131
   * written successfully, or until an error occurs.
 
132
   *
 
133
   * @param offset The offset at which the data will be written.
 
134
   *
 
135
   * @param buffers One or more data buffers to be written to the handle.
 
136
   *
 
137
   * @param ec Set to indicate what error occurred, if any.
 
138
   *
 
139
   * @returns The number of bytes written. Returns 0 if an error occurred.
 
140
   *
 
141
   * @note The write_some operation may not transmit all of the data to the
 
142
   * peer. Consider using the @ref write_at function if you need to ensure that
 
143
   * all data is written before the blocking operation completes.
 
144
   */
 
145
  template <typename ConstBufferSequence>
 
146
  std::size_t write_some_at(boost::uint64_t offset,
 
147
      const ConstBufferSequence& buffers, boost::system::error_code& ec)
 
148
  {
 
149
    return this->service.write_some_at(
 
150
        this->implementation, offset, buffers, ec);
 
151
  }
 
152
 
 
153
  /// Start an asynchronous write at the specified offset.
 
154
  /**
 
155
   * This function is used to asynchronously write data to the random-access
 
156
   * handle. The function call always returns immediately.
 
157
   *
 
158
   * @param offset The offset at which the data will be written.
 
159
   *
 
160
   * @param buffers One or more data buffers to be written to the handle.
 
161
   * Although the buffers object may be copied as necessary, ownership of the
 
162
   * underlying memory blocks is retained by the caller, which must guarantee
 
163
   * that they remain valid until the handler is called.
 
164
   *
 
165
   * @param handler The handler to be called when the write operation completes.
 
166
   * Copies will be made of the handler as required. The function signature of
 
167
   * the handler must be:
 
168
   * @code void handler(
 
169
   *   const boost::system::error_code& error, // Result of operation.
 
170
   *   std::size_t bytes_transferred           // Number of bytes written.
 
171
   * ); @endcode
 
172
   * Regardless of whether the asynchronous operation completes immediately or
 
173
   * not, the handler will not be invoked from within this function. Invocation
 
174
   * of the handler will be performed in a manner equivalent to using
 
175
   * boost::asio::io_service::post().
 
176
   *
 
177
   * @note The write operation may not transmit all of the data to the peer.
 
178
   * Consider using the @ref async_write_at function if you need to ensure that
 
179
   * all data is written before the asynchronous operation completes.
 
180
   *
 
181
   * @par Example
 
182
   * To write a single data buffer use the @ref buffer function as follows:
 
183
   * @code
 
184
   * handle.async_write_some_at(42, boost::asio::buffer(data, size), handler);
 
185
   * @endcode
 
186
   * See the @ref buffer documentation for information on writing multiple
 
187
   * buffers in one go, and how to use it with arrays, boost::array or
 
188
   * std::vector.
 
189
   */
 
190
  template <typename ConstBufferSequence, typename WriteHandler>
 
191
  void async_write_some_at(boost::uint64_t offset,
 
192
      const ConstBufferSequence& buffers, WriteHandler handler)
 
193
  {
 
194
    this->service.async_write_some_at(
 
195
        this->implementation, offset, buffers, handler);
 
196
  }
 
197
 
 
198
  /// Read some data from the handle at the specified offset.
 
199
  /**
 
200
   * This function is used to read data from the random-access handle. The
 
201
   * function call will block until one or more bytes of data has been read
 
202
   * successfully, or until an error occurs.
 
203
   *
 
204
   * @param offset The offset at which the data will be read.
 
205
   *
 
206
   * @param buffers One or more buffers into which the data will be read.
 
207
   *
 
208
   * @returns The number of bytes read.
 
209
   *
 
210
   * @throws boost::system::system_error Thrown on failure. An error code of
 
211
   * boost::asio::error::eof indicates that the connection was closed by the
 
212
   * peer.
 
213
   *
 
214
   * @note The read_some operation may not read all of the requested number of
 
215
   * bytes. Consider using the @ref read_at function if you need to ensure that
 
216
   * the requested amount of data is read before the blocking operation
 
217
   * completes.
 
218
   *
 
219
   * @par Example
 
220
   * To read into a single data buffer use the @ref buffer function as follows:
 
221
   * @code
 
222
   * handle.read_some_at(42, boost::asio::buffer(data, size));
 
223
   * @endcode
 
224
   * See the @ref buffer documentation for information on reading into multiple
 
225
   * buffers in one go, and how to use it with arrays, boost::array or
 
226
   * std::vector.
 
227
   */
 
228
  template <typename MutableBufferSequence>
 
229
  std::size_t read_some_at(boost::uint64_t offset,
 
230
      const MutableBufferSequence& buffers)
 
231
  {
 
232
    boost::system::error_code ec;
 
233
    std::size_t s = this->service.read_some_at(
 
234
        this->implementation, offset, buffers, ec);
 
235
    boost::asio::detail::throw_error(ec);
 
236
    return s;
 
237
  }
 
238
 
 
239
  /// Read some data from the handle at the specified offset.
 
240
  /**
 
241
   * This function is used to read data from the random-access handle. The
 
242
   * function call will block until one or more bytes of data has been read
 
243
   * successfully, or until an error occurs.
 
244
   *
 
245
   * @param offset The offset at which the data will be read.
 
246
   *
 
247
   * @param buffers One or more buffers into which the data will be read.
 
248
   *
 
249
   * @param ec Set to indicate what error occurred, if any.
 
250
   *
 
251
   * @returns The number of bytes read. Returns 0 if an error occurred.
 
252
   *
 
253
   * @note The read_some operation may not read all of the requested number of
 
254
   * bytes. Consider using the @ref read_at function if you need to ensure that
 
255
   * the requested amount of data is read before the blocking operation
 
256
   * completes.
 
257
   */
 
258
  template <typename MutableBufferSequence>
 
259
  std::size_t read_some_at(boost::uint64_t offset,
 
260
      const MutableBufferSequence& buffers, boost::system::error_code& ec)
 
261
  {
 
262
    return this->service.read_some_at(
 
263
        this->implementation, offset, buffers, ec);
 
264
  }
 
265
 
 
266
  /// Start an asynchronous read at the specified offset.
 
267
  /**
 
268
   * This function is used to asynchronously read data from the random-access
 
269
   * handle. The function call always returns immediately.
 
270
   *
 
271
   * @param offset The offset at which the data will be read.
 
272
   *
 
273
   * @param buffers One or more buffers into which the data will be read.
 
274
   * Although the buffers object may be copied as necessary, ownership of the
 
275
   * underlying memory blocks is retained by the caller, which must guarantee
 
276
   * that they remain valid until the handler is called.
 
277
   *
 
278
   * @param handler The handler to be called when the read operation completes.
 
279
   * Copies will be made of the handler as required. The function signature of
 
280
   * the handler must be:
 
281
   * @code void handler(
 
282
   *   const boost::system::error_code& error, // Result of operation.
 
283
   *   std::size_t bytes_transferred           // Number of bytes read.
 
284
   * ); @endcode
 
285
   * Regardless of whether the asynchronous operation completes immediately or
 
286
   * not, the handler will not be invoked from within this function. Invocation
 
287
   * of the handler will be performed in a manner equivalent to using
 
288
   * boost::asio::io_service::post().
 
289
   *
 
290
   * @note The read operation may not read all of the requested number of bytes.
 
291
   * Consider using the @ref async_read_at function if you need to ensure that
 
292
   * the requested amount of data is read before the asynchronous operation
 
293
   * completes.
 
294
   *
 
295
   * @par Example
 
296
   * To read into a single data buffer use the @ref buffer function as follows:
 
297
   * @code
 
298
   * handle.async_read_some_at(42, boost::asio::buffer(data, size), handler);
 
299
   * @endcode
 
300
   * See the @ref buffer documentation for information on reading into multiple
 
301
   * buffers in one go, and how to use it with arrays, boost::array or
 
302
   * std::vector.
 
303
   */
 
304
  template <typename MutableBufferSequence, typename ReadHandler>
 
305
  void async_read_some_at(boost::uint64_t offset,
 
306
      const MutableBufferSequence& buffers, ReadHandler handler)
 
307
  {
 
308
    this->service.async_read_some_at(
 
309
        this->implementation, offset, buffers, handler);
 
310
  }
 
311
};
 
312
 
 
313
} // namespace windows
 
314
} // namespace asio
 
315
} // namespace boost
 
316
 
 
317
#endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
 
318
       //   || defined(GENERATING_DOCUMENTATION)
 
319
 
 
320
#include <boost/asio/detail/pop_options.hpp>
 
321
 
 
322
#endif // BOOST_ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP