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