File indexing completed on 2025-01-18 09:28:29
0001 #ifndef BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
0002 #define BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
0003
0004
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <cstddef> // NULL
0025 #include <istream>
0026 #include <boost/iterator/iterator_facade.hpp>
0027
0028 namespace boost {
0029 namespace archive {
0030 namespace iterators {
0031
0032
0033 template<class Elem = char>
0034 class istream_iterator :
0035 public boost::iterator_facade<
0036 istream_iterator<Elem>,
0037 Elem,
0038 std::input_iterator_tag,
0039 Elem
0040 >
0041 {
0042 friend class boost::iterator_core_access;
0043 typedef istream_iterator this_t ;
0044 typedef typename boost::iterator_facade<
0045 istream_iterator<Elem>,
0046 Elem,
0047 std::input_iterator_tag,
0048 Elem
0049 > super_t;
0050 typedef typename std::basic_istream<Elem> istream_type;
0051
0052 bool equal(const this_t & rhs) const {
0053
0054 return m_istream == rhs.m_istream;
0055 }
0056
0057
0058 Elem dereference() const {
0059 return static_cast<Elem>(m_istream->peek());
0060 }
0061
0062 void increment(){
0063 if(NULL != m_istream){
0064 m_istream->ignore(1);
0065 }
0066 }
0067
0068 istream_type *m_istream;
0069 Elem m_current_value;
0070 public:
0071 istream_iterator(istream_type & is) :
0072 m_istream(& is)
0073 {
0074
0075 }
0076
0077 istream_iterator() :
0078 m_istream(NULL),
0079 m_current_value(NULL)
0080 {}
0081
0082 istream_iterator(const istream_iterator<Elem> & rhs) :
0083 m_istream(rhs.m_istream),
0084 m_current_value(rhs.m_current_value)
0085 {}
0086 };
0087
0088 }
0089 }
0090 }
0091
0092 #endif