epoc32/include/stdapis/stlport/stl/_ostreambuf_iterator.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2  * Copyright (c) 1999
     3  * Silicon Graphics Computer Systems, Inc.
     4  *
     5  * Copyright (c) 1999 
     6  * Boris Fomitchev
     7  *
     8  * This material is provided "as is", with absolutely no warranty expressed
     9  * or implied. Any use is at your own risk.
    10  *
    11  * Permission to use or copy this software for any purpose is hereby granted 
    12  * without fee, provided the above notices are retained on all copies.
    13  * Permission to modify the code and to distribute modified code is granted,
    14  * provided the above notices are retained, and a notice that the code was
    15  * modified is included with the above copyright notice.
    16  *
    17  */ 
    18 // WARNING: This is an internal header file, included by other C++
    19 // standard library headers.  You should not attempt to use this header
    20 // file directly.
    21 
    22 
    23 #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
    24 #define _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
    25 
    26 #ifndef _STLP_INTERNAL_STREAMBUF
    27 # include <stl/_streambuf.h>
    28 #endif
    29 
    30 _STLP_BEGIN_NAMESPACE
    31 
    32 template <class _CharT, class _Traits>
    33 extern basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_ostreambuf(basic_ostream<_CharT, _Traits>& ) ;
    34 
    35 // The default template argument is declared in iosfwd
    36 template<class _CharT, class _Traits>
    37 class ostreambuf_iterator
    38 {
    39 public:
    40   typedef _CharT                           char_type;
    41   typedef _Traits                          traits_type;
    42   typedef typename _Traits::int_type       int_type;
    43   typedef basic_streambuf<_CharT, _Traits> streambuf_type;
    44   typedef basic_ostream<_CharT, _Traits>   ostream_type;
    45 
    46   typedef output_iterator_tag              iterator_category;
    47   typedef void                             value_type;
    48   typedef void                             difference_type;
    49   typedef void                             pointer;
    50   typedef void                             reference;
    51 
    52 public:
    53   ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
    54   //  ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(_M_get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
    55   inline ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW;
    56 
    57   ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
    58     _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
    59                                                traits_type::eof());
    60     return *this;
    61   }    
    62   
    63   ostreambuf_iterator<_CharT, _Traits>& operator*()     { return *this; }
    64   ostreambuf_iterator<_CharT, _Traits>& operator++()    { return *this; }
    65   ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
    66 
    67   bool failed() const { return !_M_ok; }
    68 
    69 private:
    70   streambuf_type* _M_buf;
    71   bool _M_ok;
    72 };
    73 
    74 template <class _CharT, class _Traits>
    75 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) {}
    76 
    77 # if defined (_STLP_USE_TEMPLATE_EXPORT)
    78 _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<char, char_traits<char> >;
    79 #  if defined (INSTANTIATE_WIDE_STREAMS)
    80 _STLP_EXPORT_TEMPLATE_CLASS ostreambuf_iterator<wchar_t, char_traits<wchar_t> >;
    81 #  endif
    82 # endif /* _STLP_USE_TEMPLATE_EXPORT */
    83 
    84 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
    85 template <class _CharT, class _Traits>
    86 inline output_iterator_tag _STLP_CALL 
    87 iterator_category(const ostreambuf_iterator<_CharT, _Traits>&) { return output_iterator_tag(); }
    88 # endif
    89 
    90 _STLP_END_NAMESPACE
    91 
    92 #endif /* _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H */
    93 
    94 // Local Variables:
    95 // mode:C++
    96 // End:
    97