williamr@2: /*
williamr@2:  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
williamr@2:  * Copyright (c) 1999
williamr@2:  * Silicon Graphics Computer Systems, Inc.
williamr@2:  *
williamr@2:  * Copyright (c) 1999 
williamr@2:  * Boris Fomitchev
williamr@2:  *
williamr@2:  * This material is provided "as is", with absolutely no warranty expressed
williamr@2:  * or implied. Any use is at your own risk.
williamr@2:  *
williamr@2:  * Permission to use or copy this software for any purpose is hereby granted 
williamr@2:  * without fee, provided the above notices are retained on all copies.
williamr@2:  * Permission to modify the code and to distribute modified code is granted,
williamr@2:  * provided the above notices are retained, and a notice that the code was
williamr@2:  * modified is included with the above copyright notice.
williamr@2:  *
williamr@2:  */ 
williamr@2: #ifndef _STLP_IOS_C
williamr@2: #define _STLP_IOS_C
williamr@2: 
williamr@2: #ifndef _STLP_INTERNAL_IOS_H
williamr@2: # include <stl/_ios.h>
williamr@2: #endif
williamr@2: 
williamr@2: #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
williamr@2: 
williamr@2: #ifndef _STLP_INTERNAL_STREAMBUF
williamr@2: # include <stl/_streambuf.h>
williamr@2: #endif
williamr@2: 
williamr@2: #ifndef _STLP_INTERNAL_NUMPUNCT_H
williamr@2: # include <stl/_numpunct.h>
williamr@2: #endif
williamr@2: 
williamr@2: _STLP_BEGIN_NAMESPACE
williamr@2: 
williamr@2: // basic_ios<>'s non-inline member functions
williamr@2: 
williamr@2: // Public constructor, taking a streambuf.
williamr@2: template <class _CharT, class _Traits>
williamr@2: basic_ios<_CharT, _Traits>
williamr@2:   ::basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf)
williamr@2:     : ios_base(),
williamr@2:       _M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0)
williamr@2: {
williamr@2:   init(__streambuf);
williamr@2: }
williamr@2: 
williamr@2: template <class _CharT, class _Traits>
williamr@2: basic_streambuf<_CharT, _Traits>*
williamr@2: basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __buf)
williamr@2: {
williamr@2:   basic_streambuf<_CharT, _Traits>* __tmp = _M_streambuf;
williamr@2:   _M_streambuf = __buf;
williamr@2:   this->clear();
williamr@2:   return __tmp;
williamr@2: }
williamr@2: 
williamr@2: template <class _CharT, class _Traits>
williamr@2: basic_ios<_CharT, _Traits>&
williamr@2: basic_ios<_CharT, _Traits>::copyfmt(const basic_ios<_CharT, _Traits>& __x)
williamr@2: {
williamr@2:   _M_invoke_callbacks(erase_event);
williamr@2:   _M_copy_state(__x);           // Inherited from ios_base.
williamr@2:   _M_fill = __x._M_fill;
williamr@2:   _M_tied_ostream = __x._M_tied_ostream;
williamr@2:   _M_invoke_callbacks(copyfmt_event);
williamr@2:  // 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:   this->exceptions(__x.exceptions());
williamr@2:   return *this;
williamr@2: }
williamr@2: //#ifndef __SYMBIAN32__ // Moved to src
williamr@2: template <class _CharT, class _Traits>
williamr@2: locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
williamr@2: {
williamr@2:   locale __tmp = ios_base::imbue(__loc);
williamr@2: 
williamr@2:   if (_M_streambuf)
williamr@2:     _M_streambuf->pubimbue(__loc);
williamr@2: 
williamr@2:   // no throwing here
williamr@2: #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
williamr@2:   this->_M_cached_ctype = __loc._M_get_facet(ctype<char_type>::GetFacetLocaleId()) ;
williamr@2:   this->_M_cached_numpunct = __loc._M_get_facet(numpunct<char_type>::GetFacetLocaleId()) ;
williamr@2: #else
williamr@2:   this->_M_cached_ctype = __loc._M_get_facet(ctype<char_type>::id) ;
williamr@2:   this->_M_cached_numpunct = __loc._M_get_facet(numpunct<char_type>::id) ;
williamr@2: #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
williamr@2:   this->_M_cached_grouping = ((numpunct<char_type>*)_M_cached_numpunct)->grouping() ;
williamr@2:   return __tmp;
williamr@2: }
williamr@2: //#endif // __SYMBIAN32__
williamr@2: // Protected constructor and initialization functions. The default
williamr@2: // constructor creates an uninitialized basic_ios, and init() initializes
williamr@2: // all of the members to the values in Table 89 of the C++ standard.
williamr@2: 
williamr@2: template <class _CharT, class _Traits>
williamr@2: basic_ios<_CharT, _Traits>::basic_ios()
williamr@2:   : ios_base(),
williamr@2:     _M_fill(_STLP_NULL_CHAR_INIT(_CharT)), _M_streambuf(0), _M_tied_ostream(0)
williamr@2: {}
williamr@2: 
williamr@2: template <class _CharT, class _Traits>
williamr@2: void
williamr@2: basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
williamr@2: {
williamr@2:   this->rdbuf(__sb);
williamr@2:   this->imbue(locale());
williamr@2:   this->tie(0);
williamr@2:   this->_M_set_exception_mask(ios_base::goodbit);
williamr@2:   this->_M_clear_nothrow(__sb != 0 ? ios_base::goodbit : ios_base::badbit);
williamr@2:   ios_base::flags(ios_base::skipws | ios_base::dec);
williamr@2:   ios_base::width(0);
williamr@2:   ios_base::precision(6);
williamr@2:   this->fill(widen(' '));
williamr@2:   // We don't need to worry about any of the three arrays: they are
williamr@2:   // initialized correctly in ios_base's constructor.
williamr@2: }
williamr@2: 
williamr@2: // This is never called except from within a catch clause.
williamr@2: template <class _CharT, class _Traits>
williamr@2: void basic_ios<_CharT, _Traits>::_M_handle_exception(ios_base::iostate __flag)
williamr@2: {
williamr@2:   this->_M_setstate_nothrow(__flag);
williamr@2:   if (this->_M_get_exception_mask() & __flag)
williamr@2:     _STLP_RETHROW;
williamr@2: }
williamr@2: 
williamr@2: _STLP_END_NAMESPACE
williamr@2: 
williamr@2: #endif /* defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) */
williamr@2: 
williamr@2: #endif /* _STLP_IOS_C */