_streambuf_iterator.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996-1998
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999 
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted 
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #if !defined (_STLP_INTERNAL_STREAMBUF_ITERATOR_H)
00031 #define _STLP_INTERNAL_STREAMBUF_ITERATOR_H
00032 
00033 _STLP_BEGIN_NAMESPACE
00034 
00035 template <class _CharT, class _Traits>
00036 basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_ostreambuf(basic_ostream<_CharT, _Traits>& ) ;
00037 
00038 // The default template argument is declared in iosfwd
00039 template<class _CharT, class _Traits>
00040 class ostreambuf_iterator
00041 {
00042 public:
00043   typedef _CharT                           char_type;
00044   typedef _Traits                          traits_type;
00045   typedef typename _Traits::int_type       int_type;
00046   typedef basic_streambuf<_CharT, _Traits> streambuf_type;
00047   typedef basic_ostream<_CharT, _Traits>   ostream_type;
00048 
00049   typedef output_iterator_tag              iterator_category;
00050   typedef void                             value_type;
00051   typedef void                             difference_type;
00052   typedef void                             pointer;
00053   typedef void                             reference;
00054 
00055 public:
00056   ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
00057   ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(_M_get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
00058 
00059   ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
00060     _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
00061                                                traits_type::eof());
00062     return *this;
00063   }    
00064   
00065   ostreambuf_iterator<_CharT, _Traits>& operator*()     { return *this; }
00066   ostreambuf_iterator<_CharT, _Traits>& operator++()    { return *this; }
00067   ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
00068 
00069   bool failed() const { return !_M_ok; }
00070 
00071 private:
00072   streambuf_type* _M_buf;
00073   bool _M_ok;
00074 };
00075 
00076 _STLP_END_NAMESPACE
00077 
00078 #endif /* _STLP_INTERNAL_STREAMBUF_ITERATOR_H */
00079 
00080 // Local Variables:
00081 // mode:C++
00082 // End:
00083 

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