00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CPP_BITS_BASICIOS_TCC
00031 #define _CPP_BITS_BASICIOS_TCC 1
00032
00033 #pragma GCC system_header
00034
00035 namespace std
00036 {
00037 template<typename _CharT, typename _Traits>
00038 void
00039 basic_ios<_CharT, _Traits>::clear(iostate __state)
00040 {
00041 if (this->rdbuf())
00042 _M_streambuf_state = __state;
00043 else
00044 _M_streambuf_state = __state | badbit;
00045 if ((this->rdstate() & this->exceptions()))
00046 __throw_ios_failure("basic_ios::clear(iostate) caused exception");
00047 }
00048
00049 template<typename _CharT, typename _Traits>
00050 basic_streambuf<_CharT, _Traits>*
00051 basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
00052 {
00053 basic_streambuf<_CharT, _Traits>* __old = _M_streambuf;
00054 _M_streambuf = __sb;
00055 this->clear();
00056 return __old;
00057 }
00058
00059 template<typename _CharT, typename _Traits>
00060 basic_ios<_CharT, _Traits>&
00061 basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
00062 {
00063
00064
00065
00066
00067 _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ?
00068 _M_local_word : new _Words[__rhs._M_word_size];
00069
00070
00071 _Callback_list* __cb = __rhs._M_callbacks;
00072 if (__cb)
00073 __cb->_M_add_reference();
00074 _M_call_callbacks(erase_event);
00075 if (_M_word != _M_local_word)
00076 {
00077 delete [] _M_word;
00078 _M_word = 0;
00079 }
00080 _M_dispose_callbacks();
00081
00082 _M_callbacks = __cb;
00083 for (int __i = 0; __i < __rhs._M_word_size; ++__i)
00084 __words[__i] = __rhs._M_word[__i];
00085 if (_M_word != _M_local_word)
00086 {
00087 delete [] _M_word;
00088 _M_word = 0;
00089 }
00090 _M_word = __words;
00091 _M_word_size = __rhs._M_word_size;
00092
00093 this->flags(__rhs.flags());
00094 this->width(__rhs.width());
00095 this->precision(__rhs.precision());
00096 this->tie(__rhs.tie());
00097 this->fill(__rhs.fill());
00098 _M_ios_locale = __rhs.getloc();
00099
00100
00101 _M_call_callbacks(copyfmt_event);
00102
00103 _M_cache_locale(_M_ios_locale);
00104
00105
00106
00107 this->exceptions(__rhs.exceptions());
00108
00109 return *this;
00110 }
00111
00112 template<typename _CharT, typename _Traits>
00113 char
00114 basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
00115 {
00116 char __ret = __dfault;
00117 if (_M_check_facet(_M_fctype))
00118 __ret = _M_fctype->narrow(__c, __dfault);
00119 return __ret;
00120 }
00121
00122 template<typename _CharT, typename _Traits>
00123 _CharT
00124 basic_ios<_CharT, _Traits>::widen(char __c) const
00125 {
00126 char_type __ret = char_type();
00127 if (_M_check_facet(_M_fctype))
00128 __ret = _M_fctype->widen(__c);
00129 return __ret;
00130 }
00131
00132
00133 template<typename _CharT, typename _Traits>
00134 locale
00135 basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
00136 {
00137 locale __old(this->getloc());
00138 ios_base::imbue(__loc);
00139 _M_cache_locale(__loc);
00140 if (this->rdbuf() != 0)
00141 this->rdbuf()->pubimbue(__loc);
00142 return __old;
00143 }
00144
00145 template<typename _CharT, typename _Traits>
00146 void
00147 basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
00148 {
00149
00150 ios_base::_M_init();
00151 _M_cache_locale(_M_ios_locale);
00152 _M_tie = 0;
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 _M_fill = _CharT();
00167 _M_fill_init = false;
00168
00169 _M_exception = goodbit;
00170 _M_streambuf = __sb;
00171 _M_streambuf_state = __sb ? goodbit : badbit;
00172 }
00173
00174 template<typename _CharT, typename _Traits>
00175 void
00176 basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
00177 {
00178 if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
00179 _M_fctype = &use_facet<__ctype_type>(__loc);
00180 else
00181 _M_fctype = 0;
00182 if (__builtin_expect(has_facet<__numput_type>(__loc), true))
00183 _M_fnumput = &use_facet<__numput_type>(__loc);
00184 else
00185 _M_fnumput = 0;
00186 if (__builtin_expect(has_facet<__numget_type>(__loc), true))
00187 _M_fnumget = &use_facet<__numget_type>(__loc);
00188 else
00189 _M_fnumget = 0;
00190 }
00191
00192 #if 1
00193
00194 template<typename _CharT, typename _Traits>
00195 void
00196 basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
00197 {
00198 if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
00199 _M_fctype = &use_facet<__ctype_type>(__loc);
00200 if (__builtin_expect(has_facet<__numput_type>(__loc), true))
00201 _M_fnumput = &use_facet<__numput_type>(__loc);
00202 if (__builtin_expect(has_facet<__numget_type>(__loc), true))
00203 _M_fnumget = &use_facet<__numget_type>(__loc);
00204 }
00205 #endif
00206
00207
00208
00209
00210 #if _GLIBCPP_EXTERN_TEMPLATE
00211 extern template class basic_ios<char>;
00212
00213 #ifdef _GLIBCPP_USE_WCHAR_T
00214 extern template class basic_ios<wchar_t>;
00215 #endif
00216 #endif
00217 }
00218
00219 #endif