File indexing completed on 2025-01-18 09:38:54
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IOSTREAMS_STREAM_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_STREAM_HPP_INCLUDED
0010
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif
0014
0015 #include <boost/iostreams/constants.hpp>
0016 #include <boost/iostreams/detail/char_traits.hpp>
0017 #include <boost/iostreams/detail/config/overload_resolution.hpp>
0018 #include <boost/iostreams/detail/forward.hpp>
0019 #include <boost/iostreams/detail/iostream.hpp> // standard streams.
0020 #include <boost/iostreams/detail/select.hpp>
0021 #include <boost/iostreams/stream_buffer.hpp>
0022 #include <boost/mpl/and.hpp>
0023 #include <boost/type_traits/is_convertible.hpp>
0024 #include <boost/utility/base_from_member.hpp>
0025
0026 namespace boost { namespace iostreams { namespace detail {
0027
0028 template<typename Device, typename Tr>
0029 struct stream_traits {
0030 typedef typename char_type_of<Device>::type char_type;
0031 typedef Tr traits_type;
0032 typedef typename category_of<Device>::type mode;
0033 typedef typename
0034 iostreams::select<
0035 mpl::and_<
0036 is_convertible<mode, input>,
0037 is_convertible<mode, output>
0038 >,
0039 BOOST_IOSTREAMS_BASIC_IOSTREAM(char_type, traits_type),
0040 is_convertible<mode, input>,
0041 BOOST_IOSTREAMS_BASIC_ISTREAM(char_type, traits_type),
0042 else_,
0043 BOOST_IOSTREAMS_BASIC_OSTREAM(char_type, traits_type)
0044 >::type stream_type;
0045 typedef typename
0046 iostreams::select<
0047 mpl::and_<
0048 is_convertible<mode, input>,
0049 is_convertible<mode, output>
0050 >,
0051 iostream_tag,
0052 is_convertible<mode, input>,
0053 istream_tag,
0054 else_,
0055 ostream_tag
0056 >::type stream_tag;
0057 };
0058
0059 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0060 # pragma warning(push)
0061
0062 # pragma warning(disable: 4250)
0063 #endif
0064
0065
0066
0067
0068 template< typename Device,
0069 typename Tr =
0070 BOOST_IOSTREAMS_CHAR_TRAITS(
0071 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0072 ),
0073 typename Alloc =
0074 std::allocator<
0075 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0076 >,
0077 typename Base =
0078 BOOST_DEDUCED_TYPENAME
0079 detail::stream_traits<Device, Tr>::stream_type >
0080 class stream_base
0081 : protected base_from_member< stream_buffer<Device, Tr, Alloc> >,
0082 public Base
0083 {
0084 private:
0085 typedef base_from_member< stream_buffer<Device, Tr, Alloc> > pbase_type;
0086 typedef typename stream_traits<Device, Tr>::stream_type stream_type;
0087 protected:
0088 using pbase_type::member;
0089 public:
0090 stream_base() : pbase_type(), stream_type(&member) { }
0091 };
0092
0093 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0094 # pragma warning(pop)
0095 #endif
0096
0097 } } }
0098
0099 #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
0100 # include <boost/iostreams/detail/broken_overload_resolution/stream.hpp>
0101 #else
0102
0103 namespace boost { namespace iostreams {
0104
0105 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0106 # pragma warning(push)
0107
0108 # pragma warning(disable: 4250)
0109 #endif
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 template< typename Device,
0120 typename Tr =
0121 BOOST_IOSTREAMS_CHAR_TRAITS(
0122 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0123 ),
0124 typename Alloc =
0125 std::allocator<
0126 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0127 > >
0128 struct stream : detail::stream_base<Device, Tr, Alloc> {
0129 public:
0130 typedef typename char_type_of<Device>::type char_type;
0131 struct category
0132 : mode_of<Device>::type,
0133 closable_tag,
0134 detail::stream_traits<Device, Tr>::stream_tag
0135 { };
0136 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
0137 private:
0138 typedef typename
0139 detail::stream_traits<
0140 Device, Tr
0141 >::stream_type stream_type;
0142 public:
0143 stream() { }
0144 BOOST_IOSTREAMS_FORWARD( stream, open_impl, Device,
0145 BOOST_IOSTREAMS_PUSH_PARAMS,
0146 BOOST_IOSTREAMS_PUSH_ARGS )
0147 bool is_open() const { return this->member.is_open(); }
0148 void close() { this->member.close(); }
0149 bool auto_close() const { return this->member.auto_close(); }
0150 void set_auto_close(bool close) { this->member.set_auto_close(close); }
0151 bool strict_sync() { return this->member.strict_sync(); }
0152 Device& operator*() { return *this->member; }
0153 Device* operator->() { return &*this->member; }
0154 Device* component() { return this->member.component(); }
0155 private:
0156 void open_impl(const Device& dev BOOST_IOSTREAMS_PUSH_PARAMS())
0157 {
0158 this->clear();
0159 this->member.open(dev BOOST_IOSTREAMS_PUSH_ARGS());
0160 }
0161 };
0162
0163 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0164 # pragma warning(pop)
0165 #endif
0166
0167 } }
0168
0169 #endif
0170
0171 #endif