$search
00001 // 00002 // basic_stream_descriptor.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_POSIX_BASIC_STREAM_DESCRIPTOR_HPP 00012 #define ASIO_POSIX_BASIC_STREAM_DESCRIPTOR_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/posix/basic_descriptor.hpp" 00027 #include "asio/posix/stream_descriptor_service.hpp" 00028 #include "asio/detail/throw_error.hpp" 00029 00030 #if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \ 00031 || defined(GENERATING_DOCUMENTATION) 00032 00033 namespace asio { 00034 namespace posix { 00035 00037 00048 template <typename StreamDescriptorService = stream_descriptor_service> 00049 class basic_stream_descriptor 00050 : public basic_descriptor<StreamDescriptorService> 00051 { 00052 public: 00054 typedef typename StreamDescriptorService::native_type native_type; 00055 00057 00066 explicit basic_stream_descriptor(asio::io_service& io_service) 00067 : basic_descriptor<StreamDescriptorService>(io_service) 00068 { 00069 } 00070 00072 00084 basic_stream_descriptor(asio::io_service& io_service, 00085 const native_type& native_descriptor) 00086 : basic_descriptor<StreamDescriptorService>(io_service, native_descriptor) 00087 { 00088 } 00089 00091 00117 template <typename ConstBufferSequence> 00118 std::size_t write_some(const ConstBufferSequence& buffers) 00119 { 00120 asio::error_code ec; 00121 std::size_t s = this->service.write_some(this->implementation, buffers, ec); 00122 asio::detail::throw_error(ec); 00123 return s; 00124 } 00125 00127 00142 template <typename ConstBufferSequence> 00143 std::size_t write_some(const ConstBufferSequence& buffers, 00144 asio::error_code& ec) 00145 { 00146 return this->service.write_some(this->implementation, buffers, ec); 00147 } 00148 00150 00184 template <typename ConstBufferSequence, typename WriteHandler> 00185 void async_write_some(const ConstBufferSequence& buffers, 00186 WriteHandler handler) 00187 { 00188 this->service.async_write_some(this->implementation, buffers, handler); 00189 } 00190 00192 00219 template <typename MutableBufferSequence> 00220 std::size_t read_some(const MutableBufferSequence& buffers) 00221 { 00222 asio::error_code ec; 00223 std::size_t s = this->service.read_some(this->implementation, buffers, ec); 00224 asio::detail::throw_error(ec); 00225 return s; 00226 } 00227 00229 00245 template <typename MutableBufferSequence> 00246 std::size_t read_some(const MutableBufferSequence& buffers, 00247 asio::error_code& ec) 00248 { 00249 return this->service.read_some(this->implementation, buffers, ec); 00250 } 00251 00253 00288 template <typename MutableBufferSequence, typename ReadHandler> 00289 void async_read_some(const MutableBufferSequence& buffers, 00290 ReadHandler handler) 00291 { 00292 this->service.async_read_some(this->implementation, buffers, handler); 00293 } 00294 }; 00295 00296 } // namespace posix 00297 } // namespace asio 00298 00299 #endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) 00300 // || defined(GENERATING_DOCUMENTATION) 00301 00302 #include "asio/detail/pop_options.hpp" 00303 00304 #endif // ASIO_POSIX_BASIC_STREAM_DESCRIPTOR_HPP