annotate DEPENDENCIES/generic/include/boost/archive/iterators/ostream_iterator.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 #ifndef BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
Chris@16 2 #define BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
Chris@16 3
Chris@16 4 // MS compatible compilers support #pragma once
Chris@101 5 #if defined(_MSC_VER)
Chris@16 6 # pragma once
Chris@16 7 #endif
Chris@16 8
Chris@16 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
Chris@16 10 // ostream_iterator.hpp
Chris@16 11
Chris@16 12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
Chris@16 13 // Use, modification and distribution is subject to the Boost Software
Chris@16 14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 15 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 16
Chris@16 17 // See http://www.boost.org for updates, documentation, and revision history.
Chris@16 18
Chris@16 19 // note: this is a custom version of the standard ostream_iterator.
Chris@16 20 // This is necessary as the standard version doesn't work as expected
Chris@16 21 // for wchar_t based streams on systems for which wchar_t not a true
Chris@16 22 // type but rather a synonym for some integer type.
Chris@16 23
Chris@16 24 #include <ostream>
Chris@16 25 #include <boost/iterator/iterator_facade.hpp>
Chris@16 26
Chris@16 27 namespace boost {
Chris@16 28 namespace archive {
Chris@16 29 namespace iterators {
Chris@16 30
Chris@16 31 // given a type, make an input iterator based on a pointer to that type
Chris@16 32 template<class Elem>
Chris@16 33 class ostream_iterator :
Chris@16 34 public boost::iterator_facade<
Chris@16 35 ostream_iterator<Elem>,
Chris@16 36 Elem,
Chris@16 37 std::output_iterator_tag,
Chris@16 38 ostream_iterator<Elem> &
Chris@16 39 >
Chris@16 40 {
Chris@16 41 friend class boost::iterator_core_access;
Chris@16 42 typedef ostream_iterator this_t ;
Chris@16 43 typedef Elem char_type;
Chris@16 44 typedef std::basic_ostream<char_type> ostream_type;
Chris@16 45
Chris@16 46 //emulate the behavior of std::ostream
Chris@16 47 ostream_iterator & dereference() const {
Chris@16 48 return const_cast<ostream_iterator &>(*this);
Chris@16 49 }
Chris@16 50 bool equal(const this_t & rhs) const {
Chris@16 51 return m_ostream == rhs.m_ostream;
Chris@16 52 }
Chris@16 53 void increment(){}
Chris@16 54 protected:
Chris@16 55 ostream_type *m_ostream;
Chris@16 56 void put_val(char_type e){
Chris@16 57 if(NULL != m_ostream){
Chris@16 58 m_ostream->put(e);
Chris@16 59 if(! m_ostream->good())
Chris@16 60 m_ostream = NULL;
Chris@16 61 }
Chris@16 62 }
Chris@16 63 public:
Chris@16 64 this_t & operator=(char_type c){
Chris@16 65 put_val(c);
Chris@16 66 return *this;
Chris@16 67 }
Chris@16 68 ostream_iterator(ostream_type & os) :
Chris@16 69 m_ostream (& os)
Chris@16 70 {}
Chris@16 71 ostream_iterator() :
Chris@16 72 m_ostream (NULL)
Chris@16 73 {}
Chris@16 74 ostream_iterator(const ostream_iterator & rhs) :
Chris@16 75 m_ostream (rhs.m_ostream)
Chris@16 76 {}
Chris@16 77 };
Chris@16 78
Chris@16 79 } // namespace iterators
Chris@16 80 } // namespace archive
Chris@16 81 } // namespace boost
Chris@16 82
Chris@16 83 #endif // BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP