File indexing completed on 2025-01-18 09:28:29
0001 #ifndef BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
0002 #define BOOST_ARCHIVE_ITERATORS_OSTREAM_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 <ostream>
0025 #include <boost/iterator/iterator_facade.hpp>
0026
0027 namespace boost {
0028 namespace archive {
0029 namespace iterators {
0030
0031
0032 template<class Elem>
0033 class ostream_iterator :
0034 public boost::iterator_facade<
0035 ostream_iterator<Elem>,
0036 Elem,
0037 std::output_iterator_tag,
0038 ostream_iterator<Elem> &
0039 >
0040 {
0041 friend class boost::iterator_core_access;
0042 typedef ostream_iterator this_t ;
0043 typedef Elem char_type;
0044 typedef std::basic_ostream<char_type> ostream_type;
0045
0046
0047 ostream_iterator & dereference() const {
0048 return const_cast<ostream_iterator &>(*this);
0049 }
0050 bool equal(const this_t & rhs) const {
0051 return m_ostream == rhs.m_ostream;
0052 }
0053 void increment(){}
0054 protected:
0055 ostream_type *m_ostream;
0056 void put_val(char_type e){
0057 if(NULL != m_ostream){
0058 m_ostream->put(e);
0059 if(! m_ostream->good())
0060 m_ostream = NULL;
0061 }
0062 }
0063 public:
0064 this_t & operator=(char_type c){
0065 put_val(c);
0066 return *this;
0067 }
0068 ostream_iterator(ostream_type & os) :
0069 m_ostream (& os)
0070 {}
0071 ostream_iterator() :
0072 m_ostream (NULL)
0073 {}
0074 ostream_iterator(const ostream_iterator & rhs) :
0075 m_ostream (rhs.m_ostream)
0076 {}
0077 };
0078
0079 }
0080 }
0081 }
0082
0083 #endif