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