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_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED
|
---|
8 | #define BOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED
|
---|
9 |
|
---|
10 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
---|
11 | # pragma once
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | #include <algorithm> // copy.
|
---|
15 | #include <iosfwd> // streamsize.
|
---|
16 | #include <boost/iostreams/categories.hpp> // tags.
|
---|
17 | #include <boost/static_assert.hpp>
|
---|
18 | #include <boost/type_traits/is_convertible.hpp>
|
---|
19 |
|
---|
20 | namespace boost { namespace iostreams { namespace detail {
|
---|
21 |
|
---|
22 | template<typename Mode, typename Ch, typename OutIt>
|
---|
23 | class output_iterator_adapter {
|
---|
24 | public:
|
---|
25 | BOOST_STATIC_ASSERT((is_convertible<Mode, output>::value));
|
---|
26 | typedef Ch char_type;
|
---|
27 | typedef sink_tag category;
|
---|
28 | explicit output_iterator_adapter(OutIt out) : out_(out) { }
|
---|
29 | std::streamsize write(const char_type* s, std::streamsize n)
|
---|
30 | {
|
---|
31 | std::copy(s, s + n, out_);
|
---|
32 | return n;
|
---|
33 | }
|
---|
34 | private:
|
---|
35 | OutIt out_;
|
---|
36 | };
|
---|
37 |
|
---|
38 | } } } // End namespaces detail, iostreams, boost.
|
---|
39 |
|
---|
40 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED //-----//
|
---|