Back to home page

EIC code displayed by LXR

 
 

    


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 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // istream_iterator.hpp
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 // note: this is a custom version of the standard istream_iterator.
0020 // This is necessary as the standard version doesn't work as expected
0021 // for wchar_t based streams on systems for which wchar_t not a true
0022 // type but rather a synonym for some integer type.
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 // given a type, make an input iterator based on a pointer to that type
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         // note: only  works for comparison against end of stream
0054         return m_istream == rhs.m_istream;
0055     }
0056 
0057     //Access the value referred to
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         //increment();
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 } // namespace iterators
0089 } // namespace archive
0090 } // namespace boost
0091 
0092 #endif // BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP