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