Realistic 3D camera system
3D camera system components
basic_stream_handle.hpp
Go to the documentation of this file.
1 //
2 // windows/basic_stream_handle.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_WINDOWS_BASIC_STREAM_HANDLE_HPP
12 #define ASIO_WINDOWS_BASIC_STREAM_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 "asio/detail/config.hpp"
19 
20 #if defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <cstddef>
26 #include "asio/error.hpp"
29 
31 
32 namespace asio {
33 namespace windows {
34 
36 
47 template <typename StreamHandleService = stream_handle_service>
48 class basic_stream_handle
49  : public basic_handle<StreamHandleService>
50 {
51 public:
54  typedef typename StreamHandleService::native_handle_type native_type;
55 
57  typedef typename StreamHandleService::native_handle_type native_handle_type;
58 
60 
68  explicit basic_stream_handle(asio::io_service& io_service)
69  : basic_handle<StreamHandleService>(io_service)
70  {
71  }
72 
74 
85  basic_stream_handle(asio::io_service& io_service,
86  const native_handle_type& handle)
87  : basic_handle<StreamHandleService>(io_service, handle)
88  {
89  }
90 
91 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
92 
102  basic_stream_handle(basic_stream_handle&& other)
103  : basic_handle<StreamHandleService>(
104  ASIO_MOVE_CAST(basic_stream_handle)(other))
105  {
106  }
107 
109 
119  basic_stream_handle& operator=(basic_stream_handle&& other)
120  {
121  basic_handle<StreamHandleService>::operator=(
122  ASIO_MOVE_CAST(basic_stream_handle)(other));
123  return *this;
124  }
125 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
126 
128 
154  template <typename ConstBufferSequence>
155  std::size_t write_some(const ConstBufferSequence& buffers)
156  {
157  asio::error_code ec;
158  std::size_t s = this->get_service().write_some(
159  this->get_implementation(), buffers, ec);
160  asio::detail::throw_error(ec, "write_some");
161  return s;
162  }
163 
165 
180  template <typename ConstBufferSequence>
181  std::size_t write_some(const ConstBufferSequence& buffers,
182  asio::error_code& ec)
183  {
184  return this->get_service().write_some(
185  this->get_implementation(), buffers, ec);
186  }
187 
189 
223  template <typename ConstBufferSequence, typename WriteHandler>
224  ASIO_INITFN_RESULT_TYPE(WriteHandler,
225  void (asio::error_code, std::size_t))
226  async_write_some(const ConstBufferSequence& buffers,
227  ASIO_MOVE_ARG(WriteHandler) handler)
228  {
229  // If you get an error on the following line it means that your handler does
230  // not meet the documented type requirements for a WriteHandler.
231  ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
232 
233  return this->get_service().async_write_some(this->get_implementation(),
234  buffers, ASIO_MOVE_CAST(WriteHandler)(handler));
235  }
236 
238 
265  template <typename MutableBufferSequence>
266  std::size_t read_some(const MutableBufferSequence& buffers)
267  {
268  asio::error_code ec;
269  std::size_t s = this->get_service().read_some(
270  this->get_implementation(), buffers, ec);
271  asio::detail::throw_error(ec, "read_some");
272  return s;
273  }
274 
276 
292  template <typename MutableBufferSequence>
293  std::size_t read_some(const MutableBufferSequence& buffers,
294  asio::error_code& ec)
295  {
296  return this->get_service().read_some(
297  this->get_implementation(), buffers, ec);
298  }
299 
301 
336  template <typename MutableBufferSequence, typename ReadHandler>
337  ASIO_INITFN_RESULT_TYPE(ReadHandler,
338  void (asio::error_code, std::size_t))
339  async_read_some(const MutableBufferSequence& buffers,
340  ASIO_MOVE_ARG(ReadHandler) handler)
341  {
342  // If you get an error on the following line it means that your handler does
343  // not meet the documented type requirements for a ReadHandler.
344  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
345 
346  return this->get_service().async_read_some(this->get_implementation(),
347  buffers, ASIO_MOVE_CAST(ReadHandler)(handler));
348  }
349 };
350 
351 } // namespace windows
352 } // namespace asio
353 
354 #include "asio/detail/pop_options.hpp"
355 
356 #endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
357  // || defined(GENERATING_DOCUMENTATION)
358 
359 #endif // ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP
void throw_error(const asio::error_code &err)
Definition: throw_error.hpp:31
Provides core I/O functionality.
Definition: io_service.hpp:184
SocketService & s
Definition: connect.hpp:521
STL namespace.
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
const MutableBufferSequence & buffers
Definition: read.hpp:521
#define ASIO_READ_HANDLER_CHECK(handler_type, handler)
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
Class to represent an error code value.
Definition: error_code.hpp:80
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
#define ASIO_WRITE_HANDLER_CHECK(handler_type, handler)