annotate DEPENDENCIES/generic/include/boost/iostreams/detail/streambuf/chainbuf.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
Chris@16 2 // (C) Copyright 2003-2007 Jonathan Turkanis
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 5
Chris@16 6 // See http://www.boost.org/libs/iostreams for documentation.
Chris@16 7
Chris@16 8 #ifndef BOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
Chris@16 9 #define BOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED
Chris@16 10
Chris@16 11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 12 # pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <boost/config.hpp> // BOOST_MSVC, template friends.
Chris@16 16 #include <boost/detail/workaround.hpp>
Chris@16 17 #include <boost/iostreams/chain.hpp>
Chris@16 18 #include <boost/iostreams/detail/access_control.hpp>
Chris@16 19 #include <boost/iostreams/detail/config/wide_streams.hpp>
Chris@16 20 #include <boost/iostreams/detail/streambuf.hpp>
Chris@16 21 #include <boost/iostreams/detail/streambuf/linked_streambuf.hpp>
Chris@16 22 #include <boost/iostreams/detail/translate_int_type.hpp>
Chris@16 23 #include <boost/iostreams/traits.hpp>
Chris@16 24 #include <boost/noncopyable.hpp>
Chris@16 25
Chris@16 26 namespace boost { namespace iostreams { namespace detail {
Chris@16 27
Chris@16 28 //--------------Definition of chainbuf----------------------------------------//
Chris@16 29
Chris@16 30 //
Chris@16 31 // Template name: chainbuf.
Chris@16 32 // Description: Stream buffer which operates by delegating to the first
Chris@16 33 // linked_streambuf in a chain.
Chris@16 34 // Template parameters:
Chris@16 35 // Chain - The chain type.
Chris@16 36 //
Chris@16 37 template<typename Chain, typename Mode, typename Access>
Chris@16 38 class chainbuf
Chris@16 39 : public BOOST_IOSTREAMS_BASIC_STREAMBUF(
Chris@16 40 typename Chain::char_type,
Chris@16 41 typename Chain::traits_type
Chris@16 42 ),
Chris@16 43 public access_control<typename Chain::client_type, Access>,
Chris@16 44 private noncopyable
Chris@16 45 {
Chris@16 46 private:
Chris@16 47 typedef access_control<chain_client<Chain>, Access> client_type;
Chris@16 48 public:
Chris@16 49 typedef typename Chain::char_type char_type;
Chris@16 50 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(typename Chain::traits_type)
Chris@16 51 protected:
Chris@16 52 typedef linked_streambuf<char_type, traits_type> delegate_type;
Chris@16 53 chainbuf() { client_type::set_chain(&chain_); }
Chris@16 54 int_type underflow()
Chris@16 55 { sentry t(this); return translate(delegate().underflow()); }
Chris@16 56 int_type pbackfail(int_type c)
Chris@16 57 { sentry t(this); return translate(delegate().pbackfail(c)); }
Chris@16 58 std::streamsize xsgetn(char_type* s, std::streamsize n)
Chris@16 59 { sentry t(this); return delegate().xsgetn(s, n); }
Chris@16 60 int_type overflow(int_type c)
Chris@16 61 { sentry t(this); return translate(delegate().overflow(c)); }
Chris@16 62 std::streamsize xsputn(const char_type* s, std::streamsize n)
Chris@16 63 { sentry t(this); return delegate().xsputn(s, n); }
Chris@16 64 int sync() { sentry t(this); return delegate().sync(); }
Chris@16 65 pos_type seekoff( off_type off, BOOST_IOS::seekdir way,
Chris@16 66 BOOST_IOS::openmode which =
Chris@16 67 BOOST_IOS::in | BOOST_IOS::out )
Chris@16 68 { sentry t(this); return delegate().seekoff(off, way, which); }
Chris@16 69 pos_type seekpos( pos_type sp,
Chris@16 70 BOOST_IOS::openmode which =
Chris@16 71 BOOST_IOS::in | BOOST_IOS::out )
Chris@16 72 { sentry t(this); return delegate().seekpos(sp, which); }
Chris@16 73 protected:
Chris@16 74 typedef BOOST_IOSTREAMS_BASIC_STREAMBUF(
Chris@16 75 typename Chain::char_type,
Chris@16 76 typename Chain::traits_type
Chris@16 77 ) base_type;
Chris@16 78 //#if !BOOST_WORKAROUND(__GNUC__, == 2)
Chris@16 79 // BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type)
Chris@16 80 //#endif
Chris@16 81 private:
Chris@16 82
Chris@16 83 // Translate from std int_type to chain's int_type.
Chris@16 84 typedef BOOST_IOSTREAMS_CHAR_TRAITS(char_type) std_traits;
Chris@16 85 typedef typename Chain::traits_type chain_traits;
Chris@16 86 static typename chain_traits::int_type
Chris@16 87 translate(typename std_traits::int_type c)
Chris@16 88 { return translate_int_type<std_traits, chain_traits>(c); }
Chris@16 89
Chris@16 90 delegate_type& delegate()
Chris@16 91 { return static_cast<delegate_type&>(chain_.front()); }
Chris@16 92 void get_pointers()
Chris@16 93 {
Chris@16 94 this->setg(delegate().eback(), delegate().gptr(), delegate().egptr());
Chris@16 95 this->setp(delegate().pbase(), delegate().epptr());
Chris@16 96 this->pbump((int) (delegate().pptr() - delegate().pbase()));
Chris@16 97 }
Chris@16 98 void set_pointers()
Chris@16 99 {
Chris@16 100 delegate().setg(this->eback(), this->gptr(), this->egptr());
Chris@16 101 delegate().setp(this->pbase(), this->epptr());
Chris@16 102 delegate().pbump((int) (this->pptr() - this->pbase()));
Chris@16 103 }
Chris@16 104 struct sentry {
Chris@16 105 sentry(chainbuf<Chain, Mode, Access>* buf) : buf_(buf)
Chris@16 106 { buf_->set_pointers(); }
Chris@16 107 ~sentry() { buf_->get_pointers(); }
Chris@16 108 chainbuf<Chain, Mode, Access>* buf_;
Chris@16 109 };
Chris@16 110 friend struct sentry;
Chris@16 111 Chain chain_;
Chris@16 112 };
Chris@16 113
Chris@16 114 } } } // End namespaces detail, iostreams, boost.
Chris@16 115
Chris@16 116 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CHAINBUF_HPP_INCLUDED