1 | // (C) Copyright Jonathan Turkanis 2003. |
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) |
---|
4 | |
---|
5 | // See http://www.boost.org/libs/iostreams for documentation. |
---|
6 | |
---|
7 | #ifndef BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED |
---|
8 | #define BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED |
---|
9 | |
---|
10 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
---|
11 | # pragma once |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <typeinfo> |
---|
15 | #include <boost/config.hpp> // member template friends. |
---|
16 | #include <boost/iostreams/detail/char_traits.hpp> |
---|
17 | #include <boost/iostreams/detail/ios.hpp> // openmode. |
---|
18 | #include <boost/iostreams/detail/streambuf.hpp> |
---|
19 | |
---|
20 | // Must come last. |
---|
21 | #include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC. |
---|
22 | |
---|
23 | namespace boost { namespace iostreams { namespace detail { |
---|
24 | |
---|
25 | template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode> |
---|
26 | class chain_base; |
---|
27 | |
---|
28 | template<typename Chain, typename Access, typename Mode> class chainbuf; |
---|
29 | |
---|
30 | #define BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base) \ |
---|
31 | using base::eback; using base::gptr; using base::egptr; \ |
---|
32 | using base::setg; using base::gbump; using base::pbase; \ |
---|
33 | using base::pptr; using base::epptr; using base::setp; \ |
---|
34 | using base::pbump; using base::underflow; using base::pbackfail; \ |
---|
35 | using base::xsgetn; using base::overflow; using base::sputc; \ |
---|
36 | using base::xsputn; using base::sync; using base::seekoff; \ |
---|
37 | using base::seekpos; \ |
---|
38 | /**/ |
---|
39 | |
---|
40 | template<typename Ch, typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch) > |
---|
41 | class linked_streambuf : public BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) { |
---|
42 | protected: |
---|
43 | linked_streambuf() : true_eof_(false) { } |
---|
44 | void set_true_eof(bool eof) { true_eof_ = eof; } |
---|
45 | public: |
---|
46 | |
---|
47 | // Should be called only after receiving an ordinary EOF indication, |
---|
48 | // to confirm that it represents EOF rather than WOULD_BLOCK. |
---|
49 | bool true_eof() const { return true_eof_; } |
---|
50 | protected: |
---|
51 | |
---|
52 | //----------grant friendship to chain_base and chainbuf-------------------// |
---|
53 | |
---|
54 | #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS |
---|
55 | template< typename Self, typename ChT, typename TrT, |
---|
56 | typename Alloc, typename Mode > |
---|
57 | friend class chain_base; |
---|
58 | template<typename Chain, typename Mode, typename Access> |
---|
59 | friend class chainbuf; |
---|
60 | #else |
---|
61 | public: |
---|
62 | typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(Ch, Tr) base; |
---|
63 | BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base) |
---|
64 | #endif |
---|
65 | virtual void set_next(linked_streambuf<Ch, Tr>* /* next */) { } |
---|
66 | virtual void close(BOOST_IOS::openmode) = 0; |
---|
67 | virtual bool auto_close() const = 0; |
---|
68 | virtual void set_auto_close(bool) = 0; |
---|
69 | virtual bool strict_sync() = 0; |
---|
70 | virtual const std::type_info& component_type() const = 0; |
---|
71 | virtual void* component_impl() = 0; |
---|
72 | private: |
---|
73 | bool true_eof_; |
---|
74 | }; |
---|
75 | |
---|
76 | } } } // End namespaces detail, iostreams, boost. |
---|
77 | |
---|
78 | #include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC. |
---|
79 | |
---|
80 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_LINKED_STREAMBUF_HPP_INCLUDED |
---|