Realistic 3D camera system
3D camera system components
read.hpp
Go to the documentation of this file.
1 //
2 // impl/read.hpp
3 // ~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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 ASIO_IMPL_READ_HPP
12 #define ASIO_IMPL_READ_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include <algorithm>
19 #include "asio/buffer.hpp"
31 #include "asio/error.hpp"
32 
34 
35 namespace asio {
36 
37 template <typename SyncReadStream, typename MutableBufferSequence,
38  typename CompletionCondition>
39 std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
40  CompletionCondition completion_condition, asio::error_code& ec)
41 {
42  ec = asio::error_code();
44  mutable_buffer, MutableBufferSequence> tmp(buffers);
45  std::size_t total_transferred = 0;
47  completion_condition(ec, total_transferred)));
48  while (tmp.begin() != tmp.end())
49  {
50  std::size_t bytes_transferred = s.read_some(tmp, ec);
51  tmp.consume(bytes_transferred);
52  total_transferred += bytes_transferred;
54  completion_condition(ec, total_transferred)));
55  }
56  return total_transferred;
57 }
58 
59 template <typename SyncReadStream, typename MutableBufferSequence>
60 inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers)
61 {
63  std::size_t bytes_transferred = read(s, buffers, transfer_all(), ec);
64  asio::detail::throw_error(ec, "read");
65  return bytes_transferred;
66 }
67 
68 template <typename SyncReadStream, typename MutableBufferSequence>
69 inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
70  asio::error_code& ec)
71 {
72  return read(s, buffers, transfer_all(), ec);
73 }
74 
75 template <typename SyncReadStream, typename MutableBufferSequence,
76  typename CompletionCondition>
77 inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
78  CompletionCondition completion_condition)
79 {
81  std::size_t bytes_transferred = read(s, buffers, completion_condition, ec);
82  asio::detail::throw_error(ec, "read");
83  return bytes_transferred;
84 }
85 
86 #if !defined(ASIO_NO_IOSTREAM)
87 
88 template <typename SyncReadStream, typename Allocator,
89  typename CompletionCondition>
90 std::size_t read(SyncReadStream& s,
92  CompletionCondition completion_condition, asio::error_code& ec)
93 {
94  ec = asio::error_code();
95  std::size_t total_transferred = 0;
96  std::size_t max_size = detail::adapt_completion_condition_result(
97  completion_condition(ec, total_transferred));
98  std::size_t bytes_available = read_size_helper(b, max_size);
99  while (bytes_available > 0)
100  {
101  std::size_t bytes_transferred = s.read_some(b.prepare(bytes_available), ec);
102  b.commit(bytes_transferred);
103  total_transferred += bytes_transferred;
105  completion_condition(ec, total_transferred));
106  bytes_available = read_size_helper(b, max_size);
107  }
108  return total_transferred;
109 }
110 
111 template <typename SyncReadStream, typename Allocator>
112 inline std::size_t read(SyncReadStream& s,
114 {
115  asio::error_code ec;
116  std::size_t bytes_transferred = read(s, b, transfer_all(), ec);
117  asio::detail::throw_error(ec, "read");
118  return bytes_transferred;
119 }
120 
121 template <typename SyncReadStream, typename Allocator>
122 inline std::size_t read(SyncReadStream& s,
124  asio::error_code& ec)
125 {
126  return read(s, b, transfer_all(), ec);
127 }
128 
129 template <typename SyncReadStream, typename Allocator,
130  typename CompletionCondition>
131 inline std::size_t read(SyncReadStream& s,
133  CompletionCondition completion_condition)
134 {
135  asio::error_code ec;
136  std::size_t bytes_transferred = read(s, b, completion_condition, ec);
137  asio::detail::throw_error(ec, "read");
138  return bytes_transferred;
139 }
140 
141 #endif // !defined(ASIO_NO_IOSTREAM)
142 
143 namespace detail
144 {
145  template <typename AsyncReadStream, typename MutableBufferSequence,
146  typename CompletionCondition, typename ReadHandler>
147  class read_op
148  : detail::base_from_completion_cond<CompletionCondition>
149  {
150  public:
151  read_op(AsyncReadStream& stream, const MutableBufferSequence& buffers,
152  CompletionCondition completion_condition, ReadHandler& handler)
153  : detail::base_from_completion_cond<
154  CompletionCondition>(completion_condition),
155  stream_(stream),
156  buffers_(buffers),
157  start_(0),
159  handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
160  {
161  }
162 
163 #if defined(ASIO_HAS_MOVE)
164  read_op(const read_op& other)
166  stream_(other.stream_),
167  buffers_(other.buffers_),
168  start_(other.start_),
170  handler_(other.handler_)
171  {
172  }
173 
174  read_op(read_op&& other)
176  stream_(other.stream_),
177  buffers_(other.buffers_),
178  start_(other.start_),
180  handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
181  {
182  }
183 #endif // defined(ASIO_HAS_MOVE)
184 
185  void operator()(const asio::error_code& ec,
186  std::size_t bytes_transferred, int start = 0)
187  {
188  switch (start_ = start)
189  {
190  case 1:
192  for (;;)
193  {
194  stream_.async_read_some(buffers_,
195  ASIO_MOVE_CAST(read_op)(*this));
196  return; default:
197  total_transferred_ += bytes_transferred;
198  buffers_.consume(bytes_transferred);
200  if ((!ec && bytes_transferred == 0)
201  || buffers_.begin() == buffers_.end())
202  break;
203  }
204 
205  handler_(ec, static_cast<const std::size_t&>(total_transferred_));
206  }
207  }
208 
209  //private:
210  AsyncReadStream& stream_;
212  mutable_buffer, MutableBufferSequence> buffers_;
213  int start_;
214  std::size_t total_transferred_;
215  ReadHandler handler_;
216  };
217 
218  template <typename AsyncReadStream,
219  typename CompletionCondition, typename ReadHandler>
220  class read_op<AsyncReadStream, asio::mutable_buffers_1,
221  CompletionCondition, ReadHandler>
222  : detail::base_from_completion_cond<CompletionCondition>
223  {
224  public:
225  read_op(AsyncReadStream& stream,
227  CompletionCondition completion_condition, ReadHandler& handler)
228  : detail::base_from_completion_cond<
229  CompletionCondition>(completion_condition),
230  stream_(stream),
231  buffer_(buffers),
232  start_(0),
234  handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
235  {
236  }
237 
238 #if defined(ASIO_HAS_MOVE)
239  read_op(const read_op& other)
241  stream_(other.stream_),
242  buffer_(other.buffer_),
243  start_(other.start_),
245  handler_(other.handler_)
246  {
247  }
248 
249  read_op(read_op&& other)
251  stream_(other.stream_),
252  buffer_(other.buffer_),
253  start_(other.start_),
255  handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
256  {
257  }
258 #endif // defined(ASIO_HAS_MOVE)
259 
260  void operator()(const asio::error_code& ec,
261  std::size_t bytes_transferred, int start = 0)
262  {
263  std::size_t n = 0;
264  switch (start_ = start)
265  {
266  case 1:
268  for (;;)
269  {
270  stream_.async_read_some(
271  asio::buffer(buffer_ + total_transferred_, n),
272  ASIO_MOVE_CAST(read_op)(*this));
273  return; default:
274  total_transferred_ += bytes_transferred;
275  if ((!ec && bytes_transferred == 0)
276  || (n = this->check_for_completion(ec, total_transferred_)) == 0
277  || total_transferred_ == asio::buffer_size(buffer_))
278  break;
279  }
280 
281  handler_(ec, static_cast<const std::size_t&>(total_transferred_));
282  }
283  }
284 
285  //private:
286  AsyncReadStream& stream_;
288  int start_;
289  std::size_t total_transferred_;
290  ReadHandler handler_;
291  };
292 
293  template <typename AsyncReadStream, typename Elem,
294  typename CompletionCondition, typename ReadHandler>
295  class read_op<AsyncReadStream, boost::array<Elem, 2>,
296  CompletionCondition, ReadHandler>
297  : detail::base_from_completion_cond<CompletionCondition>
298  {
299  public:
300  read_op(AsyncReadStream& stream, const boost::array<Elem, 2>& buffers,
301  CompletionCondition completion_condition, ReadHandler& handler)
302  : detail::base_from_completion_cond<
303  CompletionCondition>(completion_condition),
304  stream_(stream),
305  buffers_(buffers),
306  start_(0),
308  handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
309  {
310  }
311 
312 #if defined(ASIO_HAS_MOVE)
313  read_op(const read_op& other)
315  stream_(other.stream_),
316  buffers_(other.buffers_),
317  start_(other.start_),
319  handler_(other.handler_)
320  {
321  }
322 
323  read_op(read_op&& other)
325  stream_(other.stream_),
326  buffers_(other.buffers_),
327  start_(other.start_),
329  handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
330  {
331  }
332 #endif // defined(ASIO_HAS_MOVE)
333 
334  void operator()(const asio::error_code& ec,
335  std::size_t bytes_transferred, int start = 0)
336  {
337  typename asio::detail::dependent_type<Elem,
338  boost::array<asio::mutable_buffer, 2> >::type bufs = {{
341  std::size_t buffer_size0 = asio::buffer_size(bufs[0]);
342  std::size_t buffer_size1 = asio::buffer_size(bufs[1]);
343  std::size_t n = 0;
344  switch (start_ = start)
345  {
346  case 1:
348  for (;;)
349  {
350  bufs[0] = asio::buffer(bufs[0] + total_transferred_, n);
351  bufs[1] = asio::buffer(
352  bufs[1] + (total_transferred_ < buffer_size0
353  ? 0 : total_transferred_ - buffer_size0),
354  n - asio::buffer_size(bufs[0]));
355  stream_.async_read_some(bufs, ASIO_MOVE_CAST(read_op)(*this));
356  return; default:
357  total_transferred_ += bytes_transferred;
358  if ((!ec && bytes_transferred == 0)
359  || (n = this->check_for_completion(ec, total_transferred_)) == 0
360  || total_transferred_ == buffer_size0 + buffer_size1)
361  break;
362  }
363 
364  handler_(ec, static_cast<const std::size_t&>(total_transferred_));
365  }
366  }
367 
368  //private:
369  AsyncReadStream& stream_;
371  int start_;
372  std::size_t total_transferred_;
373  ReadHandler handler_;
374  };
375 
376 #if defined(ASIO_HAS_STD_ARRAY)
377 
378  template <typename AsyncReadStream, typename Elem,
379  typename CompletionCondition, typename ReadHandler>
380  class read_op<AsyncReadStream, std::array<Elem, 2>,
381  CompletionCondition, ReadHandler>
382  : detail::base_from_completion_cond<CompletionCondition>
383  {
384  public:
385  read_op(AsyncReadStream& stream, const std::array<Elem, 2>& buffers,
386  CompletionCondition completion_condition, ReadHandler& handler)
388  CompletionCondition>(completion_condition),
389  stream_(stream),
390  buffers_(buffers),
391  start_(0),
393  handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
394  {
395  }
396 
397 #if defined(ASIO_HAS_MOVE)
398  read_op(const read_op& other)
400  stream_(other.stream_),
401  buffers_(other.buffers_),
402  start_(other.start_),
404  handler_(other.handler_)
405  {
406  }
407 
408  read_op(read_op&& other)
410  stream_(other.stream_),
411  buffers_(other.buffers_),
412  start_(other.start_),
414  handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
415  {
416  }
417 #endif // defined(ASIO_HAS_MOVE)
418 
419  void operator()(const asio::error_code& ec,
420  std::size_t bytes_transferred, int start = 0)
421  {
422  typename asio::detail::dependent_type<Elem,
423  std::array<asio::mutable_buffer, 2> >::type bufs = {{
426  std::size_t buffer_size0 = asio::buffer_size(bufs[0]);
427  std::size_t buffer_size1 = asio::buffer_size(bufs[1]);
428  std::size_t n = 0;
429  switch (start_ = start)
430  {
431  case 1:
433  for (;;)
434  {
435  bufs[0] = asio::buffer(bufs[0] + total_transferred_, n);
436  bufs[1] = asio::buffer(
437  bufs[1] + (total_transferred_ < buffer_size0
438  ? 0 : total_transferred_ - buffer_size0),
439  n - asio::buffer_size(bufs[0]));
440  stream_.async_read_some(bufs, ASIO_MOVE_CAST(read_op)(*this));
441  return; default:
442  total_transferred_ += bytes_transferred;
443  if ((!ec && bytes_transferred == 0)
444  || (n = this->check_for_completion(ec, total_transferred_)) == 0
445  || total_transferred_ == buffer_size0 + buffer_size1)
446  break;
447  }
448 
449  handler_(ec, static_cast<const std::size_t&>(total_transferred_));
450  }
451  }
452 
453  //private:
454  AsyncReadStream& stream_;
455  std::array<Elem, 2> buffers_;
456  int start_;
457  std::size_t total_transferred_;
458  ReadHandler handler_;
459  };
460 
461 #endif // defined(ASIO_HAS_STD_ARRAY)
462 
463  template <typename AsyncReadStream, typename MutableBufferSequence,
464  typename CompletionCondition, typename ReadHandler>
465  inline void* asio_handler_allocate(std::size_t size,
466  read_op<AsyncReadStream, MutableBufferSequence,
467  CompletionCondition, ReadHandler>* this_handler)
468  {
470  size, this_handler->handler_);
471  }
472 
473  template <typename AsyncReadStream, typename MutableBufferSequence,
474  typename CompletionCondition, typename ReadHandler>
475  inline void asio_handler_deallocate(void* pointer, std::size_t size,
476  read_op<AsyncReadStream, MutableBufferSequence,
477  CompletionCondition, ReadHandler>* this_handler)
478  {
480  pointer, size, this_handler->handler_);
481  }
482 
483  template <typename AsyncReadStream, typename MutableBufferSequence,
484  typename CompletionCondition, typename ReadHandler>
486  read_op<AsyncReadStream, MutableBufferSequence,
487  CompletionCondition, ReadHandler>* this_handler)
488  {
489  return this_handler->start_ == 0 ? true
491  this_handler->handler_);
492  }
493 
494  template <typename Function, typename AsyncReadStream,
495  typename MutableBufferSequence, typename CompletionCondition,
496  typename ReadHandler>
497  inline void asio_handler_invoke(Function& function,
498  read_op<AsyncReadStream, MutableBufferSequence,
499  CompletionCondition, ReadHandler>* this_handler)
500  {
502  function, this_handler->handler_);
503  }
504 
505  template <typename Function, typename AsyncReadStream,
506  typename MutableBufferSequence, typename CompletionCondition,
507  typename ReadHandler>
508  inline void asio_handler_invoke(const Function& function,
509  read_op<AsyncReadStream, MutableBufferSequence,
510  CompletionCondition, ReadHandler>* this_handler)
511  {
513  function, this_handler->handler_);
514  }
515 } // namespace detail
516 
517 template <typename AsyncReadStream, typename MutableBufferSequence,
518  typename CompletionCondition, typename ReadHandler>
519 inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
520  void (asio::error_code, std::size_t))
521 async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
522  CompletionCondition completion_condition,
523  ASIO_MOVE_ARG(ReadHandler) handler)
524 {
525  // If you get an error on the following line it means that your handler does
526  // not meet the documented type requirements for a ReadHandler.
527  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
528 
530  ReadHandler, void (asio::error_code, std::size_t)> init(
531  ASIO_MOVE_CAST(ReadHandler)(handler));
532 
533  detail::read_op<AsyncReadStream, MutableBufferSequence,
534  CompletionCondition, ASIO_HANDLER_TYPE(
535  ReadHandler, void (asio::error_code, std::size_t))>(
537  asio::error_code(), 0, 1);
538 
539  return init.result.get();
540 }
541 
542 template <typename AsyncReadStream, typename MutableBufferSequence,
543  typename ReadHandler>
544 inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
545  void (asio::error_code, std::size_t))
546 async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
547  ASIO_MOVE_ARG(ReadHandler) handler)
548 {
549  // If you get an error on the following line it means that your handler does
550  // not meet the documented type requirements for a ReadHandler.
551  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
552 
554  ReadHandler, void (asio::error_code, std::size_t)> init(
555  ASIO_MOVE_CAST(ReadHandler)(handler));
556 
557  detail::read_op<AsyncReadStream, MutableBufferSequence,
559  ReadHandler, void (asio::error_code, std::size_t))>(
560  s, buffers, transfer_all(), init.handler)(
561  asio::error_code(), 0, 1);
562 
563  return init.result.get();
564 }
565 
566 #if !defined(ASIO_NO_IOSTREAM)
567 
568 namespace detail
569 {
570  template <typename AsyncReadStream, typename Allocator,
571  typename CompletionCondition, typename ReadHandler>
573  : detail::base_from_completion_cond<CompletionCondition>
574  {
575  public:
576  read_streambuf_op(AsyncReadStream& stream,
578  CompletionCondition completion_condition, ReadHandler& handler)
579  : detail::base_from_completion_cond<
580  CompletionCondition>(completion_condition),
581  stream_(stream),
582  streambuf_(streambuf),
583  start_(0),
585  handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
586  {
587  }
588 
589 #if defined(ASIO_HAS_MOVE)
592  stream_(other.stream_),
593  streambuf_(other.streambuf_),
594  start_(other.start_),
596  handler_(other.handler_)
597  {
598  }
599 
602  stream_(other.stream_),
603  streambuf_(other.streambuf_),
604  start_(other.start_),
606  handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
607  {
608  }
609 #endif // defined(ASIO_HAS_MOVE)
610 
611  void operator()(const asio::error_code& ec,
612  std::size_t bytes_transferred, int start = 0)
613  {
614  std::size_t max_size, bytes_available;
615  switch (start_ = start)
616  {
617  case 1:
618  max_size = this->check_for_completion(ec, total_transferred_);
619  bytes_available = read_size_helper(streambuf_, max_size);
620  for (;;)
621  {
622  stream_.async_read_some(streambuf_.prepare(bytes_available),
624  return; default:
625  total_transferred_ += bytes_transferred;
626  streambuf_.commit(bytes_transferred);
627  max_size = this->check_for_completion(ec, total_transferred_);
628  bytes_available = read_size_helper(streambuf_, max_size);
629  if ((!ec && bytes_transferred == 0) || bytes_available == 0)
630  break;
631  }
632 
633  handler_(ec, static_cast<const std::size_t&>(total_transferred_));
634  }
635  }
636 
637  //private:
638  AsyncReadStream& stream_;
640  int start_;
641  std::size_t total_transferred_;
642  ReadHandler handler_;
643  };
644 
645  template <typename AsyncReadStream, typename Allocator,
646  typename CompletionCondition, typename ReadHandler>
647  inline void* asio_handler_allocate(std::size_t size,
648  read_streambuf_op<AsyncReadStream, Allocator,
649  CompletionCondition, ReadHandler>* this_handler)
650  {
652  size, this_handler->handler_);
653  }
654 
655  template <typename AsyncReadStream, typename Allocator,
656  typename CompletionCondition, typename ReadHandler>
657  inline void asio_handler_deallocate(void* pointer, std::size_t size,
658  read_streambuf_op<AsyncReadStream, Allocator,
659  CompletionCondition, ReadHandler>* this_handler)
660  {
662  pointer, size, this_handler->handler_);
663  }
664 
665  template <typename AsyncReadStream, typename Allocator,
666  typename CompletionCondition, typename ReadHandler>
668  read_streambuf_op<AsyncReadStream, Allocator,
669  CompletionCondition, ReadHandler>* this_handler)
670  {
671  return this_handler->start_ == 0 ? true
673  this_handler->handler_);
674  }
675 
676  template <typename Function, typename AsyncReadStream,
677  typename Allocator, typename CompletionCondition, typename ReadHandler>
678  inline void asio_handler_invoke(Function& function,
679  read_streambuf_op<AsyncReadStream, Allocator,
680  CompletionCondition, ReadHandler>* this_handler)
681  {
683  function, this_handler->handler_);
684  }
685 
686  template <typename Function, typename AsyncReadStream,
687  typename Allocator, typename CompletionCondition, typename ReadHandler>
688  inline void asio_handler_invoke(const Function& function,
689  read_streambuf_op<AsyncReadStream, Allocator,
690  CompletionCondition, ReadHandler>* this_handler)
691  {
693  function, this_handler->handler_);
694  }
695 } // namespace detail
696 
697 template <typename AsyncReadStream, typename Allocator,
698  typename CompletionCondition, typename ReadHandler>
699 inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
700  void (asio::error_code, std::size_t))
701 async_read(AsyncReadStream& s,
703  CompletionCondition completion_condition,
704  ASIO_MOVE_ARG(ReadHandler) handler)
705 {
706  // If you get an error on the following line it means that your handler does
707  // not meet the documented type requirements for a ReadHandler.
708  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
709 
711  ReadHandler, void (asio::error_code, std::size_t)> init(
712  ASIO_MOVE_CAST(ReadHandler)(handler));
713 
714  detail::read_streambuf_op<AsyncReadStream, Allocator,
715  CompletionCondition, ASIO_HANDLER_TYPE(
716  ReadHandler, void (asio::error_code, std::size_t))>(
717  s, b, completion_condition, init.handler)(
718  asio::error_code(), 0, 1);
719 
720  return init.result.get();
721 }
722 
723 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
724 inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
725  void (asio::error_code, std::size_t))
726 async_read(AsyncReadStream& s,
728  ASIO_MOVE_ARG(ReadHandler) handler)
729 {
730  // If you get an error on the following line it means that your handler does
731  // not meet the documented type requirements for a ReadHandler.
732  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
733 
735  ReadHandler, void (asio::error_code, std::size_t)> init(
736  ASIO_MOVE_CAST(ReadHandler)(handler));
737 
738  detail::read_streambuf_op<AsyncReadStream, Allocator,
740  ReadHandler, void (asio::error_code, std::size_t))>(
741  s, b, transfer_all(), init.handler)(
742  asio::error_code(), 0, 1);
743 
744  return init.result.get();
745 }
746 
747 #endif // !defined(ASIO_NO_IOSTREAM)
748 
749 } // namespace asio
750 
752 
753 #endif // ASIO_IMPL_READ_HPP
void asio_handler_deallocate(void *pointer, std::size_t size, binder1< Handler, Arg1 > *this_handler)
read_op(AsyncReadStream &stream, const boost::array< Elem, 2 > &buffers, CompletionCondition completion_condition, ReadHandler &handler)
Definition: read.hpp:300
asio::detail::consuming_buffers< mutable_buffer, MutableBufferSequence > buffers_
Definition: read.hpp:212
void throw_error(const asio::error_code &err)
Definition: throw_error.hpp:31
SocketService & s
Definition: connect.hpp:521
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)
read_op(AsyncReadStream &stream, const asio::mutable_buffers_1 &buffers, CompletionCondition completion_condition, ReadHandler &handler)
Definition: read.hpp:225
AsyncReadStream & stream_
Definition: read.hpp:638
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_type prepare(std::size_t n)
STL namespace.
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
Definition: buffer.hpp:706
asio::basic_streambuf< Allocator > & streambuf_
Definition: read.hpp:639
detail::transfer_all_t transfer_all()
asio::basic_streambuf< Allocator > & b
Definition: read.hpp:702
std::size_t total_transferred_
Definition: read.hpp:214
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.
Definition: buffer.hpp:357
void invoke(Function &function, Context &context)
const MutableBufferSequence & buffers
Definition: read.hpp:521
void commit(std::size_t n)
Move characters from the output sequence to the input sequence.
#define ASIO_READ_HANDLER_CHECK(handler_type, handler)
ReadHandler handler_
Definition: read.hpp:215
read_op(AsyncReadStream &stream, const MutableBufferSequence &buffers, CompletionCondition completion_condition, ReadHandler &handler)
Definition: read.hpp:151
Holds a buffer that can be modified.
Definition: buffer.hpp:91
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
Definition: read.hpp:185
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
Definition: read.hpp:334
AsyncReadStream & stream_
Definition: read.hpp:210
void asio_handler_invoke(Function &function, binder1< Handler, Arg1 > *this_handler)
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
bool is_continuation(Context &context)
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
Definition: read.hpp:260
std::size_t read(SyncReadStream &s, const MutableBufferSequence &buffers, CompletionCondition completion_condition, asio::error_code &ec)
Attempt to read a certain amount of data from a stream before returning.
Definition: read.hpp:39
Class to represent an error code value.
Definition: error_code.hpp:80
void deallocate(void *p, std::size_t s, Handler &h)
std::size_t read_size_helper(basic_streambuf< Allocator > &sb, std::size_t max_size)
std::size_t adapt_completion_condition_result(bool result)
Automatically resizable buffer class based on std::streambuf.
std::size_t total_transferred_
Definition: read.hpp:641
void * allocate(std::size_t s, Handler &h)
const MutableBufferSequence CompletionCondition completion_condition
Definition: read.hpp:521
handler_type< Handler, Signature >::type handler
read_streambuf_op(AsyncReadStream &stream, basic_streambuf< Allocator > &streambuf, CompletionCondition completion_condition, ReadHandler &handler)
Definition: read.hpp:576
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
async_result< typename handler_type< Handler, Signature >::type > result
void operator()(const asio::error_code &ec, std::size_t bytes_transferred, int start=0)
Definition: read.hpp:611
bool asio_handler_is_continuation(binder1< Handler, Arg1 > *this_handler)