File indexing completed on 2025-01-18 09:38:48
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
0010
0011 #include <boost/iostreams/detail/broken_overload_resolution/forward.hpp>
0012 #include <boost/throw_exception.hpp>
0013
0014 namespace boost { namespace iostreams {
0015
0016 template< typename T,
0017 typename Tr =
0018 BOOST_IOSTREAMS_CHAR_TRAITS(
0019 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
0020 ),
0021 typename Alloc =
0022 std::allocator<
0023 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
0024 >,
0025 typename Mode = BOOST_DEDUCED_TYPENAME mode_of<T>::type >
0026 class stream_buffer
0027 : public detail::stream_buffer_traits<T, Tr, Alloc, Mode>::type
0028 {
0029 private:
0030 BOOST_STATIC_ASSERT((
0031 is_convertible<
0032 BOOST_DEDUCED_TYPENAME iostreams::category_of<T>::type, Mode
0033 >::value
0034 ));
0035 typedef typename
0036 detail::stream_buffer_traits<
0037 T, Tr, Alloc, Mode
0038 >::type base_type;
0039 public:
0040 typedef typename char_type_of<T>::type char_type;
0041 struct category
0042 : Mode,
0043 closable_tag,
0044 streambuf_tag
0045 { };
0046 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
0047 stream_buffer() { }
0048 ~stream_buffer()
0049 {
0050 try {
0051 if (this->is_open() && this->auto_close())
0052 this->close();
0053 } catch (...) { }
0054 }
0055 template<typename U0>
0056 stream_buffer(const U0& u0)
0057 {
0058 open_impl(detail::forward<T, U0>(), u0);
0059 }
0060 template<typename U0, typename U1>
0061 stream_buffer(const U0& u0, const U1& u1)
0062 {
0063 open_impl(detail::forward<T, U0>(), u0, u1);
0064 }
0065 template<typename U0, typename U1, typename U2>
0066 stream_buffer(const U0& u0, const U1& u1, const U2& u2)
0067 {
0068 open_impl(detail::forward<T, U0>(), u0, u1, u2);
0069 }
0070 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
0071 template<typename U0>
0072 stream_buffer(U0& u0)
0073 {
0074 open_impl(detail::forward<T, U0>(), u0);
0075 }
0076 template<typename U0, typename U1>
0077 stream_buffer(U0& u0, const U1& u1)
0078 {
0079 open_impl(detail::forward<T, U0>(), u0, u1);
0080 }
0081 template<typename U0, typename U1, typename U2>
0082 stream_buffer(U0& u0, const U1& u1, const U2& u2)
0083 {
0084 open_impl(detail::forward<T, U0>(), u0, u1, u2);
0085 }
0086 #endif
0087 template<typename U0>
0088 void open(const U0& u0)
0089 {
0090 open_impl(detail::forward<T, U0>(), u0);
0091 }
0092 template<typename U0, typename U1>
0093 void open(const U0& u0, const U1& u1)
0094 {
0095 open_impl(detail::forward<T, U0>(), u0, u1);
0096 }
0097 template<typename U0, typename U1, typename U2>
0098 void open(const U0& u0, const U1& u1, const U2& u2)
0099 {
0100 open_impl(detail::forward<T, U0>(), u0, u1, u2);
0101 }
0102 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
0103 template<typename U0>
0104 void open(U0& u0)
0105 {
0106 open_impl(detail::forward<T, U0>(), u0);
0107 }
0108 template<typename U0, typename U1>
0109 void open(U0& u0, const U1& u1)
0110 {
0111 open_impl(detail::forward<T, U0>(), u0, u1);
0112 }
0113 template<typename U0, typename U1, typename U2>
0114 void open(U0& u0, const U1& u1, const U2& u2)
0115 {
0116 open_impl(detail::forward<T, U0>(), u0, u1, u2);
0117 }
0118 #endif
0119 T& operator*() { return *this->component(); }
0120 T* operator->() { return this->component(); }
0121 private:
0122 template<typename U0>
0123 void open_impl(mpl::false_, const U0& u0)
0124 {
0125 base_type::open(const_cast<U0&>(u0), -1, -1);
0126 }
0127 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
0128 template<typename U0>
0129 void open_impl(mpl::false_, U0& u0)
0130 {
0131 base_type::open(detail::wrap(u0), -1, -1);
0132 }
0133 #endif
0134 template<typename U0>
0135 void open_impl(mpl::true_, const U0& u0)
0136 {
0137 base_type::open(T(const_cast<U0&>(u0)), -1, -1);
0138 }
0139 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
0140 template<typename U0>
0141 void open_impl(mpl::true_, U0& u0)
0142 {
0143 base_type::open(T(u0), -1, -1);
0144 }
0145 #endif
0146 template<typename U0, typename U1>
0147 void open_impl(mpl::false_, const U0& u0, const U1& u1)
0148 {
0149 base_type::open(u0, u1, -1);
0150 }
0151 template<typename U0, typename U1>
0152 void open_impl(mpl::true_, const U0& u0, const U1& u1)
0153 {
0154 base_type::open(T(const_cast<U0&>(u0), u1), -1, -1);
0155 }
0156 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
0157 template<typename U0, typename U1>
0158 void open_impl(mpl::true_, U0& u0, const U1& u1)
0159 {
0160 base_type::open(T(u0, u1), -1, -1);
0161 }
0162 #endif
0163 template<typename U0, typename U1, typename U2>
0164 void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2)
0165 {
0166 base_type::open(u0, u1, u2);
0167 }
0168 template<typename U0, typename U1, typename U2>
0169 void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2)
0170 {
0171 base_type::open(T(const_cast<U0&>(u0), u1, u2), -1, -1);
0172 }
0173 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
0174 template<typename U0, typename U1, typename U2>
0175 void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2)
0176 {
0177 base_type::open(T(u0, u1, u2), -1, -1);
0178 }
0179 #endif
0180 void check_open()
0181 {
0182 if (this->is_open())
0183 boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open"));
0184 }
0185 };
0186
0187 } }
0188
0189 #endif