blob: fec4c45c1a5f9d861e81fb1238ab8d9e136b0f78 [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001/*
2 * Defines the class template ndnboost::iostreams::detail::filter_adapter,
3 * a convenience base class for filter adapters.
4 *
5 * File: ndnboost/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 NDNBOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
18#define NDNBOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED
19
20#include <ndnboost/iostreams/categories.hpp>
21#include <ndnboost/iostreams/detail/call_traits.hpp>
22#include <ndnboost/iostreams/detail/ios.hpp>
23#include <ndnboost/iostreams/operations.hpp>
24#include <ndnboost/iostreams/traits.hpp>
25#include <ndnboost/static_assert.hpp>
26
27namespace ndnboost { namespace iostreams { namespace detail {
28
29template<typename T>
30class filter_adapter {
31private:
32 typedef typename detail::value_type<T>::type value_type;
33 typedef typename detail::param_type<T>::type param_type;
34public:
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, NDNBOOST_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_); }
61public:
62 value_type t_;
63};
64
65//----------------------------------------------------------------------------//
66
67} } } // End namespaces detail, iostreams, boost.
68
69#endif // #ifndef NDNBOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED