source: NonGTP/Boost/boost/iostreams/filtering_streambuf.hpp @ 857

Revision 857, 2.9 KB checked in by igarcia, 18 years ago (diff)
Line 
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_FILTERING_STREAMBUF_HPP_INCLUDED
8#define BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED
9
10#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma once
12#endif             
13
14#include <exception>
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>                   
23
24namespace boost { namespace iostreams {
25
26//
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_.
35//
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 \
42                         > \
43    { \
44    public: \
45        typedef Ch                                             char_type; \
46        BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
47        typedef Mode                                           mode; \
48        typedef chain_type_<Mode, Ch, Tr, Alloc>               chain_type; \
49        name_() { } \
50        BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name_, mode, Ch, push_impl) \
51        ~name_() { if (this->is_complete()) this->BOOST_IOSTREAMS_PUBSYNC(); } \
52    }; \
53    /**/
54BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(filtering_streambuf, boost::iostreams::chain, char)
55BOOST_IOSTREAMS_DEFINE_FILTER_STREAMBUF(filtering_wstreambuf, boost::iostreams::chain, wchar_t)
56
57typedef filtering_streambuf<input>    filtering_istreambuf;
58typedef filtering_streambuf<output>   filtering_ostreambuf;
59typedef filtering_wstreambuf<input>   filtering_wistreambuf;
60typedef filtering_wstreambuf<output>  filtering_wostreambuf;
61
62} } // End namespaces iostreams, boost.
63
64#endif // #ifndef BOOST_IOSTREAMS_FILTERING_STREAMBUF_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.