Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / iostreams / detail / adapter / filter_adapter.hpp
1 /*
2  * Defines the class template boost::iostreams::detail::filter_adapter,
3  * a convenience base class for filter adapters.
4  *
5  * File:        boost/iostreams/detail/adapter/filter_adapter.hpp
6  * Date:        Mon Nov 26 14:35:48 MST 2007
7  * Copyright:   2007-2008 CodeRage, LLC
8  * Author:      Jonathan Turkanis
9  * Contact:     turkanis at coderage dot com
10  *
11  * Distributed under the Boost Software License, Version 1.0.(See accompanying 
12  * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
13  * 
14  * See http://www.boost.org/libs/iostreams for documentation.
15  */
16
17 #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
18 #define BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
19
20 #include <boost/iostreams/categories.hpp>
21 #include <boost/iostreams/detail/call_traits.hpp>
22 #include <boost/iostreams/detail/ios.hpp>
23 #include <boost/iostreams/operations.hpp>
24 #include <boost/iostreams/traits.hpp>
25 #include <boost/static_assert.hpp>
26
27 namespace boost { namespace iostreams { namespace detail {
28
29 template<typename T>
30 class filter_adapter {
31 private:
32     typedef typename detail::value_type<T>::type value_type;
33     typedef typename detail::param_type<T>::type param_type;
34 public:
35     explicit filter_adapter(param_type t) : t_(t) { }
36     T& component() { return t_; }
37
38     template<typename Device>
39     void close(Device& dev) 
40     { 
41         detail::close_all(t_, dev); 
42     }
43
44     template<typename Device>
45     void close(Device& dev, BOOST_IOS::openmode which) 
46     { 
47         iostreams::close(t_, dev, which); 
48     }
49
50     template<typename Device>
51     void flush(Device& dev) 
52     { 
53         return iostreams::flush(t_, dev); 
54     }
55
56     template<typename Locale> // Avoid dependency on <locale>
57     void imbue(const Locale& loc) { iostreams::imbue(t_, loc); }
58
59     std::streamsize optimal_buffer_size() const 
60     { return iostreams::optimal_buffer_size(t_); }
61 public:
62     value_type t_;
63 };
64
65 //----------------------------------------------------------------------------//
66
67 } } } // End namespaces detail, iostreams, boost.
68
69 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED