]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/spirit/home/karma/stream/detail/iterator_sink.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / spirit / home / karma / stream / detail / iterator_sink.hpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boist.org/LICENSE_1_0.txt)
5
6 #if !defined(BOOST_SPIRIT_ITERATOR_SINK_MAY_27_2007_0133PM)
7 #define BOOST_SPIRIT_ITERATOR_SINK_MAY_27_2007_0133PM
8
9 #if defined(_MSC_VER)
10 #pragma once
11 #endif
12
13 #include <boost/iostreams/stream.hpp>
14 #include <boost/spirit/home/karma/detail/generate_to.hpp>
15
16 ///////////////////////////////////////////////////////////////////////////////
17 namespace boost { namespace spirit { namespace karma { namespace detail
18 {
19 ///////////////////////////////////////////////////////////////////////////
20 template <
21 typename OutputIterator, typename Char, typename CharEncoding
22 , typename Tag
23 >
24 struct iterator_sink
25 {
26 typedef boost::iostreams::sink_tag category;
27 typedef Char char_type;
28
29 iterator_sink (OutputIterator& sink_)
30 : sink(sink_)
31 {}
32
33 // Write up to n characters from the buffer s to the output sequence,
34 // returning the number of characters written
35 std::streamsize write (Char const* s, std::streamsize n)
36 {
37 std::streamsize bytes_written = 0;
38 while (n--) {
39 if (!generate_to(sink, *s, CharEncoding(), Tag()))
40 break;
41 ++s; ++bytes_written;
42 }
43 return bytes_written;
44 }
45
46 OutputIterator& sink;
47
48 private:
49 // silence MSVC warning C4512: assignment operator could not be generated
50 iterator_sink& operator= (iterator_sink const&);
51 };
52
53 }}}}
54
55 #endif