$search
00001 // 00002 // basic_stream_handle.hpp 00003 // ~~~~~~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP 00012 #define ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP 00013 00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 00015 # pragma once 00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 00017 00018 #include "asio/detail/push_options.hpp" 00019 00020 #include "asio/detail/push_options.hpp" 00021 #include <cstddef> 00022 #include <boost/config.hpp> 00023 #include "asio/detail/pop_options.hpp" 00024 00025 #include "asio/error.hpp" 00026 #include "asio/windows/basic_handle.hpp" 00027 #include "asio/windows/stream_handle_service.hpp" 00028 #include "asio/detail/throw_error.hpp" 00029 00030 #if defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) \ 00031 || defined(GENERATING_DOCUMENTATION) 00032 00033 namespace asio { 00034 namespace windows { 00035 00037 00048 template <typename StreamHandleService = stream_handle_service> 00049 class basic_stream_handle 00050 : public basic_handle<StreamHandleService> 00051 { 00052 public: 00054 typedef typename StreamHandleService::native_type native_type; 00055 00057 00065 explicit basic_stream_handle(asio::io_service& io_service) 00066 : basic_handle<StreamHandleService>(io_service) 00067 { 00068 } 00069 00071 00082 basic_stream_handle(asio::io_service& io_service, 00083 const native_type& native_handle) 00084 : basic_handle<StreamHandleService>(io_service, native_handle) 00085 { 00086 } 00087 00089 00115 template <typename ConstBufferSequence> 00116 std::size_t write_some(const ConstBufferSequence& buffers) 00117 { 00118 asio::error_code ec; 00119 std::size_t s = this->service.write_some(this->implementation, buffers, ec); 00120 asio::detail::throw_error(ec); 00121 return s; 00122 } 00123 00125 00140 template <typename ConstBufferSequence> 00141 std::size_t write_some(const ConstBufferSequence& buffers, 00142 asio::error_code& ec) 00143 { 00144 return this->service.write_some(this->implementation, buffers, ec); 00145 } 00146 00148 00182 template <typename ConstBufferSequence, typename WriteHandler> 00183 void async_write_some(const ConstBufferSequence& buffers, 00184 WriteHandler handler) 00185 { 00186 this->service.async_write_some(this->implementation, buffers, handler); 00187 } 00188 00190 00217 template <typename MutableBufferSequence> 00218 std::size_t read_some(const MutableBufferSequence& buffers) 00219 { 00220 asio::error_code ec; 00221 std::size_t s = this->service.read_some(this->implementation, buffers, ec); 00222 asio::detail::throw_error(ec); 00223 return s; 00224 } 00225 00227 00243 template <typename MutableBufferSequence> 00244 std::size_t read_some(const MutableBufferSequence& buffers, 00245 asio::error_code& ec) 00246 { 00247 return this->service.read_some(this->implementation, buffers, ec); 00248 } 00249 00251 00286 template <typename MutableBufferSequence, typename ReadHandler> 00287 void async_read_some(const MutableBufferSequence& buffers, 00288 ReadHandler handler) 00289 { 00290 this->service.async_read_some(this->implementation, buffers, handler); 00291 } 00292 }; 00293 00294 } // namespace windows 00295 } // namespace asio 00296 00297 #endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) 00298 // || defined(GENERATING_DOCUMENTATION) 00299 00300 #include "asio/detail/pop_options.hpp" 00301 00302 #endif // ASIO_WINDOWS_BASIC_STREAM_HANDLE_HPP