5 // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_IMPL_WRITE_AT_HPP
12 #define BOOST_ASIO_IMPL_WRITE_AT_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/buffer.hpp>
19 #include <boost/asio/completion_condition.hpp>
20 #include <boost/asio/detail/array_fwd.hpp>
21 #include <boost/asio/detail/base_from_completion_cond.hpp>
22 #include <boost/asio/detail/bind_handler.hpp>
23 #include <boost/asio/detail/consuming_buffers.hpp>
24 #include <boost/asio/detail/dependent_type.hpp>
25 #include <boost/asio/detail/handler_alloc_helpers.hpp>
26 #include <boost/asio/detail/handler_invoke_helpers.hpp>
27 #include <boost/asio/detail/handler_type_requirements.hpp>
28 #include <boost/asio/detail/throw_error.hpp>
30 #include <boost/asio/detail/push_options.hpp>
35 template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence,
36 typename CompletionCondition>
37 std::size_t write_at(SyncRandomAccessWriteDevice& d,
38 boost::uint64_t offset, const ConstBufferSequence& buffers,
39 CompletionCondition completion_condition, boost::system::error_code& ec)
41 ec = boost::system::error_code();
42 boost::asio::detail::consuming_buffers<
43 const_buffer, ConstBufferSequence> tmp(buffers);
44 std::size_t total_transferred = 0;
45 tmp.prepare(detail::adapt_completion_condition_result(
46 completion_condition(ec, total_transferred)));
47 while (tmp.begin() != tmp.end())
49 std::size_t bytes_transferred = d.write_some_at(
50 offset + total_transferred, tmp, ec);
51 tmp.consume(bytes_transferred);
52 total_transferred += bytes_transferred;
53 tmp.prepare(detail::adapt_completion_condition_result(
54 completion_condition(ec, total_transferred)));
56 return total_transferred;
59 template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence>
60 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
61 boost::uint64_t offset, const ConstBufferSequence& buffers)
63 boost::system::error_code ec;
64 std::size_t bytes_transferred = write_at(
65 d, offset, buffers, transfer_all(), ec);
66 boost::asio::detail::throw_error(ec, "write_at");
67 return bytes_transferred;
70 template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence>
71 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
72 boost::uint64_t offset, const ConstBufferSequence& buffers,
73 boost::system::error_code& ec)
75 return write_at(d, offset, buffers, transfer_all(), ec);
78 template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence,
79 typename CompletionCondition>
80 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
81 boost::uint64_t offset, const ConstBufferSequence& buffers,
82 CompletionCondition completion_condition)
84 boost::system::error_code ec;
85 std::size_t bytes_transferred = write_at(
86 d, offset, buffers, completion_condition, ec);
87 boost::asio::detail::throw_error(ec, "write_at");
88 return bytes_transferred;
91 #if !defined(BOOST_NO_IOSTREAM)
93 template <typename SyncRandomAccessWriteDevice, typename Allocator,
94 typename CompletionCondition>
95 std::size_t write_at(SyncRandomAccessWriteDevice& d,
96 boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
97 CompletionCondition completion_condition, boost::system::error_code& ec)
99 std::size_t bytes_transferred = write_at(
100 d, offset, b.data(), completion_condition, ec);
101 b.consume(bytes_transferred);
102 return bytes_transferred;
105 template <typename SyncRandomAccessWriteDevice, typename Allocator>
106 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
107 boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b)
109 boost::system::error_code ec;
110 std::size_t bytes_transferred = write_at(d, offset, b, transfer_all(), ec);
111 boost::asio::detail::throw_error(ec, "write_at");
112 return bytes_transferred;
115 template <typename SyncRandomAccessWriteDevice, typename Allocator>
116 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
117 boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
118 boost::system::error_code& ec)
120 return write_at(d, offset, b, transfer_all(), ec);
123 template <typename SyncRandomAccessWriteDevice, typename Allocator,
124 typename CompletionCondition>
125 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
126 boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
127 CompletionCondition completion_condition)
129 boost::system::error_code ec;
130 std::size_t bytes_transferred = write_at(
131 d, offset, b, completion_condition, ec);
132 boost::asio::detail::throw_error(ec, "write_at");
133 return bytes_transferred;
136 #endif // !defined(BOOST_NO_IOSTREAM)
140 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
141 typename CompletionCondition, typename WriteHandler>
143 : detail::base_from_completion_cond<CompletionCondition>
146 write_at_op(AsyncRandomAccessWriteDevice& device,
147 boost::uint64_t offset, const ConstBufferSequence& buffers,
148 CompletionCondition completion_condition, WriteHandler& handler)
149 : detail::base_from_completion_cond<
150 CompletionCondition>(completion_condition),
154 total_transferred_(0),
155 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
159 #if defined(BOOST_ASIO_HAS_MOVE)
160 write_at_op(const write_at_op& other)
161 : detail::base_from_completion_cond<CompletionCondition>(other),
162 device_(other.device_),
163 offset_(other.offset_),
164 buffers_(other.buffers_),
165 total_transferred_(other.total_transferred_),
166 handler_(other.handler_)
170 write_at_op(write_at_op&& other)
171 : detail::base_from_completion_cond<CompletionCondition>(other),
172 device_(other.device_),
173 offset_(other.offset_),
174 buffers_(other.buffers_),
175 total_transferred_(other.total_transferred_),
176 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
179 #endif // defined(BOOST_ASIO_HAS_MOVE)
181 void operator()(const boost::system::error_code& ec,
182 std::size_t bytes_transferred, int start = 0)
187 buffers_.prepare(this->check_for_completion(ec, total_transferred_));
190 device_.async_write_some_at(
191 offset_ + total_transferred_, buffers_,
192 BOOST_ASIO_MOVE_CAST(write_at_op)(*this));
194 total_transferred_ += bytes_transferred;
195 buffers_.consume(bytes_transferred);
196 buffers_.prepare(this->check_for_completion(ec, total_transferred_));
197 if ((!ec && bytes_transferred == 0)
198 || buffers_.begin() == buffers_.end())
202 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
207 AsyncRandomAccessWriteDevice& device_;
208 boost::uint64_t offset_;
209 boost::asio::detail::consuming_buffers<
210 const_buffer, ConstBufferSequence> buffers_;
211 std::size_t total_transferred_;
212 WriteHandler handler_;
215 template <typename AsyncRandomAccessWriteDevice,
216 typename CompletionCondition, typename WriteHandler>
217 class write_at_op<AsyncRandomAccessWriteDevice,
218 boost::asio::mutable_buffers_1, CompletionCondition, WriteHandler>
219 : detail::base_from_completion_cond<CompletionCondition>
222 write_at_op(AsyncRandomAccessWriteDevice& device,
223 boost::uint64_t offset, const boost::asio::mutable_buffers_1& buffers,
224 CompletionCondition completion_condition,
225 WriteHandler& handler)
226 : detail::base_from_completion_cond<
227 CompletionCondition>(completion_condition),
231 total_transferred_(0),
232 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
236 #if defined(BOOST_ASIO_HAS_MOVE)
237 write_at_op(const write_at_op& other)
238 : detail::base_from_completion_cond<CompletionCondition>(other),
239 device_(other.device_),
240 offset_(other.offset_),
241 buffer_(other.buffer_),
242 total_transferred_(other.total_transferred_),
243 handler_(other.handler_)
247 write_at_op(write_at_op&& other)
248 : detail::base_from_completion_cond<CompletionCondition>(other),
249 device_(other.device_),
250 offset_(other.offset_),
251 buffer_(other.buffer_),
252 total_transferred_(other.total_transferred_),
253 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
256 #endif // defined(BOOST_ASIO_HAS_MOVE)
258 void operator()(const boost::system::error_code& ec,
259 std::size_t bytes_transferred, int start = 0)
265 n = this->check_for_completion(ec, total_transferred_);
268 device_.async_write_some_at(offset_ + total_transferred_,
269 boost::asio::buffer(buffer_ + total_transferred_, n),
270 BOOST_ASIO_MOVE_CAST(write_at_op)(*this));
272 total_transferred_ += bytes_transferred;
273 if ((!ec && bytes_transferred == 0)
274 || (n = this->check_for_completion(ec, total_transferred_)) == 0
275 || total_transferred_ == boost::asio::buffer_size(buffer_))
279 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
284 AsyncRandomAccessWriteDevice& device_;
285 boost::uint64_t offset_;
286 boost::asio::mutable_buffer buffer_;
287 std::size_t total_transferred_;
288 WriteHandler handler_;
291 template <typename AsyncRandomAccessWriteDevice,
292 typename CompletionCondition, typename WriteHandler>
293 class write_at_op<AsyncRandomAccessWriteDevice, boost::asio::const_buffers_1,
294 CompletionCondition, WriteHandler>
295 : detail::base_from_completion_cond<CompletionCondition>
298 write_at_op(AsyncRandomAccessWriteDevice& device,
299 boost::uint64_t offset, const boost::asio::const_buffers_1& buffers,
300 CompletionCondition completion_condition,
301 WriteHandler& handler)
302 : detail::base_from_completion_cond<
303 CompletionCondition>(completion_condition),
307 total_transferred_(0),
308 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
312 #if defined(BOOST_ASIO_HAS_MOVE)
313 write_at_op(const write_at_op& other)
314 : detail::base_from_completion_cond<CompletionCondition>(other),
315 device_(other.device_),
316 offset_(other.offset_),
317 buffer_(other.buffer_),
318 total_transferred_(other.total_transferred_),
319 handler_(other.handler_)
323 write_at_op(write_at_op&& other)
324 : detail::base_from_completion_cond<CompletionCondition>(other),
325 device_(other.device_),
326 offset_(other.offset_),
327 buffer_(other.buffer_),
328 total_transferred_(other.total_transferred_),
329 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
332 #endif // defined(BOOST_ASIO_HAS_MOVE)
334 void operator()(const boost::system::error_code& ec,
335 std::size_t bytes_transferred, int start = 0)
341 n = this->check_for_completion(ec, total_transferred_);
344 device_.async_write_some_at(offset_ + total_transferred_,
345 boost::asio::buffer(buffer_ + total_transferred_, n),
346 BOOST_ASIO_MOVE_CAST(write_at_op)(*this));
348 total_transferred_ += bytes_transferred;
349 if ((!ec && bytes_transferred == 0)
350 || (n = this->check_for_completion(ec, total_transferred_)) == 0
351 || total_transferred_ == boost::asio::buffer_size(buffer_))
355 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
360 AsyncRandomAccessWriteDevice& device_;
361 boost::uint64_t offset_;
362 boost::asio::const_buffer buffer_;
363 std::size_t total_transferred_;
364 WriteHandler handler_;
367 template <typename AsyncRandomAccessWriteDevice, typename Elem,
368 typename CompletionCondition, typename WriteHandler>
369 class write_at_op<AsyncRandomAccessWriteDevice, boost::array<Elem, 2>,
370 CompletionCondition, WriteHandler>
371 : detail::base_from_completion_cond<CompletionCondition>
374 write_at_op(AsyncRandomAccessWriteDevice& device,
375 boost::uint64_t offset, const boost::array<Elem, 2>& buffers,
376 CompletionCondition completion_condition, WriteHandler& handler)
377 : detail::base_from_completion_cond<
378 CompletionCondition>(completion_condition),
382 total_transferred_(0),
383 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
387 #if defined(BOOST_ASIO_HAS_MOVE)
388 write_at_op(const write_at_op& other)
389 : detail::base_from_completion_cond<CompletionCondition>(other),
390 device_(other.device_),
391 offset_(other.offset_),
392 buffers_(other.buffers_),
393 total_transferred_(other.total_transferred_),
394 handler_(other.handler_)
398 write_at_op(write_at_op&& other)
399 : detail::base_from_completion_cond<CompletionCondition>(other),
400 device_(other.device_),
401 offset_(other.offset_),
402 buffers_(other.buffers_),
403 total_transferred_(other.total_transferred_),
404 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
407 #endif // defined(BOOST_ASIO_HAS_MOVE)
409 void operator()(const boost::system::error_code& ec,
410 std::size_t bytes_transferred, int start = 0)
412 typename boost::asio::detail::dependent_type<Elem,
413 boost::array<boost::asio::const_buffer, 2> >::type bufs = {{
414 boost::asio::const_buffer(buffers_[0]),
415 boost::asio::const_buffer(buffers_[1]) }};
416 std::size_t buffer_size0 = boost::asio::buffer_size(bufs[0]);
417 std::size_t buffer_size1 = boost::asio::buffer_size(bufs[1]);
422 n = this->check_for_completion(ec, total_transferred_);
425 bufs[0] = boost::asio::buffer(bufs[0] + total_transferred_, n);
426 bufs[1] = boost::asio::buffer(
427 bufs[1] + (total_transferred_ < buffer_size0
428 ? 0 : total_transferred_ - buffer_size0),
429 n - boost::asio::buffer_size(bufs[0]));
430 device_.async_write_some_at(offset_ + total_transferred_,
431 bufs, BOOST_ASIO_MOVE_CAST(write_at_op)(*this));
433 total_transferred_ += bytes_transferred;
434 if ((!ec && bytes_transferred == 0)
435 || (n = this->check_for_completion(ec, total_transferred_)) == 0
436 || total_transferred_ == buffer_size0 + buffer_size1)
440 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
445 AsyncRandomAccessWriteDevice& device_;
446 boost::uint64_t offset_;
447 boost::array<Elem, 2> buffers_;
448 std::size_t total_transferred_;
449 WriteHandler handler_;
452 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
454 template <typename AsyncRandomAccessWriteDevice, typename Elem,
455 typename CompletionCondition, typename WriteHandler>
456 class write_at_op<AsyncRandomAccessWriteDevice, std::array<Elem, 2>,
457 CompletionCondition, WriteHandler>
458 : detail::base_from_completion_cond<CompletionCondition>
461 write_at_op(AsyncRandomAccessWriteDevice& device,
462 boost::uint64_t offset, const std::array<Elem, 2>& buffers,
463 CompletionCondition completion_condition, WriteHandler& handler)
464 : detail::base_from_completion_cond<
465 CompletionCondition>(completion_condition),
469 total_transferred_(0),
470 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
474 #if defined(BOOST_ASIO_HAS_MOVE)
475 write_at_op(const write_at_op& other)
476 : detail::base_from_completion_cond<CompletionCondition>(other),
477 device_(other.device_),
478 offset_(other.offset_),
479 buffers_(other.buffers_),
480 total_transferred_(other.total_transferred_),
481 handler_(other.handler_)
485 write_at_op(write_at_op&& other)
486 : detail::base_from_completion_cond<CompletionCondition>(other),
487 device_(other.device_),
488 offset_(other.offset_),
489 buffers_(other.buffers_),
490 total_transferred_(other.total_transferred_),
491 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
494 #endif // defined(BOOST_ASIO_HAS_MOVE)
496 void operator()(const boost::system::error_code& ec,
497 std::size_t bytes_transferred, int start = 0)
499 typename boost::asio::detail::dependent_type<Elem,
500 std::array<boost::asio::const_buffer, 2> >::type bufs = {{
501 boost::asio::const_buffer(buffers_[0]),
502 boost::asio::const_buffer(buffers_[1]) }};
503 std::size_t buffer_size0 = boost::asio::buffer_size(bufs[0]);
504 std::size_t buffer_size1 = boost::asio::buffer_size(bufs[1]);
509 n = this->check_for_completion(ec, total_transferred_);
512 bufs[0] = boost::asio::buffer(bufs[0] + total_transferred_, n);
513 bufs[1] = boost::asio::buffer(
514 bufs[1] + (total_transferred_ < buffer_size0
515 ? 0 : total_transferred_ - buffer_size0),
516 n - boost::asio::buffer_size(bufs[0]));
517 device_.async_write_some_at(offset_ + total_transferred_,
518 bufs, BOOST_ASIO_MOVE_CAST(write_at_op)(*this));
520 total_transferred_ += bytes_transferred;
521 if ((!ec && bytes_transferred == 0)
522 || (n = this->check_for_completion(ec, total_transferred_)) == 0
523 || total_transferred_ == buffer_size0 + buffer_size1)
527 handler_(ec, static_cast<const std::size_t&>(total_transferred_));
532 AsyncRandomAccessWriteDevice& device_;
533 boost::uint64_t offset_;
534 std::array<Elem, 2> buffers_;
535 std::size_t total_transferred_;
536 WriteHandler handler_;
539 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
541 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
542 typename CompletionCondition, typename WriteHandler>
543 inline void* asio_handler_allocate(std::size_t size,
544 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
545 CompletionCondition, WriteHandler>* this_handler)
547 return boost_asio_handler_alloc_helpers::allocate(
548 size, this_handler->handler_);
551 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
552 typename CompletionCondition, typename WriteHandler>
553 inline void asio_handler_deallocate(void* pointer, std::size_t size,
554 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
555 CompletionCondition, WriteHandler>* this_handler)
557 boost_asio_handler_alloc_helpers::deallocate(
558 pointer, size, this_handler->handler_);
561 template <typename Function, typename AsyncRandomAccessWriteDevice,
562 typename ConstBufferSequence, typename CompletionCondition,
563 typename WriteHandler>
564 inline void asio_handler_invoke(Function& function,
565 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
566 CompletionCondition, WriteHandler>* this_handler)
568 boost_asio_handler_invoke_helpers::invoke(
569 function, this_handler->handler_);
572 template <typename Function, typename AsyncRandomAccessWriteDevice,
573 typename ConstBufferSequence, typename CompletionCondition,
574 typename WriteHandler>
575 inline void asio_handler_invoke(const Function& function,
576 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
577 CompletionCondition, WriteHandler>* this_handler)
579 boost_asio_handler_invoke_helpers::invoke(
580 function, this_handler->handler_);
583 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
584 typename CompletionCondition, typename WriteHandler>
585 inline write_at_op<AsyncRandomAccessWriteDevice,
586 ConstBufferSequence, CompletionCondition, WriteHandler>
587 make_write_at_op(AsyncRandomAccessWriteDevice& d,
588 boost::uint64_t offset, const ConstBufferSequence& buffers,
589 CompletionCondition completion_condition, WriteHandler handler)
591 return write_at_op<AsyncRandomAccessWriteDevice,
592 ConstBufferSequence, CompletionCondition, WriteHandler>(
593 d, offset, buffers, completion_condition, handler);
595 } // namespace detail
597 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
598 typename CompletionCondition, typename WriteHandler>
599 inline void async_write_at(AsyncRandomAccessWriteDevice& d,
600 boost::uint64_t offset, const ConstBufferSequence& buffers,
601 CompletionCondition completion_condition,
602 BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
604 // If you get an error on the following line it means that your handler does
605 // not meet the documented type requirements for a WriteHandler.
606 BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
608 detail::make_write_at_op(
609 d, offset, buffers, completion_condition,
610 BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))(
611 boost::system::error_code(), 0, 1);
614 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
615 typename WriteHandler>
616 inline void async_write_at(AsyncRandomAccessWriteDevice& d,
617 boost::uint64_t offset, const ConstBufferSequence& buffers,
618 BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
620 // If you get an error on the following line it means that your handler does
621 // not meet the documented type requirements for a WriteHandler.
622 BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
624 detail::make_write_at_op(
625 d, offset, buffers, transfer_all(),
626 BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))(
627 boost::system::error_code(), 0, 1);
630 #if !defined(BOOST_NO_IOSTREAM)
634 template <typename Allocator, typename WriteHandler>
635 class write_at_streambuf_op
638 write_at_streambuf_op(
639 boost::asio::basic_streambuf<Allocator>& streambuf,
640 WriteHandler& handler)
641 : streambuf_(streambuf),
642 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
646 #if defined(BOOST_ASIO_HAS_MOVE)
647 write_at_streambuf_op(const write_at_streambuf_op& other)
648 : streambuf_(other.streambuf_),
649 handler_(other.handler_)
653 write_at_streambuf_op(write_at_streambuf_op&& other)
654 : streambuf_(other.streambuf_),
655 handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(other.handler_))
658 #endif // defined(BOOST_ASIO_HAS_MOVE)
660 void operator()(const boost::system::error_code& ec,
661 const std::size_t bytes_transferred)
663 streambuf_.consume(bytes_transferred);
664 handler_(ec, bytes_transferred);
668 boost::asio::basic_streambuf<Allocator>& streambuf_;
669 WriteHandler handler_;
672 template <typename Allocator, typename WriteHandler>
673 inline void* asio_handler_allocate(std::size_t size,
674 write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
676 return boost_asio_handler_alloc_helpers::allocate(
677 size, this_handler->handler_);
680 template <typename Allocator, typename WriteHandler>
681 inline void asio_handler_deallocate(void* pointer, std::size_t size,
682 write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
684 boost_asio_handler_alloc_helpers::deallocate(
685 pointer, size, this_handler->handler_);
688 template <typename Function, typename Allocator, typename WriteHandler>
689 inline void asio_handler_invoke(Function& function,
690 write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
692 boost_asio_handler_invoke_helpers::invoke(
693 function, this_handler->handler_);
696 template <typename Function, typename Allocator, typename WriteHandler>
697 inline void asio_handler_invoke(const Function& function,
698 write_at_streambuf_op<Allocator, WriteHandler>* this_handler)
700 boost_asio_handler_invoke_helpers::invoke(
701 function, this_handler->handler_);
704 template <typename Allocator, typename WriteHandler>
705 inline write_at_streambuf_op<Allocator, WriteHandler>
706 make_write_at_streambuf_op(
707 boost::asio::basic_streambuf<Allocator>& b, WriteHandler handler)
709 return write_at_streambuf_op<Allocator, WriteHandler>(b, handler);
711 } // namespace detail
713 template <typename AsyncRandomAccessWriteDevice, typename Allocator,
714 typename CompletionCondition, typename WriteHandler>
715 inline void async_write_at(AsyncRandomAccessWriteDevice& d,
716 boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
717 CompletionCondition completion_condition,
718 BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
720 // If you get an error on the following line it means that your handler does
721 // not meet the documented type requirements for a WriteHandler.
722 BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
724 async_write_at(d, offset, b.data(), completion_condition,
725 detail::make_write_at_streambuf_op(
726 b, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
729 template <typename AsyncRandomAccessWriteDevice, typename Allocator,
730 typename WriteHandler>
731 inline void async_write_at(AsyncRandomAccessWriteDevice& d,
732 boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
733 BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
735 // If you get an error on the following line it means that your handler does
736 // not meet the documented type requirements for a WriteHandler.
737 BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
739 async_write_at(d, offset, b.data(), transfer_all(),
740 detail::make_write_at_streambuf_op(
741 b, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
744 #endif // !defined(BOOST_NO_IOSTREAM)
749 #include <boost/asio/detail/pop_options.hpp>
751 #endif // BOOST_ASIO_IMPL_WRITE_AT_HPP