Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / archive / iterators / ostream_iterator.hpp @ 2486

History | View | Annotate | Download (2.3 kB)

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