00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
00024 #define _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
00025
00026 #ifndef _STLP_INTERNAL_STREAMBUF
00027 # include <stl/_streambuf.h>
00028 #endif
00029
00030 _STLP_BEGIN_NAMESPACE
00031
00032 template <class _CharT, class _Traits>
00033 extern basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_ostreambuf(basic_ostream<_CharT, _Traits>& ) ;
00034
00035
00036 template<class _CharT, class _Traits>
00037 class ostreambuf_iterator
00038 {
00039 public:
00040 typedef _CharT char_type;
00041 typedef _Traits traits_type;
00042 typedef typename _Traits::int_type int_type;
00043 typedef basic_streambuf<_CharT, _Traits> streambuf_type;
00044 typedef basic_ostream<_CharT, _Traits> ostream_type;
00045
00046 typedef output_iterator_tag iterator_category;
00047 typedef void value_type;
00048 typedef void difference_type;
00049 typedef void pointer;
00050 typedef void reference;
00051
00052 public:
00053 ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
00054
00055 inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW;
00056
00057 ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
00058 _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
00059 traits_type::eof());
00060 return *this;
00061 }
00062
00063 ostreambuf_iterator<_CharT, _Traits>& operator*() { return *this; }
00064 ostreambuf_iterator<_CharT, _Traits>& operator++() { return *this; }
00065 ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
00066
00067 bool failed() const { return !_M_ok; }
00068
00069 private:
00070 streambuf_type* _M_buf;
00071 bool _M_ok;
00072 };
00073
00074 template <class _CharT, class _Traits>
00075 inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) _STLP_NOTHROW : _M_buf(_M_get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
00076
00077 # if defined (_STLP_USE_TEMPLATE_EXPORT)
00078 _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<char, char_traits<char> >;
00079 # if defined (INSTANTIATE_WIDE_STREAMS)
00080 _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<wchar_t, char_traits<wchar_t> >;
00081 # endif
00082 # endif
00083
00084 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
00085 template <class _CharT, class _Traits>
00086 inline output_iterator_tag _STLP_CALL
00087 iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); }
00088 # endif
00089
00090 _STLP_END_NAMESPACE
00091
00092 #endif
00093
00094
00095
00096
00097