File indexing completed on 2025-01-18 09:38:49
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED
0010
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif
0014
0015 #include <boost/config.hpp> // member template friends.
0016 #include <boost/core/typeinfo.hpp>
0017 #include <boost/iostreams/detail/char_traits.hpp>
0018 #include <boost/iostreams/detail/ios.hpp> // openmode.
0019 #include <boost/iostreams/detail/streambuf.hpp>
0020
0021
0022 #include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
0023
0024 namespace boost { namespace iostreams { namespace detail {
0025
0026 template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
0027 class chain_base;
0028
0029 template<typename Chain, typename Access, typename Mode> class chainbuf;
0030
0031 #define BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base) \
0032 using base::eback; using base::gptr; using base::egptr; \
0033 using base::setg; using base::gbump; using base::pbase; \
0034 using base::pptr; using base::epptr; using base::setp; \
0035 using base::pbump; using base::underflow; using base::pbackfail; \
0036 using base::xsgetn; using base::overflow; using base::xsputn; \
0037 using base::sync; using base::seekoff; using base::seekpos; \
0038
0039
0040 template<typename Ch, typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch) >
0041 class linked_streambuf : public BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) {
0042 protected:
0043 linked_streambuf() : flags_(0) { }
0044 void set_true_eof(bool eof)
0045 {
0046 flags_ = (flags_ & ~f_true_eof) | (eof ? f_true_eof : 0);
0047 }
0048 public:
0049
0050
0051
0052 bool true_eof() const { return (flags_ & f_true_eof) != 0; }
0053 protected:
0054
0055
0056
0057 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0058 template< typename Self, typename ChT, typename TrT,
0059 typename Alloc, typename Mode >
0060 friend class chain_base;
0061 template<typename Chain, typename Mode, typename Access>
0062 friend class chainbuf;
0063 template<typename U>
0064 friend class member_close_operation;
0065 #else
0066 public:
0067 typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) base;
0068 BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base)
0069 #endif
0070 void close(BOOST_IOS::openmode which)
0071 {
0072 if ( which == BOOST_IOS::in &&
0073 (flags_ & f_input_closed) == 0 )
0074 {
0075 flags_ |= f_input_closed;
0076 close_impl(which);
0077 }
0078 if ( which == BOOST_IOS::out &&
0079 (flags_ & f_output_closed) == 0 )
0080 {
0081 flags_ |= f_output_closed;
0082 close_impl(which);
0083 }
0084 }
0085 void set_needs_close()
0086 {
0087 flags_ &= ~(f_input_closed | f_output_closed);
0088 }
0089 virtual void set_next(linked_streambuf<Ch, Tr>* ) { }
0090 virtual void close_impl(BOOST_IOS::openmode) = 0;
0091 virtual bool auto_close() const = 0;
0092 virtual void set_auto_close(bool) = 0;
0093 virtual bool strict_sync() = 0;
0094 virtual const boost::core::typeinfo& component_type() const = 0;
0095 virtual void* component_impl() = 0;
0096 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0097 private:
0098 #else
0099 public:
0100 #endif
0101 private:
0102 enum flag_type {
0103 f_true_eof = 1,
0104 f_input_closed = f_true_eof << 1,
0105 f_output_closed = f_input_closed << 1
0106 };
0107 int flags_;
0108 };
0109
0110 } } }
0111
0112 #include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
0113
0114 #endif