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