epoc32/include/stdapis/stlport/stl/_streambuf_iterator.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 0 061f57f2323e
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  *
     3  * Copyright (c) 1994
     4  * Hewlett-Packard Company
     5  *
     6  * Copyright (c) 1996-1998
     7  * Silicon Graphics Computer Systems, Inc.
     8  *
     9  * Copyright (c) 1997
    10  * Moscow Center for SPARC Technology
    11  *
    12  * Copyright (c) 1999 
    13  * Boris Fomitchev
    14  *
    15  * This material is provided "as is", with absolutely no warranty expressed
    16  * or implied. Any use is at your own risk.
    17  *
    18  * Permission to use or copy this software for any purpose is hereby granted 
    19  * without fee, provided the above notices are retained on all copies.
    20  * Permission to modify the code and to distribute modified code is granted,
    21  * provided the above notices are retained, and a notice that the code was
    22  * modified is included with the above copyright notice.
    23  *
    24  */
    25 
    26 /* NOTE: This is an internal header file, included by other STL headers.
    27  *   You should not attempt to use it directly.
    28  */
    29 
    30 #if !defined (_STLP_INTERNAL_STREAMBUF_ITERATOR_H)
    31 #define _STLP_INTERNAL_STREAMBUF_ITERATOR_H
    32 
    33 _STLP_BEGIN_NAMESPACE
    34 
    35 template <class _CharT, class _Traits>
    36 basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_ostreambuf(basic_ostream<_CharT, _Traits>& ) ;
    37 
    38 // The default template argument is declared in iosfwd
    39 template<class _CharT, class _Traits>
    40 class ostreambuf_iterator
    41 {
    42 public:
    43   typedef _CharT                           char_type;
    44   typedef _Traits                          traits_type;
    45   typedef typename _Traits::int_type       int_type;
    46   typedef basic_streambuf<_CharT, _Traits> streambuf_type;
    47   typedef basic_ostream<_CharT, _Traits>   ostream_type;
    48 
    49   typedef output_iterator_tag              iterator_category;
    50   typedef void                             value_type;
    51   typedef void                             difference_type;
    52   typedef void                             pointer;
    53   typedef void                             reference;
    54 
    55 public:
    56   ostreambuf_iterator(streambuf_type* __buf) _STLP_NOTHROW : _M_buf(__buf), _M_ok(__buf!=0) {}
    57   ostreambuf_iterator(ostream_type& __o) _STLP_NOTHROW : _M_buf(_M_get_ostreambuf(__o)), _M_ok(_M_buf != 0) {}
    58 
    59   ostreambuf_iterator<_CharT, _Traits>& operator=(char_type __c) {
    60     _M_ok = _M_ok && !traits_type::eq_int_type(_M_buf->sputc(__c),
    61                                                traits_type::eof());
    62     return *this;
    63   }    
    64   
    65   ostreambuf_iterator<_CharT, _Traits>& operator*()     { return *this; }
    66   ostreambuf_iterator<_CharT, _Traits>& operator++()    { return *this; }
    67   ostreambuf_iterator<_CharT, _Traits>& operator++(int) { return *this; }
    68 
    69   bool failed() const { return !_M_ok; }
    70 
    71 private:
    72   streambuf_type* _M_buf;
    73   bool _M_ok;
    74 };
    75 
    76 _STLP_END_NAMESPACE
    77 
    78 #endif /* _STLP_INTERNAL_STREAMBUF_ITERATOR_H */
    79 
    80 // Local Variables:
    81 // mode:C++
    82 // End:
    83