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