Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlocale_impl.cpp
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1999 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 #include "stlport_prefix.h" 00019 00020 #include <locale> 00021 #include <algorithm> 00022 #include <typeinfo> 00023 00024 #include "c_locale.h" 00025 #include "aligned_buffer.h" 00026 #include "acquire_release.h" 00027 #include "locale_impl.h" 00028 00029 _STLP_BEGIN_NAMESPACE 00030 00031 static const string _Nameless("*"); 00032 00033 static inline bool is_C_locale_name (const char* name) 00034 { return ((name[0] == 'C') && (name[1] == 0)); } 00035 00036 locale::facet * _STLP_CALL _get_facet(locale::facet *f) 00037 { 00038 if (f != 0) 00039 f->_M_incr(); 00040 return f; 00041 } 00042 00043 void _STLP_CALL _release_facet(locale::facet *&f) 00044 { 00045 if ((f != 0) && (f->_M_decr() == 0)) { 00046 delete f; 00047 f = 0; 00048 } 00049 } 00050 00051 size_t locale::id::_S_max = 27; 00052 00053 static void _Stl_loc_assign_ids(); 00054 00055 static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf; 00056 00057 _Locale_impl::Init::Init() { 00058 if (_M_count()._M_incr() == 1) { 00059 _Locale_impl::_S_initialize(); 00060 } 00061 } 00062 00063 _Locale_impl::Init::~Init() { 00064 if (_M_count()._M_decr() == 0) { 00065 _Locale_impl::_S_uninitialize(); 00066 } 00067 } 00068 00069 _Refcount_Base& _Locale_impl::Init::_M_count() const { 00070 static _Refcount_Base _S_count(0); 00071 return _S_count; 00072 } 00073 00074 _Locale_impl::_Locale_impl(const char* s) 00075 : _Refcount_Base(0), name(s), facets_vec() { 00076 facets_vec.reserve( locale::id::_S_max ); 00077 new (&__Loc_init_buf) Init(); 00078 } 00079 00080 _Locale_impl::_Locale_impl( _Locale_impl const& locimpl ) 00081 : _Refcount_Base(0), name(locimpl.name), facets_vec() { 00082 for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet); 00083 facets_vec = locimpl.facets_vec; 00084 new (&__Loc_init_buf) Init(); 00085 } 00086 00087 _Locale_impl::_Locale_impl( size_t n, const char* s) 00088 : _Refcount_Base(0), name(s), facets_vec(n, 0) { 00089 new (&__Loc_init_buf) Init(); 00090 } 00091 00092 _Locale_impl::~_Locale_impl() { 00093 (&__Loc_init_buf)->~Init(); 00094 for_each( facets_vec.begin(), facets_vec.end(), _release_facet); 00095 } 00096 00097 // Initialization of the locale system. This must be called before 00098 // any locales are constructed. (Meaning that it must be called when 00099 // the I/O library itself is initialized.) 00100 void _STLP_CALL _Locale_impl::_S_initialize() { 00101 _Stl_loc_assign_ids(); 00102 make_classic_locale(); 00103 } 00104 00105 // Release of the classic locale ressources. Has to be called after the last 00106 // locale destruction and not only after the classic locale destruction as 00107 // the facets can be shared between different facets. 00108 void _STLP_CALL _Locale_impl::_S_uninitialize() { 00109 //Not necessary anymore as classic facets are now 'normal' dynamically allocated 00110 //facets with a reference counter telling to _release_facet when the facet can be 00111 //deleted. 00112 //free_classic_locale(); 00113 } 00114 00115 // _Locale_impl non-inline member functions. 00116 void _STLP_CALL _Locale_impl::_M_throw_bad_cast() { 00117 _STLP_THROW(bad_cast()); 00118 } 00119 00120 void _Locale_impl::insert(_Locale_impl *from, const locale::id& n) { 00121 if (n._M_index > 0 && n._M_index < from->size()) { 00122 this->insert(from->facets_vec[n._M_index], n); 00123 } 00124 } 00125 00126 locale::facet* _Locale_impl::insert(locale::facet *f, const locale::id& n) { 00127 if (f == 0 || n._M_index == 0) 00128 return 0; 00129 00130 if (n._M_index >= facets_vec.size()) { 00131 facets_vec.resize(n._M_index + 1); 00132 } 00133 00134 if (f != facets_vec[n._M_index]) 00135 { 00136 _release_facet(facets_vec[n._M_index]); 00137 facets_vec[n._M_index] = _get_facet(f); 00138 } 00139 00140 return f; 00141 } 00142 00143 // 00144 // <locale> content which is dependent on the name 00145 // 00146 00147 /* Six functions, one for each category. Each of them takes a 00148 * a name, constructs that appropriate category facets by name, 00149 * and inserts them into the locale. */ 00150 _Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint) { 00151 if (name[0] == 0) 00152 name = _Locale_ctype_default(buf); 00153 00154 if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { 00155 _Locale_impl* i2 = locale::classic()._M_impl; 00156 this->insert(i2, ctype<char>::id); 00157 this->insert(i2, codecvt<char, char, mbstate_t>::id); 00158 #ifndef _STLP_NO_WCHAR_T 00159 this->insert(i2, ctype<wchar_t>::id); 00160 this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id); 00161 #endif 00162 } else { 00163 locale::facet* ct = 0; 00164 locale::facet* cvt = 0; 00165 #ifndef _STLP_NO_WCHAR_T 00166 locale::facet* wct = 0; 00167 locale::facet* wcvt = 0; 00168 #endif 00169 int __err_code; 00170 _Locale_ctype *__lct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code); 00171 if (!__lct) { 00172 locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); 00173 return hint; 00174 } 00175 00176 if (hint == 0) hint = _Locale_get_ctype_hint(__lct); 00177 00178 _STLP_TRY { 00179 ct = new ctype_byname<char>(__lct); 00180 } 00181 _STLP_UNWIND(_STLP_PRIV __release_ctype(__lct)); 00182 00183 _STLP_TRY { 00184 cvt = new codecvt_byname<char, char, mbstate_t>(name); 00185 } 00186 _STLP_UNWIND(delete ct); 00187 00188 #ifndef _STLP_NO_WCHAR_T 00189 _STLP_TRY { 00190 _Locale_ctype *__lwct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code); 00191 if (!__lwct) { 00192 locale::_M_throw_on_creation_failure(__err_code, name, "ctype"); 00193 return hint; 00194 } 00195 00196 _STLP_TRY { 00197 wct = new ctype_byname<wchar_t>(__lwct); 00198 } 00199 _STLP_UNWIND(_STLP_PRIV __release_ctype(__lwct)); 00200 00201 _Locale_codecvt *__lwcvt = _STLP_PRIV __acquire_codecvt(name, buf, hint, &__err_code); 00202 if (__lwcvt) { 00203 _STLP_TRY { 00204 wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(__lwcvt); 00205 } 00206 _STLP_UNWIND(_STLP_PRIV __release_codecvt(__lwcvt); delete wct); 00207 } 00208 } 00209 _STLP_UNWIND(delete cvt; delete ct); 00210 #endif 00211 00212 this->insert(ct, ctype<char>::id); 00213 this->insert(cvt, codecvt<char, char, mbstate_t>::id); 00214 #ifndef _STLP_NO_WCHAR_T 00215 this->insert(wct, ctype<wchar_t>::id); 00216 if (wcvt) this->insert(wcvt, codecvt<wchar_t, char, mbstate_t>::id); 00217 #endif 00218 } 00219 return hint; 00220 } 00221 00222 _Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint) { 00223 if (name[0] == 0) 00224 name = _Locale_numeric_default(buf); 00225 00226 _Locale_impl* i2 = locale::classic()._M_impl; 00227 00228 // We first insert name independant facets taken from the classic locale instance: 00229 this->insert(i2, 00230 num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); 00231 this->insert(i2, 00232 num_get<char, istreambuf_iterator<char, char_traits<char> > >::id); 00233 #ifndef _STLP_NO_WCHAR_T 00234 this->insert(i2, 00235 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00236 this->insert(i2, 00237 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00238 #endif 00239 00240 if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { 00241 this->insert(i2, numpunct<char>::id); 00242 #ifndef _STLP_NO_WCHAR_T 00243 this->insert(i2, numpunct<wchar_t>::id); 00244 #endif 00245 } 00246 else { 00247 locale::facet* punct = 0; 00248 #ifndef _STLP_NO_WCHAR_T 00249 locale::facet* wpunct = 0; 00250 #endif 00251 00252 int __err_code; 00253 _Locale_numeric *__lpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code); 00254 if (!__lpunct) { 00255 locale::_M_throw_on_creation_failure(__err_code, name, "numpunct"); 00256 return hint; 00257 } 00258 00259 if (hint == 0) hint = _Locale_get_numeric_hint(__lpunct); 00260 _STLP_TRY { 00261 punct = new numpunct_byname<char>(__lpunct); 00262 } 00263 _STLP_UNWIND(_STLP_PRIV __release_numeric(__lpunct)); 00264 00265 #ifndef _STLP_NO_WCHAR_T 00266 _Locale_numeric *__lwpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code); 00267 if (!__lwpunct) { 00268 delete punct; 00269 locale::_M_throw_on_creation_failure(__err_code, name, "numpunct"); 00270 return hint; 00271 } 00272 if (__lwpunct) { 00273 _STLP_TRY { 00274 wpunct = new numpunct_byname<wchar_t>(__lwpunct); 00275 } 00276 _STLP_UNWIND(_STLP_PRIV __release_numeric(__lwpunct); delete punct); 00277 } 00278 #endif 00279 00280 this->insert(punct, numpunct<char>::id); 00281 #ifndef _STLP_NO_WCHAR_T 00282 this->insert(wpunct, numpunct<wchar_t>::id); 00283 #endif 00284 } 00285 return hint; 00286 } 00287 00288 _Locale_name_hint* _Locale_impl::insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint) { 00289 if (name[0] == 0) 00290 name = _Locale_time_default(buf); 00291 00292 if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { 00293 _Locale_impl* i2 = locale::classic()._M_impl; 00294 this->insert(i2, 00295 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id); 00296 this->insert(i2, 00297 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); 00298 #ifndef _STLP_NO_WCHAR_T 00299 this->insert(i2, 00300 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00301 this->insert(i2, 00302 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00303 #endif 00304 } else { 00305 locale::facet *get = 0; 00306 locale::facet *put = 0; 00307 #ifndef _STLP_NO_WCHAR_T 00308 locale::facet *wget = 0; 00309 locale::facet *wput = 0; 00310 #endif 00311 00312 int __err_code; 00313 _Locale_time *__time = _STLP_PRIV __acquire_time(name, buf, hint, &__err_code); 00314 if (!__time) { 00315 // time facets category is not mandatory for correct stream behavior so if platform 00316 // do not support it we do not generate a runtime_error exception. 00317 if (__err_code == _STLP_LOC_NO_MEMORY) { 00318 _STLP_THROW_BAD_ALLOC; 00319 } 00320 return hint; 00321 } 00322 00323 if (!hint) hint = _Locale_get_time_hint(__time); 00324 _STLP_TRY { 00325 get = new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(__time); 00326 put = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(__time); 00327 #ifndef _STLP_NO_WCHAR_T 00328 wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(__time); 00329 wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(__time); 00330 #endif 00331 } 00332 #ifndef _STLP_NO_WCHAR_T 00333 _STLP_UNWIND(delete wget; delete put; delete get; _STLP_PRIV __release_time(__time)); 00334 #else 00335 _STLP_UNWIND(delete get; _STLP_PRIV __release_time(__time)); 00336 #endif 00337 00338 _STLP_PRIV __release_time(__time); 00339 00340 this->insert(get, time_get<char, istreambuf_iterator<char, char_traits<char> > >::id); 00341 this->insert(put, time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); 00342 #ifndef _STLP_NO_WCHAR_T 00343 this->insert(wget, time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00344 this->insert(wput, time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00345 #endif 00346 } 00347 return hint; 00348 } 00349 00350 _Locale_name_hint* _Locale_impl::insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint) { 00351 if (name[0] == 0) 00352 name = _Locale_collate_default(buf); 00353 00354 if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { 00355 _Locale_impl* i2 = locale::classic()._M_impl; 00356 this->insert(i2, collate<char>::id); 00357 #ifndef _STLP_NO_WCHAR_T 00358 this->insert(i2, collate<wchar_t>::id); 00359 #endif 00360 } 00361 else { 00362 locale::facet *col = 0; 00363 #ifndef _STLP_NO_WCHAR_T 00364 locale::facet *wcol = 0; 00365 #endif 00366 00367 int __err_code; 00368 _Locale_collate *__coll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code); 00369 if (!__coll) { 00370 if (__err_code == _STLP_LOC_NO_MEMORY) { 00371 _STLP_THROW_BAD_ALLOC; 00372 } 00373 return hint; 00374 } 00375 00376 if (hint == 0) hint = _Locale_get_collate_hint(__coll); 00377 _STLP_TRY { 00378 col = new collate_byname<char>(__coll); 00379 } 00380 _STLP_UNWIND(_STLP_PRIV __release_collate(__coll)); 00381 00382 #ifndef _STLP_NO_WCHAR_T 00383 _Locale_collate *__wcoll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code); 00384 if (!__wcoll) { 00385 if (__err_code == _STLP_LOC_NO_MEMORY) { 00386 delete col; 00387 _STLP_THROW_BAD_ALLOC; 00388 } 00389 } 00390 if (__wcoll) { 00391 _STLP_TRY { 00392 wcol = new collate_byname<wchar_t>(__wcoll); 00393 } 00394 _STLP_UNWIND(_STLP_PRIV __release_collate(__wcoll); delete col); 00395 } 00396 #endif 00397 00398 this->insert(col, collate<char>::id); 00399 #ifndef _STLP_NO_WCHAR_T 00400 if (wcol) this->insert(wcol, collate<wchar_t>::id); 00401 #endif 00402 } 00403 return hint; 00404 } 00405 00406 _Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint) { 00407 if (name[0] == 0) 00408 name = _Locale_monetary_default(buf); 00409 00410 _Locale_impl* i2 = locale::classic()._M_impl; 00411 00412 // We first insert name independant facets taken from the classic locale instance: 00413 this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id); 00414 this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id); 00415 #ifndef _STLP_NO_WCHAR_T 00416 this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00417 this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id); 00418 #endif 00419 00420 if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { 00421 this->insert(i2, moneypunct<char, false>::id); 00422 this->insert(i2, moneypunct<char, true>::id); 00423 #ifndef _STLP_NO_WCHAR_T 00424 this->insert(i2, moneypunct<wchar_t, false>::id); 00425 this->insert(i2, moneypunct<wchar_t, true>::id); 00426 #endif 00427 } 00428 else { 00429 locale::facet *punct = 0; 00430 locale::facet *ipunct = 0; 00431 00432 #ifndef _STLP_NO_WCHAR_T 00433 locale::facet* wpunct = 0; 00434 locale::facet* wipunct = 0; 00435 #endif 00436 00437 int __err_code; 00438 _Locale_monetary *__mon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); 00439 if (!__mon) { 00440 if (__err_code == _STLP_LOC_NO_MEMORY) { 00441 _STLP_THROW_BAD_ALLOC; 00442 } 00443 return hint; 00444 } 00445 00446 if (hint == 0) hint = _Locale_get_monetary_hint(__mon); 00447 00448 _STLP_TRY { 00449 punct = new moneypunct_byname<char, false>(__mon); 00450 } 00451 _STLP_UNWIND(_STLP_PRIV __release_monetary(__mon)); 00452 00453 _Locale_monetary *__imon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); 00454 if (!__imon) { 00455 delete punct; 00456 if (__err_code == _STLP_LOC_NO_MEMORY) { 00457 _STLP_THROW_BAD_ALLOC; 00458 } 00459 return hint; 00460 } 00461 00462 _STLP_TRY { 00463 ipunct = new moneypunct_byname<char, true>(__imon); 00464 } 00465 _STLP_UNWIND(_STLP_PRIV __release_monetary(__imon); delete punct); 00466 00467 #ifndef _STLP_NO_WCHAR_T 00468 _STLP_TRY { 00469 _Locale_monetary *__wmon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); 00470 if (!__wmon) { 00471 if (__err_code == _STLP_LOC_NO_MEMORY) { 00472 _STLP_THROW_BAD_ALLOC; 00473 } 00474 } 00475 00476 if (__wmon) { 00477 _STLP_TRY { 00478 wpunct = new moneypunct_byname<wchar_t, false>(__wmon); 00479 } 00480 _STLP_UNWIND(_STLP_PRIV __release_monetary(__wmon)); 00481 00482 _Locale_monetary *__wimon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code); 00483 if (!__wimon) { 00484 delete wpunct; 00485 if (__err_code == _STLP_LOC_NO_MEMORY) { 00486 _STLP_THROW_BAD_ALLOC; 00487 } 00488 wpunct = 0; 00489 } 00490 else { 00491 _STLP_TRY { 00492 wipunct = new moneypunct_byname<wchar_t, true>(__wimon); 00493 } 00494 _STLP_UNWIND(_STLP_PRIV __release_monetary(__wimon); delete wpunct); 00495 } 00496 } 00497 } 00498 _STLP_UNWIND(delete ipunct; delete punct); 00499 #endif 00500 00501 this->insert(punct, moneypunct<char, false>::id); 00502 this->insert(ipunct, moneypunct<char, true>::id); 00503 #ifndef _STLP_NO_WCHAR_T 00504 if (wpunct) this->insert(wpunct, moneypunct<wchar_t, false>::id); 00505 if (wipunct) this->insert(wipunct, moneypunct<wchar_t, true>::id); 00506 #endif 00507 } 00508 return hint; 00509 } 00510 00511 _Locale_name_hint* _Locale_impl::insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint) { 00512 if (name[0] == 0) 00513 name = _Locale_messages_default(buf); 00514 00515 if (name == 0 || name[0] == 0 || is_C_locale_name(name)) { 00516 _Locale_impl* i2 = locale::classic()._M_impl; 00517 this->insert(i2, messages<char>::id); 00518 #ifndef _STLP_NO_WCHAR_T 00519 this->insert(i2, messages<wchar_t>::id); 00520 #endif 00521 } 00522 else { 00523 locale::facet *msg = 0; 00524 #ifndef _STLP_NO_WCHAR_T 00525 locale::facet *wmsg = 0; 00526 #endif 00527 00528 int __err_code; 00529 _Locale_messages *__msg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code); 00530 if (!__msg) { 00531 if (__err_code == _STLP_LOC_NO_MEMORY) { 00532 _STLP_THROW_BAD_ALLOC; 00533 } 00534 return hint; 00535 } 00536 00537 _STLP_TRY { 00538 msg = new messages_byname<char>(__msg); 00539 } 00540 _STLP_UNWIND(_STLP_PRIV __release_messages(__msg)); 00541 00542 #ifndef _STLP_NO_WCHAR_T 00543 _STLP_TRY { 00544 _Locale_messages *__wmsg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code); 00545 if (!__wmsg) { 00546 if (__err_code == _STLP_LOC_NO_MEMORY) { 00547 _STLP_THROW_BAD_ALLOC; 00548 } 00549 } 00550 00551 if (__wmsg) { 00552 _STLP_TRY { 00553 wmsg = new messages_byname<wchar_t>(__wmsg); 00554 } 00555 _STLP_UNWIND(_STLP_PRIV __release_messages(__wmsg)); 00556 } 00557 } 00558 _STLP_UNWIND(delete msg); 00559 #endif 00560 00561 this->insert(msg, messages<char>::id); 00562 #ifndef _STLP_NO_WCHAR_T 00563 if (wmsg) this->insert(wmsg, messages<wchar_t>::id); 00564 #endif 00565 } 00566 return hint; 00567 } 00568 00569 static void _Stl_loc_assign_ids() { 00570 // This assigns ids to every facet that is a member of a category, 00571 // and also to money_get/put, num_get/put, and time_get/put 00572 // instantiated using ordinary pointers as the input/output 00573 // iterators. (The default is [io]streambuf_iterator.) 00574 00575 money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 8; 00576 money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 9; 00577 num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 10; 00578 num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 11; 00579 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12; 00580 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 13; 00581 00582 #ifndef _STLP_NO_WCHAR_T 00583 money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 21; 00584 money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 22; 00585 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 23; 00586 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index = 24; 00587 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 25; 00588 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 26; 00589 #endif 00590 // locale::id::_S_max = 27; 00591 } 00592 00593 // To access those static instance use the getter below, they guaranty 00594 // a correct initialization. 00595 static locale *_Stl_classic_locale = 0; 00596 static locale *_Stl_global_locale = 0; 00597 00598 locale* _Stl_get_classic_locale() { 00599 static _Locale_impl::Init init; 00600 return _Stl_classic_locale; 00601 } 00602 00603 locale* _Stl_get_global_locale() { 00604 static _Locale_impl::Init init; 00605 return _Stl_global_locale; 00606 } 00607 00608 #if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__) || defined (__DMC__) 00609 /* 00610 * The following static variable needs to be initialized before STLport 00611 * users static variable in order for him to be able to use Standard 00612 * streams in its variable initialization. 00613 * This variable is here because MSVC do not allow to change the initialization 00614 * segment in a given translation unit, iostream.cpp already contains an 00615 * initialization segment specification. 00616 */ 00617 # pragma warning (disable : 4073) 00618 # pragma init_seg(lib) 00619 #endif 00620 00621 static ios_base::Init _IosInit; 00622 00623 void _Locale_impl::make_classic_locale() { 00624 // This funcion will be called once: during build classic _Locale_impl 00625 00626 // The classic locale contains every facet that belongs to a category. 00627 static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf; 00628 _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C"); 00629 00630 locale::facet* classic_facets[] = { 00631 0, 00632 new collate<char>(1), 00633 new ctype<char>(0, false, 1), 00634 new codecvt<char, char, mbstate_t>(1), 00635 new moneypunct<char, true>(1), 00636 new moneypunct<char, false>(1), 00637 new numpunct<char>(1), 00638 new messages<char>(1), 00639 new money_get<char, istreambuf_iterator<char, char_traits<char> > >(1), 00640 new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1), 00641 new num_get<char, istreambuf_iterator<char, char_traits<char> > >(1), 00642 new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1), 00643 new time_get<char, istreambuf_iterator<char, char_traits<char> > >(1), 00644 new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1), 00645 #ifndef _STLP_NO_WCHAR_T 00646 new collate<wchar_t>(1), 00647 new ctype<wchar_t>(1), 00648 new codecvt<wchar_t, char, mbstate_t>(1), 00649 new moneypunct<wchar_t, true>(1), 00650 new moneypunct<wchar_t, false>(1), 00651 new numpunct<wchar_t>(1), 00652 new messages<wchar_t>(1), 00653 new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), 00654 new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), 00655 new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), 00656 new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), 00657 new time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), 00658 new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1), 00659 #endif 00660 0 00661 }; 00662 00663 const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *); 00664 classic->facets_vec.reserve(nb_classic_facets); 00665 classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets); 00666 00667 static locale _Locale_classic(classic); 00668 _Stl_classic_locale = &_Locale_classic; 00669 00670 static locale _Locale_global(classic); 00671 _Stl_global_locale = &_Locale_global; 00672 } 00673 00674 // Declarations of (non-template) facets' static data members 00675 // size_t locale::id::_S_max = 27; // made before 00676 00677 locale::id collate<char>::id = { 1 }; 00678 locale::id ctype<char>::id = { 2 }; 00679 locale::id codecvt<char, char, mbstate_t>::id = { 3 }; 00680 locale::id moneypunct<char, true>::id = { 4 }; 00681 locale::id moneypunct<char, false>::id = { 5 }; 00682 locale::id numpunct<char>::id = { 6 } ; 00683 locale::id messages<char>::id = { 7 }; 00684 00685 #ifndef _STLP_NO_WCHAR_T 00686 locale::id collate<wchar_t>::id = { 14 }; 00687 locale::id ctype<wchar_t>::id = { 15 }; 00688 locale::id codecvt<wchar_t, char, mbstate_t>::id = { 16 }; 00689 locale::id moneypunct<wchar_t, true>::id = { 17 } ; 00690 locale::id moneypunct<wchar_t, false>::id = { 18 } ; 00691 locale::id numpunct<wchar_t>::id = { 19 }; 00692 locale::id messages<wchar_t>::id = { 20 }; 00693 #endif 00694 00695 _STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc) 00696 { 00697 _STLP_ASSERT( loc != 0 ); 00698 loc->_M_incr(); 00699 return loc; 00700 } 00701 00702 void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc) 00703 { 00704 _STLP_ASSERT( loc != 0 ); 00705 if (loc->_M_decr() == 0) { 00706 if (*loc != *_Stl_classic_locale) 00707 delete loc; 00708 else 00709 loc->~_Locale_impl(); 00710 loc = 0; 00711 } 00712 } 00713 00714 _STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc) 00715 { 00716 _STLP_ASSERT( loc != 0 ); 00717 _Locale_impl *loc_new = new _Locale_impl(*loc); 00718 loc_new->name = _Nameless; 00719 return loc_new; 00720 } 00721 00722 /* _GetFacetId implementation have to be here in order to be in the same translation unit 00723 * as where id are initialize (in _Stl_loc_assign_ids) */ 00724 _STLP_MOVE_TO_PRIV_NAMESPACE 00725 00726 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<char, istreambuf_iterator<char, char_traits<char> > >*) 00727 { return money_get<char, istreambuf_iterator<char, char_traits<char> > >::id; } 00728 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<char, ostreambuf_iterator<char, char_traits<char> > >*) 00729 { return money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; } 00730 #ifndef _STLP_NO_WCHAR_T 00731 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*) 00732 { return money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; } 00733 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*) 00734 { return money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; } 00735 #endif 00736 00737 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<char, istreambuf_iterator<char, char_traits<char> > >*) 00738 { return num_get<char, istreambuf_iterator<char, char_traits<char> > >::id; } 00739 #ifndef _STLP_NO_WCHAR_T 00740 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*) 00741 { return num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; } 00742 #endif 00743 00744 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<char, ostreambuf_iterator<char, char_traits<char> > >*) 00745 { return num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; } 00746 #ifndef _STLP_NO_WCHAR_T 00747 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*) 00748 { return num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; } 00749 #endif 00750 00751 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<char, istreambuf_iterator<char, char_traits<char> > >*) 00752 { return time_get<char, istreambuf_iterator<char, char_traits<char> > >::id; } 00753 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<char, ostreambuf_iterator<char, char_traits<char> > >*) 00754 { return time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; } 00755 #ifndef _STLP_NO_WCHAR_T 00756 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*) 00757 { return time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; } 00758 _STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*) 00759 { return time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; } 00760 #endif 00761 00762 _STLP_MOVE_TO_STD_NAMESPACE 00763 00764 _STLP_END_NAMESPACE 00765 Generated on Sat May 26 2012 04:34:03 for ReactOS by
1.7.6.1
|