1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2 // (C) Copyright 2003-2007 Jonathan Turkanis
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
6 // See http://www.boost.org/libs/iostreams for documentation.
8 #ifndef BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED
11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
15 #include <memory> // allocator.
16 #include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME.
17 #include <boost/iostreams/detail/char_traits.hpp>
18 #include <boost/iostreams/detail/config/overload_resolution.hpp>
19 #include <boost/iostreams/detail/forward.hpp>
20 #include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
21 #include <boost/iostreams/detail/streambuf/direct_streambuf.hpp>
22 #include <boost/iostreams/detail/streambuf/indirect_streambuf.hpp>
23 #include <boost/iostreams/traits.hpp>
24 #include <boost/static_assert.hpp>
25 #include <boost/type_traits/is_convertible.hpp>
28 #include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
30 namespace boost
{ namespace iostreams
{ namespace detail
{
32 template<typename T
, typename Tr
, typename Alloc
, typename Mode
>
33 struct stream_buffer_traits
{
37 BOOST_DEDUCED_TYPENAME category_of
<T
>::type
,
40 direct_streambuf
<T
, Tr
>,
41 indirect_streambuf
<T
, Tr
, Alloc
, Mode
>
45 } } } // End namespaces detail, iostreams, boost
47 #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
48 # include <boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp>
51 namespace boost
{ namespace iostreams
{
55 BOOST_IOSTREAMS_CHAR_TRAITS(
56 BOOST_DEDUCED_TYPENAME char_type_of
<T
>::type
60 BOOST_DEDUCED_TYPENAME char_type_of
<T
>::type
62 typename Mode
= BOOST_DEDUCED_TYPENAME mode_of
<T
>::type
>
64 : public detail::stream_buffer_traits
<T
, Tr
, Alloc
, Mode
>::type
69 BOOST_DEDUCED_TYPENAME
iostreams::category_of
<T
>::type
, Mode
73 detail::stream_buffer_traits
<
77 typedef typename char_type_of
<T
>::type char_type
;
83 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr
)
89 if (this->is_open() && this->auto_close())
93 BOOST_IOSTREAMS_FORWARD( stream_buffer
, open_impl
, T
,
94 BOOST_IOSTREAMS_PUSH_PARAMS
,
95 BOOST_IOSTREAMS_PUSH_ARGS
)
96 T
& operator*() { return *this->component(); }
97 T
* operator->() { return this->component(); }
99 void open_impl(const T
& t
BOOST_IOSTREAMS_PUSH_PARAMS())
100 { // Used for forwarding.
102 BOOST_IOSTREAMS_FAILURE("already open");
103 base_type::open(t
BOOST_IOSTREAMS_PUSH_ARGS());
107 } } // End namespaces iostreams, boost.
109 #endif // #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
111 #include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
113 #endif // #ifndef BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED