epoc32/include/tools/stlport/stl/_ios.c
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
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@4
     1
/*
williamr@4
     2
 * Copyright (c) 1999
williamr@4
     3
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     4
 *
williamr@4
     5
 * Copyright (c) 1999
williamr@4
     6
 * Boris Fomitchev
williamr@4
     7
 *
williamr@4
     8
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
     9
 * or implied. Any use is at your own risk.
williamr@4
    10
 *
williamr@4
    11
 * Permission to use or copy this software for any purpose is hereby granted
williamr@4
    12
 * without fee, provided the above notices are retained on all copies.
williamr@4
    13
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    14
 * provided the above notices are retained, and a notice that the code was
williamr@4
    15
 * modified is included with the above copyright notice.
williamr@4
    16
 *
williamr@4
    17
 */
williamr@4
    18
#ifndef _STLP_IOS_C
williamr@4
    19
#define _STLP_IOS_C
williamr@4
    20
williamr@4
    21
#ifndef _STLP_INTERNAL_IOS_H
williamr@4
    22
# include <stl/_ios.h>
williamr@4
    23
#endif
williamr@4
    24
williamr@4
    25
#ifndef _STLP_INTERNAL_STREAMBUF
williamr@4
    26
# include <stl/_streambuf.h>
williamr@4
    27
#endif
williamr@4
    28
williamr@4
    29
#ifndef _STLP_INTERNAL_NUMPUNCT_H
williamr@4
    30
# include <stl/_numpunct.h>
williamr@4
    31
#endif
williamr@4
    32
williamr@4
    33
_STLP_BEGIN_NAMESPACE
williamr@4
    34
williamr@4
    35
// basic_ios<>'s non-inline member functions
williamr@4
    36
williamr@4
    37
// Public constructor, taking a streambuf.
williamr@4
    38
template <class _CharT, class _Traits>
williamr@4
    39
basic_ios<_CharT, _Traits>
williamr@4
    40
  ::basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf)
williamr@4
    41
    : ios_base(),
williamr@4
    42
      _M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0) {
williamr@4
    43
  basic_ios<_CharT, _Traits>::init(__streambuf);
williamr@4
    44
}
williamr@4
    45
williamr@4
    46
template <class _CharT, class _Traits>
williamr@4
    47
basic_streambuf<_CharT, _Traits>*
williamr@4
    48
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __buf) {
williamr@4
    49
  basic_streambuf<_CharT, _Traits>* __tmp = _M_streambuf;
williamr@4
    50
  _M_streambuf = __buf;
williamr@4
    51
  this->clear();
williamr@4
    52
  return __tmp;
williamr@4
    53
}
williamr@4
    54
williamr@4
    55
template <class _CharT, class _Traits>
williamr@4
    56
basic_ios<_CharT, _Traits>&
williamr@4
    57
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios<_CharT, _Traits>& __x) {
williamr@4
    58
  _M_invoke_callbacks(erase_event);
williamr@4
    59
  _M_copy_state(__x);           // Inherited from ios_base.
williamr@4
    60
  _M_fill = __x._M_fill;
williamr@4
    61
  _M_tied_ostream = __x._M_tied_ostream;
williamr@4
    62
  _M_invoke_callbacks(copyfmt_event);
williamr@4
    63
  this->_M_set_exception_mask(__x.exceptions());
williamr@4
    64
  return *this;
williamr@4
    65
}
williamr@4
    66
williamr@4
    67
template <class _CharT, class _Traits>
williamr@4
    68
locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) {
williamr@4
    69
  locale __tmp = ios_base::imbue(__loc);
williamr@4
    70
  _STLP_TRY {
williamr@4
    71
    if (_M_streambuf)
williamr@4
    72
      _M_streambuf->pubimbue(__loc);
williamr@4
    73
williamr@4
    74
    // no throwing here
williamr@4
    75
    this->_M_cached_ctype = __loc._M_get_facet(ctype<char_type>::id);
williamr@4
    76
    this->_M_cached_numpunct = __loc._M_get_facet(numpunct<char_type>::id);
williamr@4
    77
    this->_M_cached_grouping = ((numpunct<char_type>*)_M_cached_numpunct)->grouping();
williamr@4
    78
  }
williamr@4
    79
  _STLP_CATCH_ALL {
williamr@4
    80
    __tmp = ios_base::imbue(__tmp);
williamr@4
    81
    _M_handle_exception(ios_base::failbit);
williamr@4
    82
  }
williamr@4
    83
  return __tmp;
williamr@4
    84
}
williamr@4
    85
williamr@4
    86
// Protected constructor and initialization functions. The default
williamr@4
    87
// constructor creates an uninitialized basic_ios, and init() initializes
williamr@4
    88
// all of the members to the values in Table 89 of the C++ standard.
williamr@4
    89
williamr@4
    90
template <class _CharT, class _Traits>
williamr@4
    91
basic_ios<_CharT, _Traits>::basic_ios()
williamr@4
    92
  : ios_base(),
williamr@4
    93
    _M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0)
williamr@4
    94
{}
williamr@4
    95
williamr@4
    96
template <class _CharT, class _Traits>
williamr@4
    97
void
williamr@4
    98
basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
williamr@4
    99
{
williamr@4
   100
  this->rdbuf(__sb);
williamr@4
   101
  this->imbue(locale());
williamr@4
   102
  this->tie(0);
williamr@4
   103
  this->_M_set_exception_mask(ios_base::goodbit);
williamr@4
   104
  this->_M_clear_nothrow(__sb != 0 ? ios_base::goodbit : ios_base::badbit);
williamr@4
   105
  ios_base::flags(ios_base::skipws | ios_base::dec);
williamr@4
   106
  ios_base::width(0);
williamr@4
   107
  ios_base::precision(6);
williamr@4
   108
  this->fill(widen(' '));
williamr@4
   109
  // We don't need to worry about any of the three arrays: they are
williamr@4
   110
  // initialized correctly in ios_base's constructor.
williamr@4
   111
}
williamr@4
   112
williamr@4
   113
// This is never called except from within a catch clause.
williamr@4
   114
template <class _CharT, class _Traits>
williamr@4
   115
void basic_ios<_CharT, _Traits>::_M_handle_exception(ios_base::iostate __flag)
williamr@4
   116
{
williamr@4
   117
  this->_M_setstate_nothrow(__flag);
williamr@4
   118
  if (this->_M_get_exception_mask() & __flag)
williamr@4
   119
    _STLP_RETHROW;
williamr@4
   120
}
williamr@4
   121
williamr@4
   122
_STLP_END_NAMESPACE
williamr@4
   123
williamr@4
   124
#endif /* _STLP_IOS_C */
williamr@4
   125
williamr@4
   126
// Local Variables:
williamr@4
   127
// mode:C++
williamr@4
   128
// End: