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.)
5 // See http://www.boost.org/libs/iostreams for documentation.
7 #ifndef BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED
8 #define BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED
10 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
15 #include <memory> // allocator.
16 #include <boost/iostreams/chain.hpp>
17 #include <boost/iostreams/detail/access_control.hpp>
18 #include <boost/iostreams/detail/char_traits.hpp>
19 #include <boost/iostreams/detail/push.hpp>
20 #include <boost/iostreams/detail/streambuf.hpp> // pubsync.
21 #include <boost/iostreams/detail/streambuf/chainbuf.hpp>
22 #include <boost/mpl/if.hpp>
24 namespace boost { namespace iostreams {
27 // Macro: BOOST_IOSTREAMS_DEFINE_FILTERBUF(name_, chain_type_, default_char_)
28 // Description: Defines a template derived from std::basic_streambuf which uses
29 // a chain to perform i/o. The template has the following parameters:
30 // Ch - The character type.
31 // Tr - The character traits type.
32 // Alloc - The allocator type.
33 // Access - Indicates accessibility of the chain interface; must be either
34 // public_ or protected_; defaults to public_.
36 #define BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(name_, chain_type_, default_char_) \
37 template< typename Mode, typename Ch = default_char_, \
38 typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
39 typename Alloc = std::allocator<Ch>, typename Access = public_ > \
40 class name_ : public boost::iostreams::detail::chainbuf< \
41 chain_type_<Mode, Ch, Tr, Alloc>, Mode, Access \
45 typedef Ch char_type; \
46 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
48 typedef chain_type_<Mode, Ch, Tr, Alloc> chain_type; \
50 BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name_, mode, Ch, push_impl) \
51 ~name_() { if (this->is_complete()) this->BOOST_IOSTREAMS_PUBSYNC(); } \
54 BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(filtering_streambuf, boost::iostreams::chain, char)
55 BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(filtering_wstreambuf, boost::iostreams::chain, wchar_t)
57 typedef filtering_streambuf<input> filtering_istreambuf;
58 typedef filtering_streambuf<output> filtering_ostreambuf;
59 typedef filtering_wstreambuf<input> filtering_wistreambuf;
60 typedef filtering_wstreambuf<output> filtering_wostreambuf;
62 } } // End namespaces iostreams, boost.
64 #endif // #ifndef BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED