|
1 /* |
|
2 * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 * |
|
4 * Copyright (c) 1999 |
|
5 * Silicon Graphics Computer Systems, Inc. |
|
6 * |
|
7 * Copyright (c) 1999 |
|
8 * Boris Fomitchev |
|
9 * |
|
10 * This material is provided "as is", with absolutely no warranty expressed |
|
11 * or implied. Any use is at your own risk. |
|
12 * |
|
13 * Permission to use or copy this software for any purpose is hereby granted |
|
14 * without fee, provided the above notices are retained on all copies. |
|
15 * Permission to modify the code and to distribute modified code is granted, |
|
16 * provided the above notices are retained, and a notice that the code was |
|
17 * modified is included with the above copyright notice. |
|
18 * |
|
19 */ |
|
20 #include "stlport_prefix.h" |
|
21 |
|
22 #include <locale> |
|
23 #include <typeinfo> |
|
24 #include <algorithm> |
|
25 #include <stdexcept> |
|
26 |
|
27 #include "c_locale.h" |
|
28 #include "aligned_buffer.h" |
|
29 #include "locale_impl.h" |
|
30 #include "message_facets.h" |
|
31 |
|
32 #if defined(__SYMBIAN32__WSD__) |
|
33 #include "libstdcppwsd.h" |
|
34 |
|
35 std::_Stl_aligned_buffer<std::_Locale_impl::Init>& get_Loc_init_buf() |
|
36 { |
|
37 return *(std::_Stl_aligned_buffer<std::_Locale_impl::Init> *)(get_libcpp_wsd().__Loc_init_buf); |
|
38 } |
|
39 |
|
40 #define __Loc_init_buf get_Loc_init_buf() |
|
41 #define _S_count get_Loc_init_S_count() |
|
42 #define _Index_lock get_locale_Index_lock() |
|
43 #define _S_index get_S_index() |
|
44 #define _S_max get_locale_id_S_max() |
|
45 #define _Stl_classic_locale get_Stl_classic_locale() |
|
46 #define _Stl_global_locale get_Stl_global_locale() |
|
47 |
|
48 #endif //__SYMBIAN32__WSD__ |
|
49 |
|
50 _STLP_BEGIN_NAMESPACE |
|
51 |
|
52 #if defined(__SYMBIAN32__WSD__) && defined(_STLP_DEBUG) |
|
53 #define _Nameless *get_Nameless() |
|
54 #else |
|
55 static const string _Nameless("*"); |
|
56 #endif |
|
57 |
|
58 static inline bool is_C_locale_name (const char* name) |
|
59 { return ((name[0] == 'C') && (name[1] == 0)); } |
|
60 |
|
61 _Locale_impl * _STLP_CALL _copy_Locale_impl(_Locale_impl *loc) |
|
62 { |
|
63 _STLP_ASSERT( loc != 0 ); |
|
64 loc->_M_incr(); |
|
65 _Locale_impl *loc_new = new _Locale_impl(*loc); |
|
66 loc->_M_decr(); |
|
67 return loc_new; |
|
68 } |
|
69 |
|
70 locale::facet * _STLP_CALL _get_facet(locale::facet *f) |
|
71 { |
|
72 if (f != 0) |
|
73 f->_M_incr(); |
|
74 return f; |
|
75 } |
|
76 |
|
77 void _STLP_CALL _release_facet(locale::facet *&f) |
|
78 { |
|
79 if ((f != 0) && (f->_M_decr() == 0)) { |
|
80 delete f; |
|
81 f = 0; |
|
82 } |
|
83 } |
|
84 # if !defined(__SYMBIAN32__WSD__) |
|
85 # if !defined(__SYMBIAN32__NO_STATIC_IMPORTS__) |
|
86 _STLP_STATIC_MEMBER_DECLSPEC size_t locale::id::_S_max = 39; |
|
87 #else |
|
88 size_t locale::id::_S_max = 39; |
|
89 #endif |
|
90 # endif //__SYMBIAN32__WSD__ |
|
91 |
|
92 static void _Stl_loc_assign_ids(); |
|
93 |
|
94 #if !defined(__SYMBIAN32__WSD__) |
|
95 static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf; |
|
96 #endif |
|
97 |
|
98 _Locale_impl::Init::Init() { |
|
99 if (_M_count()._M_incr() == 1) { |
|
100 _Locale_impl::_S_initialize(); |
|
101 } |
|
102 } |
|
103 |
|
104 _Locale_impl::Init::~Init() { |
|
105 if (_M_count()._M_decr() == 0) { |
|
106 _Locale_impl::_S_uninitialize(); |
|
107 } |
|
108 } |
|
109 |
|
110 _Refcount_Base& _Locale_impl::Init::_M_count() const { |
|
111 #if !defined(__SYMBIAN32__WSD__) |
|
112 static _Refcount_Base _S_count(0); |
|
113 #endif |
|
114 return _S_count; |
|
115 } |
|
116 |
|
117 _Locale_impl::_Locale_impl(const char* s) |
|
118 : _Refcount_Base(0), name(s), facets_vec() { |
|
119 facets_vec.reserve( locale::id::_S_max ); |
|
120 new (&__Loc_init_buf) Init(); |
|
121 } |
|
122 |
|
123 _Locale_impl::_Locale_impl( _Locale_impl const& locimpl ) |
|
124 : _Refcount_Base(0), name(locimpl.name), facets_vec() { |
|
125 for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet); |
|
126 facets_vec = locimpl.facets_vec; |
|
127 new (&__Loc_init_buf) Init(); |
|
128 } |
|
129 |
|
130 _Locale_impl::_Locale_impl( size_t n, const char* s) |
|
131 : _Refcount_Base(0), name(s), facets_vec(n, 0) { |
|
132 new (&__Loc_init_buf) Init(); |
|
133 } |
|
134 |
|
135 _Locale_impl::~_Locale_impl() { |
|
136 (&__Loc_init_buf)->~Init(); |
|
137 for_each( facets_vec.begin(), facets_vec.end(), _release_facet); |
|
138 } |
|
139 |
|
140 // Initialization of the locale system. This must be called before |
|
141 // any locales are constructed. (Meaning that it must be called when |
|
142 // the I/O library itself is initialized.) |
|
143 void _STLP_CALL _Locale_impl::_S_initialize() { |
|
144 |
|
145 #if defined(__SYMBIAN32__WSD__) |
|
146 //initialize wsd obj pointer |
|
147 locale_impl_init(); |
|
148 # endif |
|
149 |
|
150 _Stl_loc_assign_ids(); |
|
151 make_classic_locale(); |
|
152 |
|
153 #if defined(__SYMBIAN32__WSD__) |
|
154 global_iostream_init(); |
|
155 # endif |
|
156 } |
|
157 |
|
158 // Release of the classic locale ressources. Has to be called after the last |
|
159 // locale destruction and not only after the classic locale destruction as |
|
160 // the facets can be shared between different facets. |
|
161 void _STLP_CALL _Locale_impl::_S_uninitialize() { |
|
162 //Not necessary anymore as classic facets are now 'normal' dynamically allocated |
|
163 //facets with a reference counter telling to _release_facet when the facet can be |
|
164 //deleted. |
|
165 //free_classic_locale(); |
|
166 } |
|
167 |
|
168 // _Locale_impl non-inline member functions. |
|
169 void _STLP_CALL _Locale_impl::_M_throw_bad_cast() { |
|
170 _STLP_THROW(bad_cast()); |
|
171 } |
|
172 |
|
173 void _Locale_impl::insert( _Locale_impl *from, const locale::id& n ) { |
|
174 size_t index = n._M_index; |
|
175 if (index > 0 && index < from->size()) { |
|
176 this->insert( from->facets_vec[index], index); |
|
177 } |
|
178 } |
|
179 |
|
180 locale::facet* _Locale_impl::insert(locale::facet *f, size_t index) { |
|
181 if (f == 0 || index == 0) |
|
182 return 0; |
|
183 |
|
184 if (index >= facets_vec.size()) { |
|
185 facets_vec.resize(index + 1); |
|
186 } |
|
187 |
|
188 if (f != facets_vec[index]) |
|
189 { |
|
190 _release_facet(facets_vec[index]); |
|
191 facets_vec[index] = _get_facet(f); |
|
192 } |
|
193 |
|
194 return f; |
|
195 } |
|
196 |
|
197 #if !defined (__DMC__) |
|
198 _Locale_name_hint* _Locale_extract_hint(ctype_byname<char>* ct) |
|
199 { return _Locale_get_ctype_hint(ct->_M_ctype); } |
|
200 _Locale_name_hint* _Locale_extract_hint(numpunct_byname<char>* punct) |
|
201 { return _Locale_get_numeric_hint(punct->_M_numeric); } |
|
202 # if defined (__GNUC__) && (__GNUC__ < 3) |
|
203 template <class _Ch, class _InIt> |
|
204 _Locale_name_hint* _Locale_time_extract_hint(time_get_byname<_Ch, _InIt>* tget) |
|
205 # else |
|
206 _Locale_name_hint* _Locale_time_extract_hint(time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >* tget) |
|
207 # endif |
|
208 { return _Locale_get_time_hint(tget->_M_time); } |
|
209 _Locale_name_hint* _Locale_extract_hint(collate_byname<char>* coll) |
|
210 { return _Locale_get_collate_hint(coll->_M_collate); } |
|
211 _Locale_name_hint* _Locale_extract_hint(moneypunct_byname<char, false>* money) |
|
212 { return _Locale_get_monetary_hint(money->_M_monetary); } |
|
213 #endif |
|
214 |
|
215 // |
|
216 // <locale> content which is dependent on the name |
|
217 // |
|
218 #if defined(__SYMBIAN32__WSD__) |
|
219 #define id GetFacetLocaleId() |
|
220 #endif |
|
221 |
|
222 template <class Facet> |
|
223 static inline locale::facet* _Locale_insert(_Locale_impl *__that, Facet* f) |
|
224 { return __that->insert(f, Facet::id._M_index); } |
|
225 |
|
226 /* |
|
227 * Six functions, one for each category. Each of them takes a |
|
228 * _Locale* and a name, constructs that appropriate category |
|
229 * facets by name, and inserts them into the locale. |
|
230 */ |
|
231 _Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* pname, _Locale_name_hint* hint) { |
|
232 char buf[_Locale_MAX_SIMPLE_NAME]; |
|
233 _Locale_impl* i2 = locale::classic()._M_impl; |
|
234 |
|
235 if (pname == 0 || pname[0] == 0) |
|
236 pname = _Locale_ctype_default(buf); |
|
237 |
|
238 if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) { |
|
239 this->insert(i2, ctype<char>::id); |
|
240 #ifndef _STLP_NO_MBSTATE_T |
|
241 this->insert(i2, codecvt<char, char, mbstate_t>::id); |
|
242 #endif |
|
243 #ifndef _STLP_NO_WCHAR_T |
|
244 this->insert(i2, ctype<wchar_t>::id); |
|
245 # ifndef _STLP_NO_MBSTATE_T |
|
246 this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id); |
|
247 # endif |
|
248 #endif |
|
249 } else { |
|
250 ctype<char>* ct = 0; |
|
251 #ifndef _STLP_NO_MBSTATE_T |
|
252 codecvt<char, char, mbstate_t>* cvt = 0; |
|
253 #endif |
|
254 #ifndef _STLP_NO_WCHAR_T |
|
255 ctype<wchar_t>* wct = 0; |
|
256 codecvt<wchar_t, char, mbstate_t>* wcvt = 0; |
|
257 #endif |
|
258 _STLP_TRY { |
|
259 ctype_byname<char> *ctbn = new ctype_byname<char>(pname, 0, hint); |
|
260 ct = ctbn; |
|
261 #if !defined (__DMC__) |
|
262 if (hint == 0) hint = _Locale_extract_hint(ctbn); |
|
263 #endif |
|
264 #ifndef _STLP_NO_MBSTATE_T |
|
265 cvt = new codecvt_byname<char, char, mbstate_t>(pname); |
|
266 #endif |
|
267 #ifndef _STLP_NO_WCHAR_T |
|
268 wct = new ctype_byname<wchar_t>(pname, 0, hint); |
|
269 wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname, 0, hint); |
|
270 #endif |
|
271 } |
|
272 |
|
273 #ifndef _STLP_NO_WCHAR_T |
|
274 # ifdef _STLP_NO_MBSTATE_T |
|
275 _STLP_UNWIND(delete ct; delete wct; delete wcvt); |
|
276 # else |
|
277 _STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt); |
|
278 # endif |
|
279 #else |
|
280 # ifdef _STLP_NO_MBSTATE_T |
|
281 _STLP_UNWIND(delete ct); |
|
282 # else |
|
283 _STLP_UNWIND(delete ct; delete cvt); |
|
284 # endif |
|
285 #endif |
|
286 _Locale_insert(this, ct); |
|
287 #ifndef _STLP_NO_MBSTATE_T |
|
288 _Locale_insert(this, cvt); |
|
289 #endif |
|
290 #ifndef _STLP_NO_WCHAR_T |
|
291 _Locale_insert(this, wct); |
|
292 _Locale_insert(this, wcvt); |
|
293 #endif |
|
294 } |
|
295 return hint; |
|
296 } |
|
297 |
|
298 _Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* pname, _Locale_name_hint* hint) { |
|
299 _Locale_impl* i2 = locale::classic()._M_impl; |
|
300 |
|
301 numpunct<char>* punct = 0; |
|
302 num_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0; |
|
303 num_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0; |
|
304 #ifndef _STLP_NO_WCHAR_T |
|
305 numpunct<wchar_t>* wpunct = 0; |
|
306 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0; |
|
307 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0; |
|
308 #endif |
|
309 |
|
310 char buf[_Locale_MAX_SIMPLE_NAME]; |
|
311 if (pname == 0 || pname[0] == 0) |
|
312 pname = _Locale_numeric_default(buf); |
|
313 |
|
314 if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) { |
|
315 this->insert(i2, numpunct<char>::id); |
|
316 this->insert(i2, |
|
317 num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); |
|
318 this->insert(i2, |
|
319 num_get<char, istreambuf_iterator<char, char_traits<char> > >::id); |
|
320 #ifndef _STLP_NO_WCHAR_T |
|
321 this->insert(i2, numpunct<wchar_t>::id); |
|
322 this->insert(i2, |
|
323 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); |
|
324 this->insert(i2, |
|
325 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); |
|
326 #endif |
|
327 } |
|
328 else { |
|
329 _STLP_TRY { |
|
330 numpunct_byname<char> *punctbn = new numpunct_byname<char>(pname, 0, hint); |
|
331 punct = punctbn; |
|
332 #if !defined (__DMC__) |
|
333 if (hint == 0) hint = _Locale_extract_hint(punctbn); |
|
334 #endif |
|
335 get = new num_get<char, istreambuf_iterator<char, char_traits<char> > >; |
|
336 put = new num_put<char, ostreambuf_iterator<char, char_traits<char> > >; |
|
337 #ifndef _STLP_NO_WCHAR_T |
|
338 wpunct = new numpunct_byname<wchar_t>(pname, 0, hint); |
|
339 wget = new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
|
340 wput = new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
|
341 #endif |
|
342 } |
|
343 #ifndef _STLP_NO_WCHAR_T |
|
344 _STLP_UNWIND(delete punct; delete wpunct; delete get; delete wget; delete put; delete wput); |
|
345 #else |
|
346 _STLP_UNWIND(delete punct; delete get;delete put); |
|
347 #endif |
|
348 |
|
349 _Locale_insert(this,punct); |
|
350 _Locale_insert(this,get); |
|
351 _Locale_insert(this,put); |
|
352 |
|
353 #ifndef _STLP_NO_WCHAR_T |
|
354 _Locale_insert(this,wpunct); |
|
355 _Locale_insert(this,wget); |
|
356 _Locale_insert(this,wput); |
|
357 #endif |
|
358 } |
|
359 return hint; |
|
360 } |
|
361 |
|
362 _Locale_name_hint* _Locale_impl::insert_time_facets(const char* pname, _Locale_name_hint* hint) { |
|
363 _Locale_impl* i2 = locale::classic()._M_impl; |
|
364 time_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0; |
|
365 time_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0; |
|
366 #ifndef _STLP_NO_WCHAR_T |
|
367 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0; |
|
368 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0; |
|
369 #endif |
|
370 |
|
371 char buf[_Locale_MAX_SIMPLE_NAME]; |
|
372 if (pname == 0 || pname[0] == 0) |
|
373 pname = _Locale_time_default(buf); |
|
374 |
|
375 if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) { |
|
376 |
|
377 this->insert(i2, |
|
378 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id); |
|
379 this->insert(i2, |
|
380 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); |
|
381 #ifndef _STLP_NO_WCHAR_T |
|
382 this->insert(i2, |
|
383 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); |
|
384 this->insert(i2, |
|
385 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); |
|
386 #endif |
|
387 } else { |
|
388 _STLP_TRY { |
|
389 time_get_byname<char, istreambuf_iterator<char, char_traits<char> > > *getbn = |
|
390 new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(pname, 0, hint); |
|
391 get = getbn; |
|
392 #if !defined (__DMC__) |
|
393 if (hint == 0) hint = _Locale_time_extract_hint(getbn); |
|
394 #endif |
|
395 put = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(pname, 0, hint); |
|
396 #ifndef _STLP_NO_WCHAR_T |
|
397 wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname, 0, hint); |
|
398 wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname, 0, hint); |
|
399 #endif |
|
400 } |
|
401 #ifndef _STLP_NO_WCHAR_T |
|
402 _STLP_UNWIND(delete get; delete wget; delete put; delete wput); |
|
403 #else |
|
404 _STLP_UNWIND(delete get; delete put); |
|
405 #endif |
|
406 _Locale_insert(this,get); |
|
407 _Locale_insert(this,put); |
|
408 #ifndef _STLP_NO_WCHAR_T |
|
409 _Locale_insert(this,wget); |
|
410 _Locale_insert(this,wput); |
|
411 #endif |
|
412 } |
|
413 return hint; |
|
414 } |
|
415 |
|
416 _Locale_name_hint* _Locale_impl::insert_collate_facets(const char* nam, _Locale_name_hint* hint) { |
|
417 _Locale_impl* i2 = locale::classic()._M_impl; |
|
418 |
|
419 collate<char> *col = 0; |
|
420 #ifndef _STLP_NO_WCHAR_T |
|
421 collate<wchar_t> *wcol = 0; |
|
422 #endif |
|
423 |
|
424 char buf[_Locale_MAX_SIMPLE_NAME]; |
|
425 if (nam == 0 || nam[0] == 0) |
|
426 nam = _Locale_collate_default(buf); |
|
427 |
|
428 if (nam == 0 || nam[0] == 0 || is_C_locale_name(nam)) { |
|
429 this->insert(i2, collate<char>::id); |
|
430 #ifndef _STLP_NO_WCHAR_T |
|
431 this->insert(i2, collate<wchar_t>::id); |
|
432 #endif |
|
433 } |
|
434 else { |
|
435 _STLP_TRY { |
|
436 collate_byname<char> *colbn = new collate_byname<char>(nam, 0, hint); |
|
437 col = colbn; |
|
438 #if !defined (__DMC__) |
|
439 if (hint == 0) hint = _Locale_extract_hint(colbn); |
|
440 #endif |
|
441 #ifndef _STLP_NO_WCHAR_T |
|
442 wcol = new collate_byname<wchar_t>(nam, 0, hint); |
|
443 #endif |
|
444 } |
|
445 #ifndef _STLP_NO_WCHAR_T |
|
446 _STLP_UNWIND(delete col; delete wcol); |
|
447 #else |
|
448 _STLP_UNWIND(delete col); |
|
449 #endif |
|
450 _Locale_insert(this,col); |
|
451 #ifndef _STLP_NO_WCHAR_T |
|
452 _Locale_insert(this,wcol); |
|
453 #endif |
|
454 } |
|
455 return hint; |
|
456 } |
|
457 |
|
458 _Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* pname, _Locale_name_hint* hint) { |
|
459 _Locale_impl* i2 = locale::classic()._M_impl; |
|
460 |
|
461 moneypunct<char, false> *punct = 0; |
|
462 moneypunct<char, true> *ipunct = 0; |
|
463 money_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0; |
|
464 money_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0; |
|
465 |
|
466 #ifndef _STLP_NO_WCHAR_T |
|
467 moneypunct<wchar_t, false>* wpunct = 0; |
|
468 moneypunct<wchar_t, true>* wipunct = 0; |
|
469 money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0; |
|
470 money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0; |
|
471 #endif |
|
472 |
|
473 char buf[_Locale_MAX_SIMPLE_NAME]; |
|
474 if (pname == 0 || pname[0] == 0) |
|
475 pname = _Locale_monetary_default(buf); |
|
476 |
|
477 if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) { |
|
478 this->insert(i2, moneypunct<char, false>::id); |
|
479 this->insert(i2, moneypunct<char, true>::id); |
|
480 this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id); |
|
481 this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); |
|
482 #ifndef _STLP_NO_WCHAR_T |
|
483 this->insert(i2, moneypunct<wchar_t, false>::id); |
|
484 this->insert(i2, moneypunct<wchar_t, true>::id); |
|
485 this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); |
|
486 this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); |
|
487 #endif |
|
488 } |
|
489 else { |
|
490 _STLP_TRY { |
|
491 moneypunct_byname<char, false>* punctbn = new moneypunct_byname<char, false>(pname, 0, hint); |
|
492 punct = punctbn; |
|
493 #if !defined (__DMC__) |
|
494 if (hint == 0) hint = _Locale_extract_hint(punctbn); |
|
495 #endif |
|
496 ipunct = new moneypunct_byname<char, true>(pname, 0, hint); |
|
497 get = new money_get<char, istreambuf_iterator<char, char_traits<char> > >; |
|
498 put = new money_put<char, ostreambuf_iterator<char, char_traits<char> > >; |
|
499 #ifndef _STLP_NO_WCHAR_T |
|
500 wpunct = new moneypunct_byname<wchar_t, false>(pname, 0, hint); |
|
501 wipunct = new moneypunct_byname<wchar_t, true>(pname, 0, hint); |
|
502 wget = new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
|
503 wput = new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
|
504 #endif |
|
505 } |
|
506 #ifndef _STLP_NO_WCHAR_T |
|
507 _STLP_UNWIND(delete punct; delete ipunct; delete wpunct; delete wipunct; delete get; delete wget; delete put; delete wput); |
|
508 #else |
|
509 _STLP_UNWIND(delete punct; delete ipunct; delete get; delete put); |
|
510 #endif |
|
511 _Locale_insert(this,punct); |
|
512 _Locale_insert(this,ipunct); |
|
513 _Locale_insert(this,get); |
|
514 _Locale_insert(this,put); |
|
515 #ifndef _STLP_NO_WCHAR_T |
|
516 _Locale_insert(this,wget); |
|
517 _Locale_insert(this,wpunct); |
|
518 _Locale_insert(this,wipunct); |
|
519 _Locale_insert(this,wput); |
|
520 #endif |
|
521 } |
|
522 return hint; |
|
523 } |
|
524 |
|
525 _Locale_name_hint* _Locale_impl::insert_messages_facets(const char* pname, _Locale_name_hint* hint) { |
|
526 _Locale_impl* i2 = locale::classic()._M_impl; |
|
527 messages<char> *msg = 0; |
|
528 #ifndef _STLP_NO_WCHAR_T |
|
529 messages<wchar_t> *wmsg = 0; |
|
530 #endif |
|
531 |
|
532 char buf[_Locale_MAX_SIMPLE_NAME]; |
|
533 if (pname == 0 || pname[0] == 0) |
|
534 pname = _Locale_messages_default(buf); |
|
535 |
|
536 if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) { |
|
537 this->insert(i2, messages<char>::id); |
|
538 #ifndef _STLP_NO_WCHAR_T |
|
539 this->insert(i2, messages<wchar_t>::id); |
|
540 #endif |
|
541 } |
|
542 else { |
|
543 _STLP_TRY { |
|
544 msg = new messages_byname<char>(pname, 0, hint); |
|
545 #ifndef _STLP_NO_WCHAR_T |
|
546 wmsg = new messages_byname<wchar_t>(pname, 0, hint); |
|
547 #endif |
|
548 } |
|
549 #ifndef _STLP_NO_WCHAR_T |
|
550 _STLP_UNWIND(delete msg; delete wmsg); |
|
551 #else |
|
552 _STLP_UNWIND(delete msg); |
|
553 #endif |
|
554 _Locale_insert(this,msg); |
|
555 #ifndef _STLP_NO_WCHAR_T |
|
556 _Locale_insert(this,wmsg); |
|
557 #endif |
|
558 } |
|
559 return hint; |
|
560 } |
|
561 |
|
562 static void _Stl_loc_assign_ids() { |
|
563 // This assigns ids to every facet that is a member of a category, |
|
564 // and also to money_get/put, num_get/put, and time_get/put |
|
565 // instantiated using ordinary pointers as the input/output |
|
566 // iterators. (The default is [io]streambuf_iterator.) |
|
567 |
|
568 #ifdef __SYMBIAN32__WSD__ |
|
569 collate<char>::id._M_index = 1; |
|
570 ctype<char>::id._M_index = 2; |
|
571 |
|
572 #ifndef _STLP_NO_MBSTATE_T |
|
573 codecvt<char, char, mbstate_t>::id._M_index = 3; |
|
574 # ifndef _STLP_NO_WCHAR_T |
|
575 codecvt<wchar_t, char, mbstate_t>::id._M_index = 22; |
|
576 # endif |
|
577 #endif |
|
578 moneypunct<char, true>::id._M_index = 4; |
|
579 moneypunct<char, false>::id._M_index = 5; |
|
580 numpunct<char>::id._M_index = 6; |
|
581 messages<char>::id._M_index =7; |
|
582 |
|
583 collate<wchar_t>::id._M_index = 20; |
|
584 ctype<wchar_t>::id._M_index = 21; |
|
585 moneypunct<wchar_t, true>::id._M_index = 23; |
|
586 moneypunct<wchar_t, false>::id._M_index = 24; |
|
587 numpunct<wchar_t>::id._M_index = 25; |
|
588 messages<wchar_t>::id._M_index = 26; |
|
589 #endif |
|
590 |
|
591 |
|
592 money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 8; |
|
593 //money_get<char, const char*>::id._M_index = 9; |
|
594 money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 10; |
|
595 //money_put<char, char*>::id._M_index = 11; |
|
596 |
|
597 num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12; |
|
598 //num_get<char, const char*>::id._M_index = 13; |
|
599 num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 14; |
|
600 //num_put<char, char*>::id._M_index = 15; |
|
601 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 16; |
|
602 //time_get<char, const char*>::id._M_index = 17; |
|
603 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 18; |
|
604 //time_put<char, char*>::id._M_index = 19; |
|
605 |
|
606 #ifndef _STLP_NO_WCHAR_T |
|
607 money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 27; |
|
608 //money_get<wchar_t, const wchar_t*>::id._M_index = 28; |
|
609 money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 29; |
|
610 //money_put<wchar_t, wchar_t*>::id._M_index = 30; |
|
611 |
|
612 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 31; |
|
613 //num_get<wchar_t, const wchar_t*>::id._M_index = 32; |
|
614 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index = 33; |
|
615 //num_put<wchar_t, wchar_t*>::id._M_index = 34; |
|
616 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 35; |
|
617 //time_get<wchar_t, const wchar_t*>::id._M_index = 36; |
|
618 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 37; |
|
619 //time_put<wchar_t, wchar_t*>::id._M_index = 38; |
|
620 #endif |
|
621 // locale::id::_S_max = 39; |
|
622 } |
|
623 |
|
624 // To access those static instance use the getter below, they guaranty |
|
625 // a correct initialization. |
|
626 #if !defined(__SYMBIAN32__WSD__) |
|
627 static locale *_Stl_classic_locale = 0; |
|
628 static locale *_Stl_global_locale = 0; |
|
629 #endif |
|
630 |
|
631 static locale* _Stl_get_classic_locale() { |
|
632 #if !defined(__SYMBIAN32__WSD__) |
|
633 static _Locale_impl::Init init; |
|
634 #endif |
|
635 return _Stl_classic_locale; |
|
636 } |
|
637 |
|
638 static locale* _Stl_get_global_locale() { |
|
639 #if !defined(__SYMBIAN32__WSD__) |
|
640 static _Locale_impl::Init init; |
|
641 #endif |
|
642 return _Stl_global_locale; |
|
643 } |
|
644 |
|
645 #if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__) |
|
646 /* |
|
647 * The following static variable needs to be initialized before STLport |
|
648 * users static variable in order for him to be able to use Standard |
|
649 * streams in its variable initialization. |
|
650 * This variable is here because MSVC do not allow to change the initialization |
|
651 * segment in a given translation unit, iostream.cpp already contains an |
|
652 * initialization segment specification. |
|
653 */ |
|
654 # pragma warning (disable : 4073) |
|
655 # pragma init_seg(lib) |
|
656 #endif |
|
657 |
|
658 #if !defined(__SYMBIAN32__WSD__) |
|
659 static ios_base::Init _IosInit; |
|
660 #endif |
|
661 |
|
662 void _Locale_impl::make_classic_locale() { |
|
663 // This funcion will be called once: during build classic _Locale_impl |
|
664 |
|
665 // The classic locale contains every facet that belongs to a category. |
|
666 static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf; |
|
667 _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C"); |
|
668 |
|
669 locale::facet* classic_facets[] = { |
|
670 0, |
|
671 new collate<char>(1), |
|
672 new ctype<char>(0, false, 1), |
|
673 #ifndef _STLP_NO_MBSTATE_T |
|
674 new codecvt<char, char, mbstate_t>(1), |
|
675 #else |
|
676 0, |
|
677 #endif |
|
678 new moneypunct<char, true>(1), |
|
679 new moneypunct<char, false>(1), |
|
680 new numpunct<char>(1), |
|
681 new messages<char>(new _STLP_PRIV _Messages()), |
|
682 new money_get<char, istreambuf_iterator<char, char_traits<char> > >(1), |
|
683 0, |
|
684 new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1), |
|
685 0, |
|
686 new num_get<char, istreambuf_iterator<char, char_traits<char> > >(1), |
|
687 0, |
|
688 new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1), |
|
689 0, |
|
690 new time_get<char, istreambuf_iterator<char, char_traits<char> > >(1), |
|
691 0, |
|
692 new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1), |
|
693 0, |
|
694 #ifndef _STLP_NO_WCHAR_T |
|
695 new collate<wchar_t>(1), |
|
696 new ctype<wchar_t>(1), |
|
697 |
|
698 # ifndef _STLP_NO_MBSTATE_T |
|
699 new codecvt<wchar_t, char, mbstate_t>(1), |
|
700 # else |
|
701 0, |
|
702 # endif |
|
703 new moneypunct<wchar_t, true>(1), |
|
704 new moneypunct<wchar_t, false>(1), |
|
705 new numpunct<wchar_t>(1), |
|
706 new messages<wchar_t>(new _STLP_PRIV _Messages()), |
|
707 |
|
708 new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), |
|
709 0, |
|
710 new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), |
|
711 0, |
|
712 |
|
713 new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), |
|
714 0, |
|
715 new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), |
|
716 0, |
|
717 new time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), |
|
718 0, |
|
719 new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), |
|
720 0, |
|
721 #endif |
|
722 0 |
|
723 }; |
|
724 |
|
725 const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *); |
|
726 classic->facets_vec.reserve(nb_classic_facets); |
|
727 classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets); |
|
728 |
|
729 #if defined(__SYMBIAN32__WSD__) |
|
730 ::set_Stl_classic_locale(new (WSDAlloc(sizeof(locale))) locale(classic)); |
|
731 ::set_Stl_global_locale (new (WSDAlloc(sizeof(locale))) locale(_copy_Locale_impl(classic))); |
|
732 #else |
|
733 static locale _Locale_classic(classic); |
|
734 _Stl_classic_locale = &_Locale_classic; |
|
735 |
|
736 static locale _Locale_global(_copy_Locale_impl(classic)); |
|
737 _Stl_global_locale = &_Locale_global; |
|
738 #endif |
|
739 } |
|
740 |
|
741 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x564) |
|
742 template <> |
|
743 _STLP_DECLSPEC locale::id time_get<char, istreambuf_iterator<char, char_traits<char> > >::id; |
|
744 /* |
|
745 template <> |
|
746 _STLP_DECLSPEC locale::id time_get<char, const char*>::id; |
|
747 */ |
|
748 |
|
749 template <> |
|
750 _STLP_DECLSPEC locale::id time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; |
|
751 /* |
|
752 template <> |
|
753 _STLP_DECLSPEC locale::id time_put<char, char*>::id; |
|
754 */ |
|
755 |
|
756 # if !defined (_STLP_NO_WCHAR_T) |
|
757 template <> |
|
758 _STLP_DECLSPEC locale::id time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
759 /* |
|
760 template <> |
|
761 _STLP_DECLSPEC locale::id time_get<wchar_t, const wchar_t*>::id; |
|
762 */ |
|
763 |
|
764 template <> |
|
765 _STLP_DECLSPEC locale::id time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
766 /* |
|
767 template <> |
|
768 _STLP_DECLSPEC locale::id time_put<wchar_t, wchar_t*>::id; |
|
769 */ |
|
770 # endif /* _STLP_NO_WCHAR_T */ |
|
771 |
|
772 template <> |
|
773 _STLP_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id; |
|
774 /* |
|
775 template <> |
|
776 _STLP_DECLSPEC locale::id money_get<char, const char*>::id; |
|
777 */ |
|
778 |
|
779 template <> |
|
780 _STLP_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; |
|
781 /* |
|
782 template <> |
|
783 _STLP_DECLSPEC locale::id money_put<char, char*>::id; |
|
784 */ |
|
785 |
|
786 # if !defined (_STLP_NO_WCHAR_T) |
|
787 template <> |
|
788 _STLP_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
789 /* |
|
790 template <> |
|
791 _STLP_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id; |
|
792 */ |
|
793 |
|
794 template <> |
|
795 _STLP_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
796 /* |
|
797 template <> |
|
798 _STLP_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id; |
|
799 */ |
|
800 # endif |
|
801 |
|
802 template <> |
|
803 _STLP_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id; |
|
804 /* |
|
805 template <> |
|
806 _STLP_DECLSPEC locale::id num_get<char, const char*>::id; |
|
807 */ |
|
808 |
|
809 # if !defined (STLP_NO_WCHAR_T) |
|
810 template <> |
|
811 _STLP_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
812 /* |
|
813 template <> |
|
814 _STLP_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id; |
|
815 */ |
|
816 # endif |
|
817 |
|
818 template <> |
|
819 _STLP_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; |
|
820 /* |
|
821 template <> |
|
822 _STLP_DECLSPEC locale::id num_put<char, char*>::id; |
|
823 */ |
|
824 |
|
825 # if !defined (_STLP_NO_WCHAR_T) |
|
826 template <> |
|
827 _STLP_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
828 /* |
|
829 template <> |
|
830 _STLP_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id; |
|
831 */ |
|
832 # endif |
|
833 #endif |
|
834 |
|
835 // Declarations of (non-template) facets' static data members |
|
836 # if defined(__SYMBIAN32__WSD__) |
|
837 /* no definitions */ |
|
838 #elif defined (__EPOC32__) |
|
839 |
|
840 locale::id collate<char>::id = { 1 }; |
|
841 locale::id ctype<char>::id = { 2 }; |
|
842 |
|
843 #ifndef _STLP_NO_MBSTATE_T |
|
844 locale::id codecvt<char, char, mbstate_t>::id = { 3 }; |
|
845 # ifndef _STLP_NO_WCHAR_T |
|
846 locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 }; |
|
847 # endif |
|
848 #endif |
|
849 |
|
850 locale::id moneypunct<char, true>::id = { 4 }; |
|
851 locale::id moneypunct<char, false>::id = { 5 }; |
|
852 locale::id numpunct<char>::id = { 6 } ; |
|
853 locale::id messages<char>::id = { 7 }; |
|
854 |
|
855 #ifndef _STLP_NO_WCHAR_T |
|
856 locale::id collate<wchar_t>::id = { 20 }; |
|
857 locale::id ctype<wchar_t>::id = { 21 }; |
|
858 |
|
859 locale::id moneypunct<wchar_t, true>::id = { 23 } ; |
|
860 locale::id moneypunct<wchar_t, false>::id = { 24 } ; |
|
861 |
|
862 locale::id numpunct<wchar_t>::id = { 25 }; |
|
863 locale::id messages<wchar_t>::id = { 26 }; |
|
864 #endif |
|
865 |
|
866 #if defined(__SYMBIAN32__NO_STATIC_IMPORTS__) |
|
867 //ACCESS FUNCTIONS |
|
868 _STLP_DECLSPEC locale::id& collate<char>::GetFacetLocaleId() |
|
869 { |
|
870 return collate<char>::id; |
|
871 } |
|
872 _STLP_DECLSPEC locale::id& ctype<char>::GetFacetLocaleId() |
|
873 { |
|
874 return ctype<char>::id; |
|
875 } |
|
876 #ifndef _STLP_NO_MBSTATE_T |
|
877 _STLP_DECLSPEC locale::id& codecvt<char, char, mbstate_t>::GetFacetLocaleId() |
|
878 { |
|
879 return codecvt<char, char, mbstate_t>::id; |
|
880 } |
|
881 # ifndef _STLP_NO_WCHAR_T |
|
882 _STLP_DECLSPEC locale::id& codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId() |
|
883 { |
|
884 return codecvt<wchar_t, char, mbstate_t>::id; |
|
885 } |
|
886 # endif |
|
887 #endif |
|
888 |
|
889 _STLP_DECLSPEC locale::id& moneypunct<char, true>::GetFacetLocaleId() |
|
890 { |
|
891 return moneypunct<char, true>::id; |
|
892 } |
|
893 _STLP_DECLSPEC locale::id& moneypunct<char, false>::GetFacetLocaleId() |
|
894 { |
|
895 return moneypunct<char, false>::id; |
|
896 } |
|
897 _STLP_DECLSPEC locale::id& numpunct<char>::GetFacetLocaleId() |
|
898 { |
|
899 return numpunct<char>::id; |
|
900 } |
|
901 _STLP_DECLSPEC locale::id& messages<char>::GetFacetLocaleId() |
|
902 { |
|
903 return messages<char>::id; |
|
904 } |
|
905 #ifndef _STLP_NO_WCHAR_T |
|
906 _STLP_DECLSPEC locale::id& collate<wchar_t>::GetFacetLocaleId() |
|
907 { |
|
908 return collate<wchar_t>::id; |
|
909 } |
|
910 _STLP_DECLSPEC locale::id& ctype<wchar_t>::GetFacetLocaleId() |
|
911 { |
|
912 return ctype<wchar_t>::id; |
|
913 } |
|
914 _STLP_DECLSPEC locale::id& moneypunct<wchar_t, true>::GetFacetLocaleId() |
|
915 { |
|
916 return moneypunct<wchar_t, true>::id; |
|
917 } |
|
918 _STLP_DECLSPEC locale::id& moneypunct<wchar_t, false>::GetFacetLocaleId() |
|
919 { |
|
920 return moneypunct<wchar_t, false>::id; |
|
921 } |
|
922 _STLP_DECLSPEC locale::id& numpunct<wchar_t>::GetFacetLocaleId() |
|
923 { |
|
924 return numpunct<wchar_t>::id; |
|
925 } |
|
926 _STLP_DECLSPEC locale::id& messages<wchar_t>::GetFacetLocaleId() |
|
927 { |
|
928 return messages<wchar_t>::id; |
|
929 } |
|
930 #endif |
|
931 template <> |
|
932 _STLP_DECLSPEC locale::id& money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
933 { |
|
934 return money_get<char, istreambuf_iterator<char, char_traits<char> > >::id; |
|
935 } |
|
936 template <> |
|
937 _STLP_DECLSPEC locale::id& money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
938 { |
|
939 return money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; |
|
940 } |
|
941 # if !defined (_STLP_NO_WCHAR_T) |
|
942 template <> |
|
943 _STLP_DECLSPEC locale::id& money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
944 { |
|
945 return money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
946 } |
|
947 template <> |
|
948 _STLP_DECLSPEC locale::id& money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
949 { |
|
950 return money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
951 } |
|
952 # endif |
|
953 template <> |
|
954 _STLP_DECLSPEC locale::id& num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
955 { |
|
956 return num_get<char, istreambuf_iterator<char, char_traits<char> > >::id; |
|
957 } |
|
958 # if !defined (STLP_NO_WCHAR_T) |
|
959 template <> |
|
960 _STLP_DECLSPEC locale::id& num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
961 { |
|
962 return num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
963 } |
|
964 # endif |
|
965 template <> |
|
966 _STLP_DECLSPEC locale::id& num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
967 { |
|
968 return num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; |
|
969 } |
|
970 # if !defined (_STLP_NO_WCHAR_T) |
|
971 template <> |
|
972 _STLP_DECLSPEC locale::id& num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
973 { |
|
974 return num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
975 } |
|
976 # endif |
|
977 template <> |
|
978 _STLP_DECLSPEC locale::id& |
|
979 time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
980 { |
|
981 return time_get<char, istreambuf_iterator<char, char_traits<char> > >::id; |
|
982 } |
|
983 template <> |
|
984 _STLP_DECLSPEC locale::id& |
|
985 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId() |
|
986 { |
|
987 return time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; |
|
988 } |
|
989 # ifndef _STLP_NO_WCHAR_T |
|
990 template <> |
|
991 _STLP_DECLSPEC locale::id& |
|
992 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
993 { |
|
994 return time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
995 } |
|
996 template <> |
|
997 _STLP_DECLSPEC locale::id& |
|
998 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId() |
|
999 { |
|
1000 return time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; |
|
1001 } |
|
1002 # endif |
|
1003 |
|
1004 # endif // __SYMBIAN32__NO_STATIC_IMPORTS__ |
|
1005 |
|
1006 |
|
1007 #else // original STLPort |
|
1008 |
|
1009 // size_t locale::id::_S_max = 39; // made before |
|
1010 |
|
1011 _STLP_STATIC_MEMBER_DECLSPEC locale::id collate<char>::id = { 1 }; |
|
1012 _STLP_STATIC_MEMBER_DECLSPEC locale::id ctype<char>::id = { 2 }; |
|
1013 |
|
1014 #ifndef _STLP_NO_MBSTATE_T |
|
1015 _STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt<char, char, mbstate_t>::id = { 3 }; |
|
1016 # ifndef _STLP_NO_WCHAR_T |
|
1017 _STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 }; |
|
1018 # endif |
|
1019 #endif |
|
1020 |
|
1021 _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<char, true>::id = { 4 }; |
|
1022 _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<char, false>::id = { 5 }; |
|
1023 _STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct<char>::id = { 6 } ; |
|
1024 _STLP_STATIC_MEMBER_DECLSPEC locale::id messages<char>::id = { 7 }; |
|
1025 |
|
1026 #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564) |
|
1027 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 8 }; |
|
1028 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 10 }; |
|
1029 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 12 }; |
|
1030 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 14 }; |
|
1031 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 16 }; |
|
1032 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 18 }; |
|
1033 /* |
|
1034 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<char, const char*>::id = { 9 }; |
|
1035 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<char, char*>::id = { 11 }; |
|
1036 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<char, const char*>::id = { 13 }; |
|
1037 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<char, char*>::id = { 15 }; |
|
1038 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<char, const char*>::id = { 17 }; |
|
1039 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<char, char*>::id = { 19 }; |
|
1040 */ |
|
1041 #endif |
|
1042 |
|
1043 #ifndef _STLP_NO_WCHAR_T |
|
1044 _STLP_STATIC_MEMBER_DECLSPEC locale::id collate<wchar_t>::id = { 20 }; |
|
1045 _STLP_STATIC_MEMBER_DECLSPEC locale::id ctype<wchar_t>::id = { 21 }; |
|
1046 |
|
1047 _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<wchar_t, true>::id = { 23 } ; |
|
1048 _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<wchar_t, false>::id = { 24 } ; |
|
1049 |
|
1050 _STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct<wchar_t>::id = { 25 }; |
|
1051 _STLP_STATIC_MEMBER_DECLSPEC locale::id messages<wchar_t>::id = { 26 }; |
|
1052 |
|
1053 #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564) |
|
1054 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 27 }; |
|
1055 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 29 }; |
|
1056 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 31 }; |
|
1057 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id = { 33 }; |
|
1058 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 35 }; |
|
1059 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 37 }; |
|
1060 /* |
|
1061 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id = { 28 }; |
|
1062 _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id = { 30 }; |
|
1063 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id = { 32 }; |
|
1064 _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id = { 34 }; |
|
1065 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<wchar_t, const wchar_t*>::id = { 36 }; |
|
1066 _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<wchar_t, wchar_t*>::id = { 38 }; |
|
1067 */ |
|
1068 # endif |
|
1069 #endif |
|
1070 # endif //!__SYMBIAN32__WSD__ |
|
1071 |
|
1072 _STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc) |
|
1073 { |
|
1074 _STLP_ASSERT( loc != 0 ); |
|
1075 loc->_M_incr(); |
|
1076 return loc; |
|
1077 } |
|
1078 |
|
1079 void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc) |
|
1080 { |
|
1081 _STLP_ASSERT( loc != 0 ); |
|
1082 if (loc->_M_decr() == 0) { |
|
1083 if (*loc != *_Stl_classic_locale) |
|
1084 delete loc; |
|
1085 else |
|
1086 loc->~_Locale_impl(); |
|
1087 loc = 0; |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 _STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc) |
|
1092 { |
|
1093 _STLP_ASSERT( loc != 0 ); |
|
1094 loc->_M_incr(); |
|
1095 _Locale_impl *loc_new = new _Locale_impl(*loc); |
|
1096 loc->_M_decr(); |
|
1097 loc_new->name = _Nameless; |
|
1098 return loc_new; |
|
1099 } |
|
1100 |
|
1101 #if defined(__SYMBIAN32__WSD__) |
|
1102 #undef id |
|
1103 #endif |
|
1104 |
|
1105 _STLP_END_NAMESPACE |
|
1106 |
|
1107 #if defined(__SYMBIAN32__WSD__) |
|
1108 void locale_impl_init() |
|
1109 { |
|
1110 //initialize _S_max |
|
1111 std::locale::id::get_locale_id_S_max() = 39; |
|
1112 |
|
1113 //initialize the mutex lock in locale.cpp |
|
1114 locale_index_lock_init(); |
|
1115 |
|
1116 //initialize _S_count of Init |
|
1117 std::ios_base::Init::ios_base_Init_S_count_init(); |
|
1118 |
|
1119 //initialize S_was_synced of ios_base |
|
1120 std::ios_base::ios_base_S_was_synced_init(); |
|
1121 |
|
1122 //initialize the mutex in locale_catalog.cpp |
|
1123 stlp_priv::locale_catalog_category_hash_lock_init(); |
|
1124 |
|
1125 //initialize category map in locale_catalog.cpp |
|
1126 stlp_priv::Category_Map_Init(); |
|
1127 |
|
1128 //initialize empty string in monetary.cpp |
|
1129 monetary_empty_string_init(); |
|
1130 } |
|
1131 # endif //__SYMBIAN32__WSD__ |
|
1132 |
|
1133 |
|
1134 // locale use many static functions/pointers from this file: |
|
1135 // to avoid making ones extern, simple #include implementation of locale |
|
1136 |
|
1137 #include "locale.cpp" |
|
1138 |