williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 1999
|
williamr@4
|
3 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@4
|
4 |
*
|
williamr@4
|
5 |
* Copyright (c) 1999
|
williamr@4
|
6 |
* Boris Fomitchev
|
williamr@4
|
7 |
*
|
williamr@4
|
8 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@4
|
9 |
* or implied. Any use is at your own risk.
|
williamr@4
|
10 |
*
|
williamr@4
|
11 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@4
|
12 |
* without fee, provided the above notices are retained on all copies.
|
williamr@4
|
13 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@4
|
14 |
* provided the above notices are retained, and a notice that the code was
|
williamr@4
|
15 |
* modified is included with the above copyright notice.
|
williamr@4
|
16 |
*
|
williamr@4
|
17 |
*/
|
williamr@4
|
18 |
// WARNING: This is an internal header file, included by other C++
|
williamr@4
|
19 |
// standard library headers. You should not attempt to use this header
|
williamr@4
|
20 |
// file directly.
|
williamr@4
|
21 |
|
williamr@4
|
22 |
|
williamr@4
|
23 |
#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
williamr@4
|
24 |
#define _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
|
williamr@4
|
25 |
|
williamr@4
|
26 |
#ifndef _STLP_INTERNAL_STREAMBUF
|
williamr@4
|
27 |
# include <stl/_streambuf.h>
|
williamr@4
|
28 |
#endif
|
williamr@4
|
29 |
|
williamr@4
|
30 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
31 |
|
williamr@4
|
32 |
_STLP_MOVE_TO_PRIV_NAMESPACE
|
williamr@4
|
33 |
|
williamr@4
|
34 |
template<class _CharT, class _Traits>
|
williamr@4
|
35 |
extern basic_streambuf<_CharT, _Traits>* _STLP_CALL __get_ostreambuf(basic_ostream<_CharT, _Traits>&);
|
williamr@4
|
36 |
|
williamr@4
|
37 |
_STLP_MOVE_TO_STD_NAMESPACE
|
williamr@4
|
38 |
|
williamr@4
|
39 |
// The default template argument is declared in iosfwd
|
williamr@4
|
40 |
template <class _CharT, class _Traits>
|
williamr@4
|
41 |
class ostreambuf_iterator :
|
williamr@4
|
42 |
public iterator<output_iterator_tag, void, void, void, void> {
|
williamr@4
|
43 |
public:
|
williamr@4
|
44 |
typedef _CharT char_type;
|
williamr@4
|
45 |
typedef _Traits traits_type;
|
williamr@4
|
46 |
typedef typename _Traits::int_type int_type;
|
williamr@4
|
47 |
typedef basic_streambuf<_CharT, _Traits> streambuf_type;
|
williamr@4
|
48 |
typedef basic_ostream<_CharT, _Traits> ostream_type;
|
williamr@4
|
49 |
|
williamr@4
|
50 |
typedef output_iterator_tag iterator_category;
|
williamr@4
|
51 |
typedef void value_type;
|
williamr@4
|
52 |
typedef void difference_type;
|
williamr@4
|
53 |
typedef void pointer;
|
williamr@4
|
54 |
typedef void reference;
|
williamr@4
|
55 |
|
williamr@4
|
56 |
public:
|
williamr@4
|
57 |
ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
|
williamr@4
|
58 |
// ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(__get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
|
williamr@4
|
59 |
inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW;
|
williamr@4
|
60 |
|
williamr@4
|
61 |
ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
|
williamr@4
|
62 |
_M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
|
williamr@4
|
63 |
traits_type::eof());
|
williamr@4
|
64 |
return *this;
|
williamr@4
|
65 |
}
|
williamr@4
|
66 |
|
williamr@4
|
67 |
ostreambuf_iterator<_CharT, _Traits>& operator*() { return *this; }
|
williamr@4
|
68 |
ostreambuf_iterator<_CharT, _Traits>& operator++() { return *this; }
|
williamr@4
|
69 |
ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
|
williamr@4
|
70 |
|
williamr@4
|
71 |
bool failed() const { return !_M_ok; }
|
williamr@4
|
72 |
|
williamr@4
|
73 |
private:
|
williamr@4
|
74 |
streambuf_type* _M_buf;
|
williamr@4
|
75 |
bool _M_ok;
|
williamr@4
|
76 |
};
|
williamr@4
|
77 |
|
williamr@4
|
78 |
template <class _CharT, class _Traits>
|
williamr@4
|
79 |
inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) _STLP_NOTHROW
|
williamr@4
|
80 |
: _M_buf(_STLP_PRIV __get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
|
williamr@4
|
81 |
|
williamr@4
|
82 |
#if defined (_STLP_USE_TEMPLATE_EXPORT)
|
williamr@4
|
83 |
_STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<char, char_traits<char> >;
|
williamr@4
|
84 |
# if defined (INSTANTIATE_WIDE_STREAMS)
|
williamr@4
|
85 |
_STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<wchar_t, char_traits<wchar_t> >;
|
williamr@4
|
86 |
# endif
|
williamr@4
|
87 |
#endif /* _STLP_USE_TEMPLATE_EXPORT */
|
williamr@4
|
88 |
|
williamr@4
|
89 |
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
williamr@4
|
90 |
template <class _CharT, class _Traits>
|
williamr@4
|
91 |
inline output_iterator_tag _STLP_CALL
|
williamr@4
|
92 |
iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); }
|
williamr@4
|
93 |
#endif
|
williamr@4
|
94 |
|
williamr@4
|
95 |
_STLP_END_NAMESPACE
|
williamr@4
|
96 |
|
williamr@4
|
97 |
#endif /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */
|
williamr@4
|
98 |
|
williamr@4
|
99 |
// Local Variables:
|
williamr@4
|
100 |
// mode:C++
|
williamr@4
|
101 |
// End:
|
williamr@4
|
102 |
|