williamr@2: /* williamr@2: * Copyright (c) 1999 williamr@2: * Silicon Graphics Computer Systems, Inc. williamr@2: * williamr@4: * Copyright (c) 1999 williamr@2: * Boris Fomitchev williamr@2: * williamr@2: * This material is provided "as is", with absolutely no warranty expressed williamr@2: * or implied. Any use is at your own risk. williamr@2: * williamr@4: * Permission to use or copy this software for any purpose is hereby granted williamr@2: * without fee, provided the above notices are retained on all copies. williamr@2: * Permission to modify the code and to distribute modified code is granted, williamr@2: * provided the above notices are retained, and a notice that the code was williamr@2: * modified is included with the above copyright notice. williamr@2: * williamr@4: */ williamr@2: // WARNING: This is an internal header file, included by other C++ williamr@2: // standard library headers. You should not attempt to use this header williamr@2: // file directly. williamr@2: williamr@2: williamr@2: #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H williamr@2: #define _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H williamr@2: williamr@2: #ifndef _STLP_INTERNAL_STREAMBUF williamr@2: # include williamr@2: #endif williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: williamr@4: _STLP_MOVE_TO_PRIV_NAMESPACE williamr@4: williamr@4: template williamr@4: extern basic_streambuf<_CharT, _Traits>* _STLP_CALL __get_ostreambuf(basic_ostream<_CharT, _Traits>&); williamr@4: williamr@4: _STLP_MOVE_TO_STD_NAMESPACE williamr@2: williamr@2: // The default template argument is declared in iosfwd williamr@4: template williamr@4: class ostreambuf_iterator : williamr@4: public iterator { williamr@2: public: williamr@2: typedef _CharT char_type; williamr@2: typedef _Traits traits_type; williamr@2: typedef typename _Traits::int_type int_type; williamr@2: typedef basic_streambuf<_CharT, _Traits> streambuf_type; williamr@2: typedef basic_ostream<_CharT, _Traits> ostream_type; williamr@2: williamr@2: typedef output_iterator_tag iterator_category; williamr@2: typedef void value_type; williamr@2: typedef void difference_type; williamr@2: typedef void pointer; williamr@2: typedef void reference; williamr@2: williamr@2: public: williamr@2: ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {} williamr@4: // ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(__get_ostreambuf(__o)), _M_ok(_M_buf != 0) {} williamr@2: inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW; williamr@2: williamr@2: ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) { williamr@2: _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c), williamr@2: traits_type::eof()); williamr@2: return *this; williamr@4: } williamr@4: williamr@2: ostreambuf_iterator<_CharT, _Traits>& operator*() { return *this; } williamr@2: ostreambuf_iterator<_CharT, _Traits>& operator++() { return *this; } williamr@2: ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; } williamr@2: williamr@2: bool failed() const { return !_M_ok; } williamr@2: williamr@2: private: williamr@2: streambuf_type* _M_buf; williamr@2: bool _M_ok; williamr@2: }; williamr@2: williamr@2: template williamr@4: inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) _STLP_NOTHROW williamr@4: : _M_buf(_STLP_PRIV __get_ostreambuf(__o)), _M_ok(_M_buf != 0) {} williamr@2: williamr@4: #if defined (_STLP_USE_TEMPLATE_EXPORT) williamr@2: _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator >; williamr@2: # if defined (INSTANTIATE_WIDE_STREAMS) williamr@2: _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator >; williamr@2: # endif williamr@4: #endif /* _STLP_USE_TEMPLATE_EXPORT */ williamr@2: williamr@4: #if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) williamr@2: template williamr@4: inline output_iterator_tag _STLP_CALL williamr@2: iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); } williamr@4: #endif williamr@2: williamr@2: _STLP_END_NAMESPACE williamr@2: williamr@2: #endif /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */ williamr@2: williamr@2: // Local Variables: williamr@2: // mode:C++ williamr@2: // End: williamr@2: