_ostreambuf_iterator.h

00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999 
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted 
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */ 
00018 // WARNING: This is an internal header file, included by other C++
00019 // standard library headers.  You should not attempt to use this header
00020 // file directly.
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 // The default template argument is declared in iosfwd
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   //  ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(_M_get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
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 /* _STLP_USE_TEMPLATE_EXPORT */
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 /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */
00093 
00094 // Local Variables:
00095 // mode:C++
00096 // End:
00097 

Generated on Mon Jun 5 10:20:46 2006 for Intelligence.kdevelop by  doxygen 1.4.6