1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(BOOST_SPIRIT_ITERATOR_ISTREAM_MAY_05_2007_0110PM)
8 #define BOOST_SPIRIT_ITERATOR_ISTREAM_MAY_05_2007_0110PM
14 #include <boost/iostreams/stream.hpp>
15 #include <boost/detail/iterator.hpp>
17 ///////////////////////////////////////////////////////////////////////////////
18 namespace boost { namespace spirit { namespace qi { namespace detail
20 ///////////////////////////////////////////////////////////////////////////
21 template <typename Iterator>
22 struct iterator_source
25 boost::detail::iterator_traits<Iterator>::value_type
27 typedef boost::iostreams::seekable_device_tag category;
29 iterator_source (Iterator const& first_, Iterator const& last_)
30 : first(first_), last(last_), pos(0)
33 // Read up to n characters from the input sequence into the buffer s,
34 // returning the number of characters read, or -1 to indicate
36 std::streamsize read (char_type* s, std::streamsize n)
41 std::streamsize bytes_read = 0;
53 // Write is implemented only to satisfy the requirements of a
54 // boost::iostreams::seekable_device. We need to have see support to
55 // be able to figure out how many characters have been actually
56 // consumed by the stream.
57 std::streamsize write(const char_type*, std::streamsize)
59 BOOST_ASSERT(false); // not supported
63 std::streampos seek(boost::iostreams::stream_offset, std::ios_base::seekdir way)
65 BOOST_ASSERT(way == std::ios_base::cur); // only support queries
66 return pos; // return current position
74 // silence MSVC warning C4512: assignment operator could not be generated
75 iterator_source& operator= (iterator_source const&);