11 #ifndef ASIO_IMPL_WRITE_AT_HPP 12 #define ASIO_IMPL_WRITE_AT_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 35 template <
typename SyncRandomAccessWriteDevice,
typename ConstBufferSequence,
36 typename CompletionCondition>
37 std::size_t
write_at(SyncRandomAccessWriteDevice& d,
44 std::size_t total_transferred = 0;
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;
56 return total_transferred;
59 template <
typename SyncRandomAccessWriteDevice,
typename ConstBufferSequence>
60 inline std::size_t
write_at(SyncRandomAccessWriteDevice& d,
64 std::size_t bytes_transferred =
write_at(
67 return bytes_transferred;
70 template <
typename SyncRandomAccessWriteDevice,
typename ConstBufferSequence>
71 inline std::size_t
write_at(SyncRandomAccessWriteDevice& d,
78 template <
typename SyncRandomAccessWriteDevice,
typename ConstBufferSequence,
79 typename CompletionCondition>
80 inline std::size_t
write_at(SyncRandomAccessWriteDevice& d,
85 std::size_t bytes_transferred =
write_at(
86 d, offset, buffers, completion_condition, ec);
88 return bytes_transferred;
91 #if !defined(ASIO_NO_IOSTREAM) 93 template <
typename SyncRandomAccessWriteDevice,
typename Allocator,
94 typename CompletionCondition>
95 std::size_t
write_at(SyncRandomAccessWriteDevice& d,
99 std::size_t bytes_transferred =
write_at(
102 return bytes_transferred;
105 template <
typename SyncRandomAccessWriteDevice,
typename Allocator>
106 inline std::size_t
write_at(SyncRandomAccessWriteDevice& d,
112 return bytes_transferred;
115 template <
typename SyncRandomAccessWriteDevice,
typename Allocator>
116 inline std::size_t
write_at(SyncRandomAccessWriteDevice& d,
123 template <
typename SyncRandomAccessWriteDevice,
typename Allocator,
124 typename CompletionCondition>
125 inline std::size_t
write_at(SyncRandomAccessWriteDevice& d,
130 std::size_t bytes_transferred =
write_at(
131 d, offset, b, completion_condition, ec);
133 return bytes_transferred;
136 #endif // !defined(ASIO_NO_IOSTREAM) 140 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
141 typename CompletionCondition,
typename WriteHandler>
150 CompletionCondition>(completion_condition),
160 #if defined(ASIO_HAS_MOVE) 182 #endif // defined(ASIO_HAS_MOVE) 185 std::size_t bytes_transferred,
int start = 0)
198 buffers_.consume(bytes_transferred);
200 if ((!ec && bytes_transferred == 0)
219 template <
typename AsyncRandomAccessWriteDevice,
220 typename CompletionCondition,
typename WriteHandler>
229 WriteHandler& handler)
231 CompletionCondition>(completion_condition),
241 #if defined(ASIO_HAS_MOVE) 246 buffer_(other.buffer_),
257 buffer_(other.buffer_),
263 #endif // defined(ASIO_HAS_MOVE) 266 std::size_t bytes_transferred,
int start = 0)
280 if ((!ec && bytes_transferred == 0)
299 template <
typename AsyncRandomAccessWriteDevice,
300 typename CompletionCondition,
typename WriteHandler>
302 CompletionCondition, WriteHandler>
309 WriteHandler& handler)
311 CompletionCondition>(completion_condition),
321 #if defined(ASIO_HAS_MOVE) 326 buffer_(other.buffer_),
337 buffer_(other.buffer_),
343 #endif // defined(ASIO_HAS_MOVE) 346 std::size_t bytes_transferred,
int start = 0)
360 if ((!ec && bytes_transferred == 0)
379 template <
typename AsyncRandomAccessWriteDevice,
typename Elem,
380 typename CompletionCondition,
typename WriteHandler>
382 CompletionCondition, WriteHandler>
390 CompletionCondition>(completion_condition),
400 #if defined(ASIO_HAS_MOVE) 422 #endif // defined(ASIO_HAS_MOVE) 425 std::size_t bytes_transferred,
int start = 0)
449 if ((!ec && bytes_transferred == 0)
468 #if defined(ASIO_HAS_STD_ARRAY) 470 template <
typename AsyncRandomAccessWriteDevice,
typename Elem,
471 typename CompletionCondition,
typename WriteHandler>
473 CompletionCondition, WriteHandler>
491 #if defined(ASIO_HAS_MOVE) 513 #endif // defined(ASIO_HAS_MOVE) 516 std::size_t bytes_transferred,
int start = 0)
519 std::array<asio::const_buffer, 2> >::type bufs = {{
540 if ((!ec && bytes_transferred == 0)
551 AsyncRandomAccessWriteDevice&
device_;
559 #endif // defined(ASIO_HAS_STD_ARRAY) 561 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
562 typename CompletionCondition,
typename WriteHandler>
564 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
565 CompletionCondition, WriteHandler>* this_handler)
568 size, this_handler->handler_);
571 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
572 typename CompletionCondition,
typename WriteHandler>
574 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
575 CompletionCondition, WriteHandler>* this_handler)
578 pointer, size, this_handler->handler_);
581 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
582 typename CompletionCondition,
typename WriteHandler>
584 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
585 CompletionCondition, WriteHandler>* this_handler)
587 return this_handler->start_ == 0 ?
true 589 this_handler->handler_);
592 template <
typename Function,
typename AsyncRandomAccessWriteDevice,
593 typename ConstBufferSequence,
typename CompletionCondition,
594 typename WriteHandler>
596 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
597 CompletionCondition, WriteHandler>* this_handler)
600 function, this_handler->handler_);
603 template <
typename Function,
typename AsyncRandomAccessWriteDevice,
604 typename ConstBufferSequence,
typename CompletionCondition,
605 typename WriteHandler>
607 write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
608 CompletionCondition, WriteHandler>* this_handler)
611 function, this_handler->handler_);
614 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
615 typename CompletionCondition,
typename WriteHandler>
617 ConstBufferSequence, CompletionCondition, WriteHandler>
623 ConstBufferSequence, CompletionCondition, WriteHandler>(
628 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
629 typename CompletionCondition,
typename WriteHandler>
632 async_write_at(AsyncRandomAccessWriteDevice& d,
654 template <
typename AsyncRandomAccessWriteDevice,
typename ConstBufferSequence,
655 typename WriteHandler>
658 async_write_at(AsyncRandomAccessWriteDevice& d,
659 uint64_t offset,
const ConstBufferSequence& buffers,
679 #if !defined(ASIO_NO_IOSTREAM) 683 template <
typename Allocator,
typename WriteHandler>
689 WriteHandler& handler)
690 : streambuf_(streambuf),
695 #if defined(ASIO_HAS_MOVE) 707 #endif // defined(ASIO_HAS_MOVE) 710 const std::size_t bytes_transferred)
712 streambuf_.consume(bytes_transferred);
721 template <
typename Allocator,
typename WriteHandler>
729 template <
typename Allocator,
typename WriteHandler>
734 pointer, size, this_handler->
handler_);
737 template <
typename Allocator,
typename WriteHandler>
745 template <
typename Function,
typename Allocator,
typename WriteHandler>
753 template <
typename Function,
typename Allocator,
typename WriteHandler>
761 template <
typename Allocator,
typename WriteHandler>
770 template <
typename AsyncRandomAccessWriteDevice,
typename Allocator,
771 typename CompletionCondition,
typename WriteHandler>
774 async_write_at(AsyncRandomAccessWriteDevice& d,
776 CompletionCondition completion_condition,
795 template <
typename AsyncRandomAccessWriteDevice,
typename Allocator,
796 typename WriteHandler>
799 async_write_at(AsyncRandomAccessWriteDevice& d,
819 #endif // !defined(ASIO_NO_IOSTREAM) 825 #endif // ASIO_IMPL_WRITE_AT_HPP
void asio_handler_deallocate(void *pointer, std::size_t size, binder1< Handler, Arg1 > *this_handler)
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
asio::detail::consuming_buffers< const_buffer, ConstBufferSequence > buffers_
std::size_t total_transferred_
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
asio::const_buffer buffer_
void throw_error(const asio::error_code &err)
asio::basic_streambuf< Allocator > & streambuf_
Holds a buffer that cannot be modified.
std::size_t total_transferred_
std::size_t check_for_completion(const asio::error_code &ec, std::size_t total_transferred)
void * asio_handler_allocate(std::size_t size, binder1< Handler, Arg1 > *this_handler)
AsyncRandomAccessWriteDevice & device_
std::size_t total_transferred_
asio::basic_streambuf< Allocator > MatchCondition enable_if< is_match_condition< MatchCondition >::value >::type *detail::async_result_init< ReadHandler, void(asio::error_code, std::size_t)> init(ASIO_MOVE_CAST(ReadHandler)(handler))
#define ASIO_HANDLER_TYPE(h, sig)
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
AsyncRandomAccessWriteDevice & device_
write_at_op(AsyncRandomAccessWriteDevice &device, uint64_t offset, const boost::array< Elem, 2 > &buffers, CompletionCondition completion_condition, WriteHandler &handler)
detail::transfer_all_t transfer_all()
write_at_streambuf_op(asio::basic_streambuf< Allocator > &streambuf, WriteHandler &handler)
write_at_op(AsyncRandomAccessWriteDevice &device, uint64_t offset, const asio::const_buffers_1 &buffers, CompletionCondition completion_condition, WriteHandler &handler)
asio::basic_streambuf< Allocator > & b
AsyncRandomAccessWriteDevice & device_
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
std::size_t buffer_size(const mutable_buffer &b)
Get the number of bytes in a modifiable buffer.
std::size_t write_at(SyncRandomAccessWriteDevice &d, uint64_t offset, const ConstBufferSequence &buffers, CompletionCondition completion_condition, asio::error_code &ec)
Write a certain amount of data at a specified offset before returning.
void invoke(Function &function, Context &context)
const MutableBufferSequence & buffers
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
Holds a buffer that can be modified.
write_at_streambuf_op< Allocator, WriteHandler > make_write_at_streambuf_op(asio::basic_streambuf< Allocator > &b, WriteHandler handler)
void asio_handler_invoke(Function &function, binder1< Handler, Arg1 > *this_handler)
write_at_op(AsyncRandomAccessWriteDevice &device, uint64_t offset, const asio::mutable_buffers_1 &buffers, CompletionCondition completion_condition, WriteHandler &handler)
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
bool is_continuation(Context &context)
Class to represent an error code value.
void deallocate(void *p, std::size_t s, Handler &h)
AsyncRandomAccessWriteDevice & device_
std::size_t adapt_completion_condition_result(bool result)
void operator()(const asio::error_code &ec, const std::size_t bytes_transferred)
std::size_t total_transferred_
Automatically resizable buffer class based on std::streambuf.
void * allocate(std::size_t s, Handler &h)
write_at_op(AsyncRandomAccessWriteDevice &device, uint64_t offset, const ConstBufferSequence &buffers, CompletionCondition completion_condition, WriteHandler &handler)
const MutableBufferSequence CompletionCondition completion_condition
handler_type< Handler, Signature >::type handler
#define ASIO_MOVE_CAST(type)
write_at_op< AsyncRandomAccessWriteDevice, ConstBufferSequence, CompletionCondition, WriteHandler > make_write_at_op(AsyncRandomAccessWriteDevice &d, uint64_t offset, const ConstBufferSequence &buffers, CompletionCondition completion_condition, WriteHandler handler)
async_result< typename handler_type< Handler, Signature >::type > result
const_buffers_type data() const
Get a list of buffers that represents the input sequence.
void consume(std::size_t n)
Remove characters from the input sequence.
#define ASIO_WRITE_HANDLER_CHECK(handler_type, handler)
asio::mutable_buffer buffer_
bool asio_handler_is_continuation(binder1< Handler, Arg1 > *this_handler)
boost::array< Elem, 2 > buffers_