1 #ifndef BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
2 #define BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // istream_iterator.hpp
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 // note: this is a custom version of the standard istream_iterator.
20 // This is necessary as the standard version doesn't work as expected
21 // for wchar_t based streams on systems for which wchar_t not a true
22 // type but rather a synonym for some integer type.
24 #include <cstddef> // NULL
26 #include <boost/iterator/iterator_facade.hpp>
32 // given a type, make an input iterator based on a pointer to that type
33 template<class Elem = char>
34 class istream_iterator :
35 public boost::iterator_facade<
36 istream_iterator<Elem>,
38 std::input_iterator_tag,
42 friend class boost::iterator_core_access;
43 typedef istream_iterator this_t ;
44 typedef typename boost::iterator_facade<
45 istream_iterator<Elem>,
47 std::input_iterator_tag,
50 typedef typename std::basic_istream<Elem> istream_type;
52 bool equal(const this_t & rhs) const {
53 // note: only works for comparison against end of stream
54 return m_istream == rhs.m_istream;
57 //Access the value referred to
58 Elem dereference() const {
59 return m_istream->peek();
63 if(NULL != m_istream){
68 istream_type *m_istream;
71 istream_iterator(istream_type & is) :
81 istream_iterator(const istream_iterator<Elem> & rhs) :
82 m_istream(rhs.m_istream),
83 m_current_value(rhs.m_current_value)
88 } // namespace iterators
89 } // namespace archive
92 #endif // BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP