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