1 | // (C) Copyright Jonathan Turkanis 2005.
|
---|
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_DETAIL_BASIC_ADAPTER_HPP_INCLUDED
|
---|
8 | #define BOOST_IOSTREAMS_DETAIL_BASIC_ADAPTER_HPP_INCLUDED
|
---|
9 |
|
---|
10 | #include <boost/iostreams/categories.hpp>
|
---|
11 | #include <boost/iostreams/detail/call_traits.hpp>
|
---|
12 | #include <boost/iostreams/detail/ios.hpp>
|
---|
13 | #include <boost/iostreams/operations.hpp>
|
---|
14 | #include <boost/iostreams/traits.hpp>
|
---|
15 | #include <boost/static_assert.hpp>
|
---|
16 |
|
---|
17 | namespace boost { namespace iostreams { namespace detail {
|
---|
18 |
|
---|
19 | template<typename T>
|
---|
20 | class basic_adapter {
|
---|
21 | private:
|
---|
22 | typedef typename detail::value_type<T>::type value_type;
|
---|
23 | typedef typename detail::param_type<T>::type param_type;
|
---|
24 | public:
|
---|
25 | explicit basic_adapter(param_type t) : t_(t) { }
|
---|
26 | T& component() { return t_; }
|
---|
27 |
|
---|
28 | void close(BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out)
|
---|
29 | {
|
---|
30 | BOOST_STATIC_ASSERT(is_device<T>::value);
|
---|
31 | iostreams::close(t_, which);
|
---|
32 | }
|
---|
33 |
|
---|
34 | template<typename Device>
|
---|
35 | void close( Device& dev,
|
---|
36 | BOOST_IOS::openmode which =
|
---|
37 | BOOST_IOS::in | BOOST_IOS::out )
|
---|
38 | {
|
---|
39 | BOOST_STATIC_ASSERT(is_filter<T>::value);
|
---|
40 | iostreams::close(t_, dev, which);
|
---|
41 | }
|
---|
42 |
|
---|
43 | bool flush()
|
---|
44 | {
|
---|
45 | BOOST_STATIC_ASSERT(is_device<T>::value);
|
---|
46 | return iostreams::flush(t_);
|
---|
47 | }
|
---|
48 |
|
---|
49 | template<typename Device>
|
---|
50 | void flush(Device& dev)
|
---|
51 | {
|
---|
52 | BOOST_STATIC_ASSERT(is_filter<T>::value);
|
---|
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_BASIC_ADAPTER_HPP_INCLUDED
|
---|