/home/ntakagi/work/STLport-5.1.5/stlport/stl/_ostreambuf_iterator.h

Go to the documentation of this file.
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 _STLP_MOVE_TO_PRIV_NAMESPACE
00033 
00034 template<class _CharT, class _Traits>
00035 extern basic_streambuf<_CharT, _Traits>* _STLP_CALL __get_ostreambuf(basic_ostream<_CharT, _Traits>&);
00036 
00037 _STLP_MOVE_TO_STD_NAMESPACE
00038 
00039 // The default template argument is declared in iosfwd
00040 template <class _CharT, class _Traits>
00041 class ostreambuf_iterator :
00042   public iterator<output_iterator_tag, void, void, void, void> {
00043 public:
00044   typedef _CharT                           char_type;
00045   typedef _Traits                          traits_type;
00046   typedef typename _Traits::int_type       int_type;
00047   typedef basic_streambuf<_CharT, _Traits> streambuf_type;
00048   typedef basic_ostream<_CharT, _Traits>   ostream_type;
00049 
00050   typedef output_iterator_tag              iterator_category;
00051   typedef void                             value_type;
00052   typedef void                             difference_type;
00053   typedef void                             pointer;
00054   typedef void                             reference;
00055 
00056 public:
00057   ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
00058   //  ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(__get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
00059   inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW;
00060 
00061   ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
00062     _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
00063                                                traits_type::eof());
00064     return *this;
00065   }
00066 
00067   ostreambuf_iterator<_CharT, _Traits>& operator*()     { return *this; }
00068   ostreambuf_iterator<_CharT, _Traits>& operator++()    { return *this; }
00069   ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
00070 
00071   bool failed() const { return !_M_ok; }
00072 
00073 private:
00074   streambuf_type* _M_buf;
00075   bool _M_ok;
00076 };
00077 
00078 template <class _CharT, class _Traits>
00079 inline ostreambuf_iterator<_CharT, _Traits>::ostreambuf_iterator(basic_ostream<_CharT, _Traits>& __o) _STLP_NOTHROW
00080   : _M_buf(_STLP_PRIV __get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
00081 
00082 #if defined (_STLP_USE_TEMPLATE_EXPORT)
00083 _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<char, char_traits<char> >;
00084 #  if defined (INSTANTIATE_WIDE_STREAMS)
00085 _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<wchar_t, char_traits<wchar_t> >;
00086 #  endif
00087 #endif /* _STLP_USE_TEMPLATE_EXPORT */
00088 
00089 #if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
00090 template <class _CharT, class _Traits>
00091 inline output_iterator_tag _STLP_CALL
00092 iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); }
00093 #endif
00094 
00095 _STLP_END_NAMESPACE
00096 
00097 #endif /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */
00098 
00099 // Local Variables:
00100 // mode:C++
00101 // End:
00102 



Generated on Mon Mar 10 15:32:32 2008 by  doxygen 1.5.1