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