Update contrib.
2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
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.
20 # include "stlport_prefix.h"
24 #include "locale_impl.h"
27 #include "locale_nonclassic.h"
30 #include <stl/_codecvt.h>
31 #include <stl/_collate.h>
32 #include <stl/_ctype.h>
33 #include <stl/_monetary.h>
34 #include <stl/_time_facets.h>
35 #include <stl/_messages_facets.h>
36 #include <stl/_istream.h>
37 #include <stl/_num_get.h>
38 #include <stl/_num_put.h>
40 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
41 #include "libstdcppwsd.h"
46 // those wrappers are needed to avoid extern "C"
48 void* _Loc_ctype_create(const char * s)
49 { return (void*)_Locale_ctype_create(s); }
50 void* _Loc_numeric_create(const char * s)
51 { return (void*)_Locale_numeric_create(s); }
52 void* _Loc_time_create(const char * s)
53 { return (void*)_Locale_time_create(s); }
54 void* _Loc_collate_create(const char * s)
55 { return (void*)_Locale_collate_create(s); }
56 void* _Loc_monetary_create(const char * s)
57 { return (void*)_Locale_monetary_create(s); }
58 void* _Loc_messages_create(const char * s)
59 { return (void*)_Locale_messages_create(s); }
61 char* _Loc_ctype_name(const void* l, char* s)
62 { return _Locale_ctype_name(l, s); }
63 char* _Loc_numeric_name(const void* l, char* s)
64 { return _Locale_numeric_name(l, s); }
65 char* _Loc_time_name(const void* l, char* s)
66 { return _Locale_time_name(l,s); }
67 char* _Loc_collate_name( const void* l, char* s)
68 { return _Locale_collate_name(l,s); }
69 char* _Loc_monetary_name(const void* l, char* s)
70 { return _Locale_monetary_name(l,s); }
71 char* _Loc_messages_name(const void* l, char* s)
72 { return _Locale_messages_name(l,s); }
74 const char* _Loc_ctype_default(char* p) { return _Locale_ctype_default(p); }
75 const char* _Loc_numeric_default(char * p) { return _Locale_numeric_default(p); }
76 const char* _Loc_time_default(char* p) { return _Locale_time_default(p); }
77 const char* _Loc_collate_default(char* p) { return _Locale_collate_default(p); }
78 const char* _Loc_monetary_default(char* p) { return _Locale_monetary_default(p); }
79 const char* _Loc_messages_default(char* p) { return _Locale_messages_default(p); }
81 void _Loc_ctype_destroy(void* p) {_Locale_ctype_destroy(p); }
82 void _Loc_numeric_destroy(void* p) {_Locale_numeric_destroy(p); }
83 void _Loc_time_destroy(void* p) {_Locale_time_destroy(p);}
84 void _Loc_collate_destroy(void* p) {_Locale_collate_destroy(p);}
85 void _Loc_monetary_destroy(void* p) {_Locale_monetary_destroy(p);}
86 void _Loc_messages_destroy(void* p) {_Locale_messages_destroy(p);}
88 typedef void* (*loc_create_func_t)(const char *);
89 typedef char* (*loc_name_func_t)(const void* l, char* s);
90 typedef void (*loc_destroy_func_t)(void* l);
91 typedef const char* (*loc_default_name_func_t)(char* s);
93 //----------------------------------------------------------------------
94 // Acquire and release low-level category objects. The whole point of
95 // this is so that we don't allocate (say) four different _Locale_ctype
96 // objects for a single locale.
97 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
99 bool operator()(const char* s1, const char* s2) const
100 { return strcmp(s1, s2) == 0; }
105 size_t operator()(const void* p) const
106 { return __REINTERPRET_CAST(size_t,p); }
109 template <class _Category_ptr>
110 struct __destroy_fun {
111 typedef void (*_fun_type)(_Category_ptr);
113 __destroy_fun(_fun_type __f) : _M_fun(__f) {}
114 void operator()(_Category_ptr __c) { _M_fun(__c); }
117 // Global hash tables for category objects.
118 typedef hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr> Category_Map;
120 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
121 // Look up a category by name
122 static hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>* ctype_hash;
123 static hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>* numeric_hash;
124 static hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>* time_hash;
125 static hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>* collate_hash;
126 static hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>* monetary_hash;
127 static hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>* messages_hash;
130 // We have a single lock for all of the hash tables. We may wish to
131 // replace it with six different locks.
133 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
134 _STLP_STATIC_MUTEX __category_hash_lock _STLP_MUTEX_INITIALIZER;
137 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
138 void locale_catalog_category_hash_lock_init()
140 get_locale_catalog_category_hash_lock()._M_lock.iState = _ENeedsNormalInit;
141 get_locale_catalog_category_hash_lock()._M_lock.iPtr = 0;
142 get_locale_catalog_category_hash_lock()._M_lock.iReentry = 0;
147 __acquire_category(const char* name, loc_create_func_t create_obj,
148 loc_default_name_func_t default_obj, Category_Map ** M)
150 typedef Category_Map::iterator Category_iterator;
151 pair<Category_iterator, bool> result;
152 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
153 _STLP_auto_lock sentry(get_locale_catalog_category_hash_lock());
155 _STLP_auto_lock sentry(__category_hash_lock);
158 typedef const char* key_type;
162 *M = new Category_Map();
164 #if defined(__SC__) //*TY 06/01/2000 - added workaround for SCpp
165 if(!*M) delete *M; //*TY 06/01/2000 - it forgets to generate dtor for Category_Map class. This fake code forces to generate one.
166 #endif //*TY 06/01/2000 -
168 // Find what name to look for. Be careful if user requests the default.
169 char buf[_Locale_MAX_SIMPLE_NAME];
170 if (name == 0 || name[0] == 0)
171 name = default_obj(buf);
172 if (name == 0 || name[0] == 0)
175 pair<const key_type, pair<void*,size_t> > __e(name, pair<void*,size_t>((void*)0,size_t(0)));
177 // Look for an existing entry with that name.
179 result = (*M)->insert_noresize(__e);
181 // There was no entry in the map already. Create the category.
183 (*result.first).second.first = create_obj(name);
185 // Increment the reference count.
186 ++((*result.first).second.second);
188 return (*result.first).second.first;
193 __release_category(void* cat,
194 loc_destroy_func_t destroy_fun,
195 loc_name_func_t get_name,
198 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
199 _STLP_auto_lock sentry(get_locale_catalog_category_hash_lock());
201 _STLP_auto_lock sentry(__category_hash_lock);
205 // Find the name of the category object.
206 char buf[_Locale_MAX_SIMPLE_NAME + 1];
207 char* name = get_name(cat, buf);
210 Category_Map::iterator it = (*M)->find(name);
211 if (it != (*M)->end()) {
212 // Decrement the ref count. If it goes to zero, delete this category
214 if (--((*it).second.second) == 0) {
215 void* cat1 = (*it).second.first;
226 _Locale_ctype* _STLP_CALL __acquire_ctype(const char* name)
228 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
229 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& ctype_hash = get_locale_catalog_ctype_hash();
231 return __REINTERPRET_CAST(_Locale_ctype*,
232 __acquire_category(name, _Loc_ctype_create, _Loc_ctype_default, &ctype_hash));
235 _Locale_numeric* _STLP_CALL __acquire_numeric(const char* name)
237 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
238 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& numeric_hash = get_locale_catalog_numeric_hash();
240 return __REINTERPRET_CAST(_Locale_numeric*,
241 __acquire_category(name, _Loc_numeric_create, _Loc_numeric_default, &numeric_hash)); }
242 _STLP_EXP_DECLSPEC _Locale_time* _STLP_CALL __acquire_time(const char* name)
244 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
245 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& time_hash = get_locale_catalog_time_hash();
247 return __REINTERPRET_CAST(_Locale_time*,
248 __acquire_category(name, _Loc_time_create, _Loc_time_default, &time_hash)); }
249 _Locale_collate* _STLP_CALL __acquire_collate(const char* name)
251 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
252 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& collate_hash = get_locale_catalog_collate_hash();
254 return __REINTERPRET_CAST(_Locale_collate*,
255 __acquire_category(name, _Loc_collate_create, _Loc_collate_default, &collate_hash)); }
256 _Locale_monetary* _STLP_CALL __acquire_monetary(const char* name)
258 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
259 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& monetary_hash = get_locale_catalog_monetary_hash();
261 return __REINTERPRET_CAST(_Locale_monetary*,
262 __acquire_category(name, _Loc_monetary_create, _Loc_monetary_default, &monetary_hash)); }
263 _Locale_messages* _STLP_CALL __acquire_messages(const char* name)
265 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
266 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& messages_hash = get_locale_catalog_messages_hash();
268 return __REINTERPRET_CAST(_Locale_messages*,
269 __acquire_category(name, _Loc_messages_create, _Loc_messages_default, &messages_hash)); }
271 void _STLP_CALL __release_ctype(_Locale_ctype* cat) {
272 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
273 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& ctype_hash = get_locale_catalog_ctype_hash();
274 __release_category(cat, _Loc_ctype_destroy, _Loc_ctype_name, &ctype_hash);
276 __release_category(cat, _Loc_ctype_destroy, _Loc_ctype_name, &ctype_hash);
279 void _STLP_CALL __release_numeric(_Locale_numeric* cat) {
280 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
281 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& numeric_hash = get_locale_catalog_numeric_hash();
282 __release_category(cat, _Loc_numeric_destroy, _Loc_numeric_name, &numeric_hash);
284 __release_category(cat, _Loc_numeric_destroy, _Loc_numeric_name, &numeric_hash);
287 _STLP_EXP_DECLSPEC void _STLP_CALL __release_time(_Locale_time* cat) {
288 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
289 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& time_hash = get_locale_catalog_time_hash();
290 __release_category(cat, _Loc_time_destroy, _Loc_time_name, &time_hash);
292 __release_category(cat, _Loc_time_destroy, _Loc_time_name, &time_hash);
295 void _STLP_CALL __release_collate(_Locale_collate* cat) {
296 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
297 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& collate_hash = get_locale_catalog_collate_hash();
298 __release_category(cat, _Loc_collate_destroy, _Loc_collate_name, &collate_hash);
300 __release_category(cat, _Loc_collate_destroy, _Loc_collate_name, &collate_hash);
303 void _STLP_CALL __release_monetary(_Locale_monetary* cat) {
304 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
305 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& monetary_hash = get_locale_catalog_monetary_hash();
306 __release_category(cat, _Loc_monetary_destroy, _Loc_monetary_name, &monetary_hash);
308 __release_category(cat, _Loc_monetary_destroy, _Loc_monetary_name, &monetary_hash);
311 void _STLP_CALL __release_messages(_Locale_messages* cat) {
312 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
313 hash_map<const char*, pair<void*, size_t>, hash<const char*>, __eqstr>*& messages_hash = get_locale_catalog_messages_hash();
314 __release_category(cat, _Loc_messages_destroy, _Loc_messages_name, &messages_hash);
316 __release_category(cat, _Loc_messages_destroy, _Loc_messages_name, &messages_hash);
322 // <locale> content which is dependent on the name
325 template <class Facet>
326 inline locale::facet*
327 _Locale_insert(_Locale* __that, Facet* f) {
328 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
329 return __that->insert(f, Facet::GetFacetLocaleId()._M_index, false);
331 return __that->insert(f, Facet::id._M_index, false);
335 // Give L a name where all facets except those in category c
336 // are taken from name1, and those in category c are taken from name2.
337 void _Stl_loc_combine_names(_Locale* L,
338 const char* name1, const char* name2,
341 if ((c & locale::all) == 0 || strcmp(name1, name2) == 0)
343 else if ((c & locale::all) == locale::all)
346 // Decompose the names.
347 char ctype_buf[_Locale_MAX_SIMPLE_NAME];
348 char numeric_buf[_Locale_MAX_SIMPLE_NAME];
349 char time_buf[_Locale_MAX_SIMPLE_NAME];
350 char collate_buf[_Locale_MAX_SIMPLE_NAME];
351 char monetary_buf[_Locale_MAX_SIMPLE_NAME];
352 char messages_buf[_Locale_MAX_SIMPLE_NAME];
354 _Locale_extract_ctype_name((c & locale::ctype) ? name2 : name1,
356 _Locale_extract_numeric_name((c & locale::numeric) ? name2 : name1,
358 _Locale_extract_time_name((c & locale::time) ? name2 : name1,
360 _Locale_extract_collate_name((c & locale::collate) ? name2 : name1,
362 _Locale_extract_monetary_name((c & locale::monetary) ? name2 : name1,
364 _Locale_extract_messages_name((c & locale::messages) ? name2 : name1,
367 // Construct a new composite name.
368 char composite_buf[_Locale_MAX_COMPOSITE_NAME];
369 _Locale_compose_name(composite_buf,
370 ctype_buf, numeric_buf, time_buf,
371 collate_buf, monetary_buf, messages_buf,
373 L->name = composite_buf;
378 // Create a locale from a name.
379 _STLP_EXP_DECLSPEC locale::locale(const char* name)
383 _M_throw_runtime_error(0);
384 else if(strcmp(name,"")==0)
385 name = _Locale_ctype_default(NULL);
390 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
391 impl = new _Locale(get_locale_id_S_max(), name);
393 impl = new _Locale(locale::id::_S_max, name);
397 // Insert categories one at a time.
398 impl->insert_ctype_facets(name);
399 impl->insert_numeric_facets(name);
400 impl->insert_time_facets(name);
401 impl->insert_collate_facets(name);
402 impl->insert_monetary_facets(name);
403 impl->insert_messages_facets(name);
407 _STLP_UNWIND(delete impl);
410 // Create a locale that's a copy of L, except that all of the facets
411 // in category c are instead constructed by name.
412 _STLP_EXP_DECLSPEC locale::locale(const locale& L, const char* name, locale::category c)
415 if (name == 0 || strcmp(name, "*") == 0)
416 _M_throw_runtime_error(name);
421 impl = new _Locale(*L._M_impl);
422 _Stl_loc_combine_names(impl, L._M_impl->name.c_str(), name, c);
424 if (c & locale::ctype)
425 impl->insert_ctype_facets(name);
426 if (c & locale::numeric)
427 impl->insert_numeric_facets(name);
428 if (c & locale::time)
429 impl->insert_time_facets(name);
430 if (c & locale::collate)
431 impl->insert_collate_facets(name);
432 if (c & locale::monetary)
433 impl->insert_monetary_facets(name);
434 if (c & locale::messages)
435 impl->insert_messages_facets(name);
438 _STLP_UNWIND(delete impl)
442 // Contruct a new locale where all facets that aren't in category c
443 // come from L1, and all those that are in category c come from L2.
444 _STLP_EXP_DECLSPEC locale::locale(const locale& L1, const locale& L2, category c)
447 _Locale* impl = new _Locale(*L1._M_impl);
449 _Locale_impl* i2 = L2._M_impl;
451 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
452 const string nameless("*");
454 static string nameless("*");
457 if (L1.name() != nameless && L2.name() != nameless)
458 _Stl_loc_combine_names(impl,
459 L1._M_impl->name.c_str(), L2._M_impl->name.c_str(),
466 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
467 impl->insert( i2, _STLP_STD::collate<char>::GetFacetLocaleId());
469 impl->insert( i2, _STLP_STD::collate<char>::id);
471 # ifndef _STLP_NO_WCHAR_T
472 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
473 impl->insert( i2, _STLP_STD::collate<wchar_t>::GetFacetLocaleId());
475 impl->insert( i2, _STLP_STD::collate<wchar_t>::id);
476 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
477 # endif //!_STLP_NO_WCHAR_T
480 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
481 impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::GetFacetLocaleId());
482 impl->insert( i2, _STLP_STD::ctype<char>::GetFacetLocaleId());
484 impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::id);
485 impl->insert( i2, _STLP_STD::ctype<char>::id);
486 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
488 # ifndef _STLP_NO_WCHAR_T
489 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
490 impl->insert( i2, _STLP_STD::ctype<wchar_t>::GetFacetLocaleId());
491 impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId());
493 impl->insert( i2, _STLP_STD::ctype<wchar_t>::id);
494 impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::id);
495 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
496 # endif //!_STLP_NO_WCHAR_T
499 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
500 impl->insert( i2, _STLP_STD::moneypunct<char, true>::GetFacetLocaleId());
501 impl->insert( i2, _STLP_STD::moneypunct<char, false>::GetFacetLocaleId());
502 impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
503 impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
505 impl->insert( i2, _STLP_STD::moneypunct<char, true>::id);
506 impl->insert( i2, _STLP_STD::moneypunct<char, false>::id);
507 impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
508 impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
509 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
511 # ifndef _STLP_NO_WCHAR_T
512 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
513 impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::GetFacetLocaleId());
514 impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::GetFacetLocaleId());
515 impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
516 impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
518 impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::id);
519 impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::id);
520 impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
521 impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
522 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
523 # endif //!_STLP_NO_WCHAR_T
526 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
527 impl->insert( i2, _STLP_STD::numpunct<char>::GetFacetLocaleId());
528 impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
529 impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
531 impl->insert( i2, _STLP_STD::numpunct<char>::id);
532 impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
533 impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
536 # ifndef _STLP_NO_WCHAR_T
537 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
538 impl->insert(i2, _STLP_STD::numpunct<wchar_t>::GetFacetLocaleId());
539 impl->insert( i2, num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
540 impl->insert( i2, num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
542 impl->insert( i2, _STLP_STD::numpunct<wchar_t>::id);
543 impl->insert( i2, num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
544 impl->insert( i2, num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
545 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
546 # endif //!_STLP_NO_WCHAR_T
549 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
550 impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
551 impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
553 impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
554 impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
555 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
556 # ifndef _STLP_NO_WCHAR_T
557 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
558 impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
559 impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
561 impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
562 impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
563 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
564 # endif //!_STLP_NO_WCHAR_T
567 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
568 impl->insert( i2, _STLP_STD::messages<char>::GetFacetLocaleId());
570 impl->insert( i2, _STLP_STD::messages<char>::id);
572 # ifndef _STLP_NO_WCHAR_T
573 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
574 impl->insert( i2, _STLP_STD::messages<wchar_t>::GetFacetLocaleId());
576 impl->insert( i2, _STLP_STD::messages<wchar_t>::id);
577 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
578 # endif //_STLP_NO_WCHAR_T
583 // Six functions, one for each category. Each of them takes a
584 // _Locale* and a name, constructs that appropriate category
585 // facets by name, and inserts them into the locale.
587 void _Locale::insert_ctype_facets(const char* pname)
589 char buf[_Locale_MAX_SIMPLE_NAME];
590 _Locale_impl* i2 = locale::classic()._M_impl;
592 if (pname == 0 || pname[0] == 0)
593 pname = _Locale_ctype_default(buf);
595 if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
596 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
597 this->insert(i2, ctype<char>::GetFacetLocaleId());
599 this->insert(i2, ctype<char>::id);
601 # ifndef _STLP_NO_MBSTATE_T
602 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
603 this->insert(i2, codecvt<char, char, mbstate_t>::GetFacetLocaleId());
605 this->insert(i2, codecvt<char, char, mbstate_t>::id);
606 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
607 # endif //!_STLP_NO_MBSTATE_T
608 # ifndef _STLP_NO_WCHAR_T
609 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
610 this->insert(i2, ctype<wchar_t>::GetFacetLocaleId());
612 this->insert(i2, ctype<wchar_t>::id);
613 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
614 # ifndef _STLP_NO_MBSTATE_T
615 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
616 this->insert(i2, codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId());
618 this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
619 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
620 # endif //!_STLP_NO_MBSTATE_T
621 # endif //!_STLP_NO_WCHAR_T
625 # ifndef _STLP_NO_MBSTATE_T
626 codecvt<char, char, mbstate_t>* cvt = 0;
628 # ifndef _STLP_NO_WCHAR_T
629 ctype<wchar_t>* wct = 0;
630 codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
633 ct = new ctype_byname<char>(pname);
634 # ifndef _STLP_NO_MBSTATE_T
635 cvt = new codecvt_byname<char, char, mbstate_t>(pname);
637 # ifndef _STLP_NO_WCHAR_T
638 wct = new ctype_byname<wchar_t>(pname);
639 wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname);
643 # ifndef _STLP_NO_WCHAR_T
644 # ifdef _STLP_NO_MBSTATE_T
645 _STLP_UNWIND(delete ct; delete wct; delete wcvt);
647 _STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
650 # ifdef _STLP_NO_MBSTATE_T
651 _STLP_UNWIND(delete ct);
653 _STLP_UNWIND(delete ct; delete cvt);
656 _Locale_insert(this, ct);
657 # ifndef _STLP_NO_MBSTATE_T
658 _Locale_insert(this, cvt);
660 # ifndef _STLP_NO_WCHAR_T
661 _Locale_insert(this, wct);
662 _Locale_insert(this, wcvt);
667 void _Locale::insert_numeric_facets(const char* pname)
669 _Locale_impl* i2 = locale::classic()._M_impl;
671 numpunct<char>* punct = 0;
672 num_get<char, istreambuf_iterator<char, char_traits<char> > >* get = 0;
673 num_put<char, ostreambuf_iterator<char, char_traits<char> > >* put = 0;
674 # ifndef _STLP_NO_WCHAR_T
675 numpunct<wchar_t>* wpunct = 0;
676 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >* wget = 0;
677 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >* wput = 0;
680 char buf[_Locale_MAX_SIMPLE_NAME];
681 if (pname == 0 || pname[0] == 0)
682 pname = _Locale_numeric_default(buf);
684 if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
685 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
686 this->insert(i2, numpunct<char>::GetFacetLocaleId());
687 this->insert(i2, num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
688 this->insert(i2, num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
690 this->insert(i2, numpunct<char>::id);
691 this->insert(i2, num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
692 this->insert(i2, num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
695 # ifndef _STLP_NO_WCHAR_T
696 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
697 this->insert(i2, numpunct<wchar_t>::GetFacetLocaleId());
698 this->insert(i2, num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
699 this->insert(i2, num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
701 this->insert(i2, numpunct<wchar_t>::id);
702 this->insert(i2, num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
703 this->insert(i2, num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
704 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
705 # endif //!_STLP_NO_WCHAR_T
709 punct = new numpunct_byname<char>(pname);
710 get = new num_get<char, istreambuf_iterator<char, char_traits<char> > >;
711 put = new num_put<char, ostreambuf_iterator<char, char_traits<char> > >;
712 # ifndef _STLP_NO_WCHAR_T
713 wpunct = new numpunct_byname<wchar_t>(pname);
714 wget = new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
715 wput = new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
718 # ifndef _STLP_NO_WCHAR_T
719 _STLP_UNWIND(delete punct; delete wpunct; delete get; delete wget;
720 delete put; delete wput);
722 _STLP_UNWIND(delete punct; delete get;delete put);
725 _Locale_insert(this,punct);
726 _Locale_insert(this,get);
727 _Locale_insert(this,put);
729 # ifndef _STLP_NO_WCHAR_T
730 _Locale_insert(this,wpunct);
731 _Locale_insert(this,wget);
732 _Locale_insert(this,wput);
737 void _Locale::insert_time_facets(const char* pname)
739 _Locale_impl* i2 = locale::classic()._M_impl;
740 time_get<char, istreambuf_iterator<char, char_traits<char> > >* get = 0;
741 time_put<char, ostreambuf_iterator<char, char_traits<char> > >* put = 0;
742 # ifndef _STLP_NO_WCHAR_T
743 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >* wget = 0;
744 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >* wput = 0;
747 char buf[_Locale_MAX_SIMPLE_NAME];
748 if (pname == 0 || pname[0] == 0)
749 pname = _Locale_time_default(buf);
751 if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
753 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
755 time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
757 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
760 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
762 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
764 # ifndef _STLP_NO_WCHAR_T
765 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
767 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
769 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
772 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
774 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
776 # endif //!_STLP_NO_WCHAR_T
780 get = new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(pname);
781 put = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(pname);
782 # ifndef _STLP_NO_WCHAR_T
783 wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname);
784 wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname);
787 # ifndef _STLP_NO_WCHAR_T
788 _STLP_UNWIND(delete get; delete wget; delete put; delete wput);
790 _STLP_UNWIND(delete get; delete put);
792 _Locale_insert(this,get);
793 _Locale_insert(this,put);
794 # ifndef _STLP_NO_WCHAR_T
795 _Locale_insert(this,wget);
796 _Locale_insert(this,wput);
801 void _Locale::insert_collate_facets(const char* nam)
803 _Locale_impl* i2 = locale::classic()._M_impl;
805 collate<char>* col = 0;
806 # ifndef _STLP_NO_WCHAR_T
807 collate<wchar_t>* wcol = 0;
810 char buf[_Locale_MAX_SIMPLE_NAME];
811 if (nam == 0 || nam[0] == 0)
812 nam = _Locale_collate_default(buf);
814 if (nam == 0 || nam[0] == 0 || strcmp(nam, "C") == 0) {
815 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
816 this->insert(i2, collate<char>::GetFacetLocaleId());
818 this->insert(i2, collate<char>::id);
820 # ifndef _STLP_NO_WCHAR_T
821 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
822 this->insert(i2, collate<wchar_t>::GetFacetLocaleId());
824 this->insert(i2, collate<wchar_t>::id);
825 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
826 # endif//_STLP_NO_WCHAR_T
830 col = new collate_byname<char>(nam);
831 # ifndef _STLP_NO_WCHAR_T
832 wcol = new collate_byname<wchar_t>(nam);
835 # ifndef _STLP_NO_WCHAR_T
836 _STLP_UNWIND(delete col; delete wcol);
838 _STLP_UNWIND(delete col);
840 _Locale_insert(this,col);
841 # ifndef _STLP_NO_WCHAR_T
842 _Locale_insert(this,wcol);
847 void _Locale::insert_monetary_facets(const char* pname)
849 _Locale_impl* i2 = locale::classic()._M_impl;
851 moneypunct<char, false>* punct = 0;
852 moneypunct<char, true>* ipunct = 0;
853 money_get<char, istreambuf_iterator<char, char_traits<char> > >* get = 0;
854 money_put<char, ostreambuf_iterator<char, char_traits<char> > >* put = 0;
856 # ifndef _STLP_NO_WCHAR_T
857 moneypunct<wchar_t, false>* wpunct = 0;
858 moneypunct<wchar_t, true>* wipunct = 0;
859 money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >* wget = 0;
860 money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >* wput = 0;
863 char buf[_Locale_MAX_SIMPLE_NAME];
864 if (pname == 0 || pname[0] == 0)
865 pname = _Locale_monetary_default(buf);
867 if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
868 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
869 this->insert(i2, moneypunct<char, false>::GetFacetLocaleId());
870 this->insert(i2, moneypunct<char, true>::GetFacetLocaleId());
871 this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
872 this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
874 this->insert(i2, moneypunct<char, false>::id);
875 this->insert(i2, moneypunct<char, true>::id);
876 this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
877 this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
879 # ifndef _STLP_NO_WCHAR_T
880 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
881 this->insert( i2, moneypunct<wchar_t, false>::GetFacetLocaleId());
882 this->insert( i2, moneypunct<wchar_t, true>::GetFacetLocaleId());
883 this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
884 this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
886 this->insert(i2, moneypunct<wchar_t, false>::id);
887 this->insert(i2, moneypunct<wchar_t, true>::id);
888 this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
889 this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
890 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
895 punct = new moneypunct_byname<char, false>(pname);
896 ipunct = new moneypunct_byname<char, true>(pname);
897 get = new money_get<char, istreambuf_iterator<char, char_traits<char> > >;
898 put = new money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
899 # ifndef _STLP_NO_WCHAR_T
900 wpunct = new moneypunct_byname<wchar_t, false>(pname);
901 wipunct = new moneypunct_byname<wchar_t, true>(pname);
902 wget = new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
903 wput = new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
906 # ifndef _STLP_NO_WCHAR_T
907 _STLP_UNWIND(delete punct; delete ipunct; delete wpunct; delete wipunct;
908 delete get; delete wget; delete put; delete wput);
910 _STLP_UNWIND(delete punct; delete ipunct; delete get; delete put);
912 _Locale_insert(this,punct);
913 _Locale_insert(this,ipunct);
914 _Locale_insert(this,get);
915 _Locale_insert(this,put);
916 # ifndef _STLP_NO_WCHAR_T
917 _Locale_insert(this,wget);
918 _Locale_insert(this,wpunct);
919 _Locale_insert(this,wipunct);
920 _Locale_insert(this,wput);
926 void _Locale::insert_messages_facets(const char* pname)
928 _Locale_impl* i2 = locale::classic()._M_impl;
929 messages<char>* msg = 0;
930 # ifndef _STLP_NO_WCHAR_T
931 messages<wchar_t>* wmsg = 0;
934 char buf[_Locale_MAX_SIMPLE_NAME];
935 if (pname == 0 || pname[0] == 0)
936 pname = _Locale_messages_default(buf);
938 if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
939 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
940 this->insert(i2, messages<char>::GetFacetLocaleId());
942 this->insert(i2, messages<char>::id);
944 # ifndef _STLP_NO_WCHAR_T
945 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
946 this->insert(i2, messages<wchar_t>::GetFacetLocaleId());
948 this->insert(i2, messages<wchar_t>::id);
949 #endif //__LIBSTD_CPP_SYMBIAN32_WSD__
950 # endif //!_STLP_NO_WCHAR_T
954 msg = new messages_byname<char>(pname);
955 # ifndef _STLP_NO_WCHAR_T
956 wmsg = new messages_byname<wchar_t>(pname);
959 # ifndef _STLP_NO_WCHAR_T
960 _STLP_UNWIND(delete msg; delete wmsg);
962 _STLP_UNWIND(delete msg);
964 _Locale_insert(this,msg);
965 # ifndef _STLP_NO_WCHAR_T
966 _Locale_insert(this,wmsg);