1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | #ifndef _BASIC_IOS_TCC |
31 | #define _BASIC_IOS_TCC 1 |
32 | |
33 | #pragma GCC system_header |
34 | |
35 | namespace std _GLIBCXX_VISIBILITY(default) |
36 | { |
37 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
38 | |
39 | template<typename _CharT, typename _Traits> |
40 | void |
41 | basic_ios<_CharT, _Traits>::clear(iostate __state) |
42 | { |
43 | if (this->rdbuf()) |
44 | _M_streambuf_state = __state; |
45 | else |
46 | _M_streambuf_state = __state | badbit; |
47 | if (this->exceptions() & this->rdstate()) |
48 | __throw_ios_failure(__N("basic_ios::clear")); |
49 | } |
50 | |
51 | template<typename _CharT, typename _Traits> |
52 | basic_streambuf<_CharT, _Traits>* |
53 | basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb) |
54 | { |
55 | basic_streambuf<_CharT, _Traits>* __old = _M_streambuf; |
56 | _M_streambuf = __sb; |
57 | this->clear(); |
58 | return __old; |
59 | } |
60 | |
61 | template<typename _CharT, typename _Traits> |
62 | basic_ios<_CharT, _Traits>& |
63 | basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) |
64 | { |
65 | |
66 | |
67 | if (this != &__rhs) |
68 | { |
69 | |
70 | |
71 | |
72 | |
73 | _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? |
74 | _M_local_word : new _Words[__rhs._M_word_size]; |
75 | |
76 | |
77 | _Callback_list* __cb = __rhs._M_callbacks; |
78 | if (__cb) |
79 | __cb->_M_add_reference(); |
80 | _M_call_callbacks(erase_event); |
81 | if (_M_word != _M_local_word) |
82 | { |
83 | delete [] _M_word; |
84 | _M_word = 0; |
85 | } |
86 | _M_dispose_callbacks(); |
87 | |
88 | |
89 | _M_callbacks = __cb; |
90 | for (int __i = 0; __i < __rhs._M_word_size; ++__i) |
91 | __words[__i] = __rhs._M_word[__i]; |
92 | _M_word = __words; |
93 | _M_word_size = __rhs._M_word_size; |
94 | |
95 | this->flags(__rhs.flags()); |
96 | this->width(__rhs.width()); |
97 | this->precision(__rhs.precision()); |
98 | this->tie(__rhs.tie()); |
99 | this->fill(__rhs.fill()); |
100 | _M_ios_locale = __rhs.getloc(); |
101 | _M_cache_locale(_M_ios_locale); |
102 | |
103 | _M_call_callbacks(copyfmt_event); |
104 | |
105 | |
106 | this->exceptions(__rhs.exceptions()); |
107 | } |
108 | return *this; |
109 | } |
110 | |
111 | |
112 | template<typename _CharT, typename _Traits> |
113 | locale |
114 | basic_ios<_CharT, _Traits>::imbue(const locale& __loc) |
115 | { |
116 | locale __old(this->getloc()); |
117 | ios_base::imbue(__loc); |
118 | _M_cache_locale(__loc); |
119 | if (this->rdbuf() != 0) |
120 | this->rdbuf()->pubimbue(__loc); |
121 | return __old; |
122 | } |
123 | |
124 | template<typename _CharT, typename _Traits> |
125 | void |
126 | basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb) |
127 | { |
128 | |
129 | ios_base::_M_init(); |
130 | |
131 | |
132 | _M_cache_locale(_M_ios_locale); |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | _M_fill = _CharT(); |
147 | _M_fill_init = false; |
148 | |
149 | _M_tie = 0; |
150 | _M_exception = goodbit; |
151 | _M_streambuf = __sb; |
152 | _M_streambuf_state = __sb ? goodbit : badbit; |
153 | } |
154 | |
155 | template<typename _CharT, typename _Traits> |
156 | void |
157 | basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc) |
158 | { |
159 | if (__builtin_expect(has_facet<__ctype_type>(__loc), true)) |
160 | _M_ctype = std::__addressof(use_facet<__ctype_type>(__loc)); |
161 | else |
162 | _M_ctype = 0; |
163 | |
164 | if (__builtin_expect(has_facet<__num_put_type>(__loc), true)) |
165 | _M_num_put = std::__addressof(use_facet<__num_put_type>(__loc)); |
166 | else |
167 | _M_num_put = 0; |
168 | |
169 | if (__builtin_expect(has_facet<__num_get_type>(__loc), true)) |
170 | _M_num_get = std::__addressof(use_facet<__num_get_type>(__loc)); |
171 | else |
172 | _M_num_get = 0; |
173 | } |
174 | |
175 | |
176 | |
177 | #if _GLIBCXX_EXTERN_TEMPLATE |
178 | extern template class basic_ios<char>; |
179 | |
180 | #ifdef _GLIBCXX_USE_WCHAR_T |
181 | extern template class basic_ios<wchar_t>; |
182 | #endif |
183 | #endif |
184 | |
185 | _GLIBCXX_END_NAMESPACE_VERSION |
186 | } |
187 | |
188 | #endif |
189 | |