Chris@16: // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) Chris@16: // (C) Copyright 2003-2007 Jonathan Turkanis 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: // See http://www.boost.org/libs/iostreams for documentation. Chris@16: Chris@16: #ifndef BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED Chris@16: #define BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include // member template friends. Chris@16: #include Chris@16: #include // openmode. Chris@16: #include Chris@16: Chris@16: // Must come last. Chris@16: #include // MSVC. Chris@16: Chris@16: namespace boost { namespace iostreams { namespace detail { Chris@16: Chris@16: template Chris@16: class chain_base; Chris@16: Chris@16: template class chainbuf; Chris@16: Chris@16: #define BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base) \ Chris@16: using base::eback; using base::gptr; using base::egptr; \ Chris@16: using base::setg; using base::gbump; using base::pbase; \ Chris@16: using base::pptr; using base::epptr; using base::setp; \ Chris@16: using base::pbump; using base::underflow; using base::pbackfail; \ Chris@16: using base::xsgetn; using base::overflow; using base::xsputn; \ Chris@16: using base::sync; using base::seekoff; using base::seekpos; \ Chris@16: /**/ Chris@16: Chris@16: template Chris@16: class linked_streambuf : public BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) { Chris@16: protected: Chris@16: linked_streambuf() : flags_(0) { } Chris@16: void set_true_eof(bool eof) Chris@16: { Chris@16: flags_ = (flags_ & ~f_true_eof) | (eof ? f_true_eof : 0); Chris@16: } Chris@16: public: Chris@16: Chris@16: // Should be called only after receiving an ordinary EOF indication, Chris@16: // to confirm that it represents EOF rather than WOULD_BLOCK. Chris@16: bool true_eof() const { return (flags_ & f_true_eof) != 0; } Chris@16: protected: Chris@16: Chris@16: //----------grant friendship to chain_base and chainbuf-------------------// Chris@16: Chris@16: #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS Chris@16: template< typename Self, typename ChT, typename TrT, Chris@16: typename Alloc, typename Mode > Chris@16: friend class chain_base; Chris@16: template Chris@16: friend class chainbuf; Chris@16: template Chris@16: friend class member_close_operation; Chris@16: #else Chris@16: public: Chris@16: typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) base; Chris@16: BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base) Chris@16: #endif Chris@16: void close(BOOST_IOS::openmode which) Chris@16: { Chris@16: if ( which == BOOST_IOS::in && Chris@16: (flags_ & f_input_closed) == 0 ) Chris@16: { Chris@16: flags_ |= f_input_closed; Chris@16: close_impl(which); Chris@16: } Chris@16: if ( which == BOOST_IOS::out && Chris@16: (flags_ & f_output_closed) == 0 ) Chris@16: { Chris@16: flags_ |= f_output_closed; Chris@16: close_impl(which); Chris@16: } Chris@16: } Chris@16: void set_needs_close() Chris@16: { Chris@16: flags_ &= ~(f_input_closed | f_output_closed); Chris@16: } Chris@16: virtual void set_next(linked_streambuf* /* next */) { } Chris@16: virtual void close_impl(BOOST_IOS::openmode) = 0; Chris@16: virtual bool auto_close() const = 0; Chris@16: virtual void set_auto_close(bool) = 0; Chris@16: virtual bool strict_sync() = 0; Chris@16: virtual const std::type_info& component_type() const = 0; Chris@16: virtual void* component_impl() = 0; Chris@16: #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS Chris@16: private: Chris@16: #else Chris@16: public: Chris@16: #endif Chris@16: private: Chris@16: enum flag_type { Chris@16: f_true_eof = 1, Chris@16: f_input_closed = f_true_eof << 1, Chris@16: f_output_closed = f_input_closed << 1 Chris@16: }; Chris@16: int flags_; Chris@16: }; Chris@16: Chris@16: } } } // End namespaces detail, iostreams, boost. Chris@16: Chris@16: #include // MSVC. Chris@16: Chris@16: #endif // #ifndef BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED