11 #ifndef ASIO_IMPL_WRITE_HPP 12 #define ASIO_IMPL_WRITE_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 35 template <
typename SyncWriteStream,
typename ConstBufferSequence,
36 typename CompletionCondition>
37 std::size_t
write(SyncWriteStream&
s,
const ConstBufferSequence&
buffers,
43 std::size_t total_transferred = 0;
46 while (tmp.begin() != tmp.end())
48 std::size_t bytes_transferred = s.write_some(tmp, ec);
49 tmp.consume(bytes_transferred);
50 total_transferred += bytes_transferred;
54 return total_transferred;
57 template <
typename SyncWriteStream,
typename ConstBufferSequence>
58 inline std::size_t
write(SyncWriteStream&
s,
const ConstBufferSequence&
buffers)
63 return bytes_transferred;
66 template <
typename SyncWriteStream,
typename ConstBufferSequence>
67 inline std::size_t
write(SyncWriteStream&
s,
const ConstBufferSequence&
buffers,
73 template <
typename SyncWriteStream,
typename ConstBufferSequence,
74 typename CompletionCondition>
75 inline std::size_t
write(SyncWriteStream&
s,
const ConstBufferSequence&
buffers,
79 std::size_t bytes_transferred =
write(s, buffers, completion_condition, ec);
81 return bytes_transferred;
84 #if !defined(ASIO_NO_IOSTREAM) 86 template <
typename SyncWriteStream,
typename Allocator,
87 typename CompletionCondition>
88 std::size_t
write(SyncWriteStream&
s,
94 return bytes_transferred;
97 template <
typename SyncWriteStream,
typename Allocator>
98 inline std::size_t
write(SyncWriteStream&
s,
104 return bytes_transferred;
107 template <
typename SyncWriteStream,
typename Allocator>
108 inline std::size_t
write(SyncWriteStream&
s,
115 template <
typename SyncWriteStream,
typename Allocator,
116 typename CompletionCondition>
117 inline std::size_t
write(SyncWriteStream&
s,
122 std::size_t bytes_transferred =
write(s, b, completion_condition, ec);
124 return bytes_transferred;
127 #endif // !defined(ASIO_NO_IOSTREAM) 131 template <
typename AsyncWriteStream,
typename ConstBufferSequence,
132 typename CompletionCondition,
typename WriteHandler>
140 CompletionCondition>(completion_condition),
149 #if defined(ASIO_HAS_MOVE) 169 #endif // defined(ASIO_HAS_MOVE) 172 std::size_t bytes_transferred,
int start = 0)
184 buffers_.consume(bytes_transferred);
186 if ((!ec && bytes_transferred == 0)
204 template <
typename AsyncWriteStream,
205 typename CompletionCondition,
typename WriteHandler>
207 CompletionCondition, WriteHandler>
214 WriteHandler& handler)
216 CompletionCondition>(completion_condition),
225 #if defined(ASIO_HAS_MOVE) 229 buffer_(other.buffer_),
239 buffer_(other.buffer_),
245 #endif // defined(ASIO_HAS_MOVE) 248 std::size_t bytes_transferred,
int start = 0)
262 if ((!ec && bytes_transferred == 0)
280 template <
typename AsyncWriteStream,
281 typename CompletionCondition,
typename WriteHandler>
283 CompletionCondition, WriteHandler>
290 WriteHandler& handler)
292 CompletionCondition>(completion_condition),
301 #if defined(ASIO_HAS_MOVE) 305 buffer_(other.buffer_),
315 buffer_(other.buffer_),
321 #endif // defined(ASIO_HAS_MOVE) 324 std::size_t bytes_transferred,
int start = 0)
338 if ((!ec && bytes_transferred == 0)
356 template <
typename AsyncWriteStream,
typename Elem,
357 typename CompletionCondition,
typename WriteHandler>
359 CompletionCondition, WriteHandler>
366 CompletionCondition>(completion_condition),
375 #if defined(ASIO_HAS_MOVE) 395 #endif // defined(ASIO_HAS_MOVE) 398 std::size_t bytes_transferred,
int start = 0)
421 if ((!ec && bytes_transferred == 0)
439 #if defined(ASIO_HAS_STD_ARRAY) 441 template <
typename AsyncWriteStream,
typename Elem,
442 typename CompletionCondition,
typename WriteHandler>
444 CompletionCondition, WriteHandler>
460 #if defined(ASIO_HAS_MOVE) 480 #endif // defined(ASIO_HAS_MOVE) 483 std::size_t bytes_transferred,
int start = 0)
486 std::array<asio::const_buffer, 2> >::type bufs = {{
506 if ((!ec && bytes_transferred == 0)
524 #endif // defined(ASIO_HAS_STD_ARRAY) 526 template <
typename AsyncWriteStream,
typename ConstBufferSequence,
527 typename CompletionCondition,
typename WriteHandler>
529 write_op<AsyncWriteStream, ConstBufferSequence,
530 CompletionCondition, WriteHandler>* this_handler)
533 size, this_handler->handler_);
536 template <
typename AsyncWriteStream,
typename ConstBufferSequence,
537 typename CompletionCondition,
typename WriteHandler>
539 write_op<AsyncWriteStream, ConstBufferSequence,
540 CompletionCondition, WriteHandler>* this_handler)
543 pointer, size, this_handler->handler_);
546 template <
typename AsyncWriteStream,
typename ConstBufferSequence,
547 typename CompletionCondition,
typename WriteHandler>
549 write_op<AsyncWriteStream, ConstBufferSequence,
550 CompletionCondition, WriteHandler>* this_handler)
552 return this_handler->start_ == 0 ?
true 554 this_handler->handler_);
557 template <
typename Function,
typename AsyncWriteStream,
558 typename ConstBufferSequence,
typename CompletionCondition,
559 typename WriteHandler>
561 write_op<AsyncWriteStream, ConstBufferSequence,
562 CompletionCondition, WriteHandler>* this_handler)
565 function, this_handler->handler_);
568 template <
typename Function,
typename AsyncWriteStream,
569 typename ConstBufferSequence,
typename CompletionCondition,
570 typename WriteHandler>
572 write_op<AsyncWriteStream, ConstBufferSequence,
573 CompletionCondition, WriteHandler>* this_handler)
576 function, this_handler->handler_);
580 template <
typename AsyncWriteStream,
typename ConstBufferSequence,
581 typename CompletionCondition,
typename WriteHandler>
584 async_write(AsyncWriteStream&
s,
const ConstBufferSequence&
buffers,
605 template <
typename AsyncWriteStream,
typename ConstBufferSequence,
606 typename WriteHandler>
609 async_write(AsyncWriteStream& s,
const ConstBufferSequence& buffers,
629 #if !defined(ASIO_NO_IOSTREAM) 633 template <
typename Allocator,
typename WriteHandler>
638 WriteHandler& handler)
639 : streambuf_(streambuf),
644 #if defined(ASIO_HAS_MOVE) 656 #endif // defined(ASIO_HAS_MOVE) 659 const std::size_t bytes_transferred)
661 streambuf_.consume(bytes_transferred);
670 template <
typename Allocator,
typename WriteHandler>
678 template <
typename Allocator,
typename WriteHandler>
683 pointer, size, this_handler->
handler_);
686 template <
typename Allocator,
typename WriteHandler>
694 template <
typename Function,
typename Allocator,
typename WriteHandler>
702 template <
typename Function,
typename Allocator,
typename WriteHandler>
711 template <
typename AsyncWriteStream,
typename Allocator,
712 typename CompletionCondition,
typename WriteHandler>
715 async_write(AsyncWriteStream& s,
717 CompletionCondition completion_condition,
736 template <
typename AsyncWriteStream,
typename Allocator,
typename WriteHandler>
739 async_write(AsyncWriteStream& s,
759 #endif // !defined(ASIO_NO_IOSTREAM) 765 #endif // ASIO_IMPL_WRITE_HPP
void asio_handler_deallocate(void *pointer, std::size_t size, binder1< Handler, Arg1 > *this_handler)
void throw_error(const asio::error_code &err)
write_op(AsyncWriteStream &stream, const ConstBufferSequence &buffers, CompletionCondition completion_condition, WriteHandler &handler)
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
AsyncWriteStream & stream_
Holds a buffer that cannot be modified.
write_op(AsyncWriteStream &stream, const asio::const_buffers_1 &buffers, CompletionCondition completion_condition, WriteHandler &handler)
std::size_t check_for_completion(const asio::error_code &ec, std::size_t total_transferred)
write_op(AsyncWriteStream &stream, const boost::array< Elem, 2 > &buffers, CompletionCondition completion_condition, WriteHandler &handler)
void * asio_handler_allocate(std::size_t size, binder1< Handler, Arg1 > *this_handler)
std::size_t total_transferred_
asio::detail::consuming_buffers< const_buffer, ConstBufferSequence > buffers_
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))
void operator()(const asio::error_code &ec, const std::size_t bytes_transferred)
#define ASIO_HANDLER_TYPE(h, sig)
std::size_t write(SyncWriteStream &s, const ConstBufferSequence &buffers, CompletionCondition completion_condition, asio::error_code &ec)
Write a certain amount of data to a stream before returning.
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
write_op(AsyncWriteStream &stream, const asio::mutable_buffers_1 &buffers, CompletionCondition completion_condition, WriteHandler &handler)
detail::transfer_all_t transfer_all()
write_streambuf_handler(asio::basic_streambuf< Allocator > &streambuf, WriteHandler &handler)
asio::const_buffer buffer_
asio::basic_streambuf< Allocator > & b
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.
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
void invoke(Function &function, Context &context)
AsyncWriteStream & stream_
const MutableBufferSequence & buffers
Holds a buffer that can be modified.
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
void asio_handler_invoke(Function &function, binder1< Handler, Arg1 > *this_handler)
AsyncWriteStream & stream_
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
bool is_continuation(Context &context)
asio::mutable_buffer buffer_
Class to represent an error code value.
void deallocate(void *p, std::size_t s, Handler &h)
std::size_t adapt_completion_condition_result(bool result)
std::size_t total_transferred_
Automatically resizable buffer class based on std::streambuf.
boost::array< Elem, 2 > buffers_
asio::basic_streambuf< Allocator > & streambuf_
void * allocate(std::size_t s, Handler &h)
const MutableBufferSequence CompletionCondition completion_condition
handler_type< Handler, Signature >::type handler
#define ASIO_MOVE_CAST(type)
std::size_t total_transferred_
AsyncWriteStream & stream_
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.
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
#define ASIO_WRITE_HANDLER_CHECK(handler_type, handler)
bool asio_handler_is_continuation(binder1< Handler, Arg1 > *this_handler)
std::size_t total_transferred_