Chris@16: // Chris@16: // basic_socket_iostream.hpp Chris@16: // ~~~~~~~~~~~~~~~~~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP Chris@16: #define BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) Chris@16: Chris@16: # include Chris@16: Chris@16: // A macro that should expand to: Chris@16: // template Chris@16: // explicit basic_socket_iostream(T1 x1, ..., Tn xn) Chris@16: // : std::basic_iostream( Chris@16: // &this->detail::socket_iostream_base< Chris@16: // Protocol, StreamSocketService, Time, Chris@16: // TimeTraits, TimerService>::streambuf_) Chris@16: // { Chris@16: // if (rdbuf()->connect(x1, ..., xn) == 0) Chris@16: // this->setstate(std::ios_base::failbit); Chris@16: // } Chris@16: // This macro should only persist within this file. Chris@16: Chris@16: # define BOOST_ASIO_PRIVATE_CTR_DEF(n) \ Chris@16: template \ Chris@16: explicit basic_socket_iostream(BOOST_ASIO_VARIADIC_PARAMS(n)) \ Chris@16: : std::basic_iostream( \ Chris@16: &this->detail::socket_iostream_base< \ Chris@16: Protocol, StreamSocketService, Time, \ Chris@16: TimeTraits, TimerService>::streambuf_) \ Chris@16: { \ Chris@16: this->setf(std::ios_base::unitbuf); \ Chris@16: if (rdbuf()->connect(BOOST_ASIO_VARIADIC_ARGS(n)) == 0) \ Chris@16: this->setstate(std::ios_base::failbit); \ Chris@16: } \ Chris@16: /**/ Chris@16: Chris@16: // A macro that should expand to: Chris@16: // template Chris@16: // void connect(T1 x1, ..., Tn xn) Chris@16: // { Chris@16: // if (rdbuf()->connect(x1, ..., xn) == 0) Chris@16: // this->setstate(std::ios_base::failbit); Chris@16: // } Chris@16: // This macro should only persist within this file. Chris@16: Chris@16: # define BOOST_ASIO_PRIVATE_CONNECT_DEF(n) \ Chris@16: template \ Chris@16: void connect(BOOST_ASIO_VARIADIC_PARAMS(n)) \ Chris@16: { \ Chris@16: if (rdbuf()->connect(BOOST_ASIO_VARIADIC_ARGS(n)) == 0) \ Chris@16: this->setstate(std::ios_base::failbit); \ Chris@16: } \ Chris@16: /**/ Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: namespace detail { Chris@16: Chris@16: // A separate base class is used to ensure that the streambuf is initialised Chris@16: // prior to the basic_socket_iostream's basic_iostream base class. Chris@16: template Chris@16: class socket_iostream_base Chris@16: { Chris@16: protected: Chris@16: basic_socket_streambuf streambuf_; Chris@16: }; Chris@16: Chris@16: } Chris@16: Chris@16: /// Iostream interface for a socket. Chris@16: template , Chris@16: #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \ Chris@16: || defined(GENERATING_DOCUMENTATION) Chris@16: typename Time = boost::posix_time::ptime, Chris@16: typename TimeTraits = boost::asio::time_traits