stdcpp/src/locale_impl.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  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_impl.h"
       
    23 #include <locale>
       
    24 #include <typeinfo>
       
    25 #include <stdexcept>
       
    26 #include "c_locale.h"
       
    27 #include "aligned_buffer.h"
       
    28 #include <exception>
       
    29 
       
    30 #include "locale_impl.h"
       
    31 #include <stl/_codecvt.h>
       
    32 #include <stl/_collate.h>
       
    33 #include <stl/_ctype.h>
       
    34 #include <stl/_monetary.h>
       
    35 #include "message_facets.h"
       
    36 
       
    37 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
    38 #include "libstdcppwsd.h"
       
    39 _STLP_BEGIN_NAMESPACE
       
    40 extern void filebuf_page_size_init();
       
    41 extern void num_get_array_init();
       
    42 extern void locale_mutex_lock_init();
       
    43 extern void ios_base_S_index_init();
       
    44 extern void ios_base_Init_S_count_init();
       
    45 extern void ios_base_S_was_synced_init();
       
    46 extern void numpunct_name_init();
       
    47 extern void locale_catalog_category_hash_lock_init();
       
    48 extern void complex_trig_limit_init();
       
    49 extern void monetary_empty_string_init();
       
    50 //forward declaraions
       
    51 void ios_base_Loc_init_S_count_init();
       
    52 void locale_impl_init();
       
    53 void locale_impl_string_init();
       
    54 _STLP_END_NAMESPACE
       
    55 # endif
       
    56 
       
    57 #ifdef __WINSCW__
       
    58 extern void SetGlobalTlsData(void* aData);
       
    59 #endif
       
    60 
       
    61 _STLP_BEGIN_NAMESPACE
       
    62 
       
    63 
       
    64 // #ifdef _STLP_USE_OWN_NAMESPACE
       
    65 // using _STLP_VENDOR_EXCEPT_STD::bad_cast;
       
    66 // #endif
       
    67 
       
    68 _Locale_impl::_Locale_impl(const char* s) : name(s) {}
       
    69 _Locale_impl::~_Locale_impl() {}
       
    70 void _Locale_impl::incr() {}
       
    71 void _Locale_impl::decr() {}
       
    72 
       
    73 // _Locale_impl non-inline member functions.
       
    74 void _STLP_CALL
       
    75 _Locale_impl::_M_throw_bad_cast()
       
    76 {
       
    77   _STLP_THROW(bad_cast());  
       
    78 }
       
    79 
       
    80 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
    81 static void global_iostream_init()
       
    82 {
       
    83 	_Libcpp_wsd* libwsd = &get_libcpp_wsdptr();
       
    84 	//initialize the pointer members
       
    85 	libwsd->cin = new istream(0);
       
    86 	libwsd->cout = new ostream(0);
       
    87 	libwsd->cerr = new ostream(0);
       
    88 	libwsd->clog = new ostream(0);
       
    89 #ifndef _STLP_NO_WCHAR_T
       
    90 	libwsd->wcin = new wistream(0);
       
    91 	libwsd->wcout = new wostream(0);
       
    92 	libwsd->wcerr = new wostream(0);
       
    93 	libwsd->wclog = new wostream(0);
       
    94 #endif //_STLP_NO_WCHAR_T
       
    95 }
       
    96 
       
    97 //WSD class constructor
       
    98 _Libcpp_wsd::_Libcpp_wsd()
       
    99 	{
       
   100 	ios_base_Init_S_count = 0;
       
   101 	ios_base_Loc_init_S_count = 0;
       
   102 	locale_catalog_ctype_hash = NULL;
       
   103 	locale_catalog_numeric_hash = NULL;
       
   104 	locale_catalog_time_hash = NULL;
       
   105 	locale_catalog_collate_hash = NULL;
       
   106 	locale_catalog_monetary_hash = NULL;
       
   107 	locale_catalog_messages_hash = NULL;
       
   108 	_LocInit = NULL;
       
   109 	_IosInit = NULL;
       
   110 	ios_pword_dummy = NULL;
       
   111 	Locale_impl_S_global_impl = NULL;
       
   112 
       
   113 	//initialize the global stream pointers
       
   114 	cin  = NULL;
       
   115 	cout = NULL;
       
   116 	cerr = NULL;
       
   117 	clog = NULL;
       
   118 #ifndef _STLP_NO_WCHAR_T
       
   119 	wcin  = NULL;
       
   120 	wcout = NULL;
       
   121 	wcerr = NULL;
       
   122 	wclog = NULL;
       
   123 #endif
       
   124     _new_handler = NULL;
       
   125 	}
       
   126 
       
   127 //WSd class destructor
       
   128 _Libcpp_wsd::~_Libcpp_wsd()
       
   129 	{
       
   130 		delete _LocInit;
       
   131 		delete _IosInit;
       
   132 		delete cin;
       
   133 		delete cout;
       
   134 		delete cerr;
       
   135 		delete clog;
       
   136 # ifndef _STLP_NO_WCHAR_T		
       
   137 		delete wcin;
       
   138 		delete wcout;
       
   139 		delete wcerr;
       
   140 		delete wclog;
       
   141 # endif		
       
   142 	}
       
   143 
       
   144 void CallCloseStdLib()
       
   145     {
       
   146     _Libcpp_wsd* wsd = &get_libcpp_wsdptr();
       
   147 #ifdef __WINSCW__
       
   148     SetGlobalTlsData(NULL);
       
   149 #endif //__WINSCW__
       
   150     delete wsd;
       
   151     }
       
   152 
       
   153 # endif  //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   154 
       
   155 static void 
       
   156 _Stl_loc_assign_ids() {
       
   157 
       
   158 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   159   //initialize wsd obj pointer
       
   160   locale_impl_init();
       
   161 # endif  
       
   162   
       
   163   // This assigns ids to every facet that is a member of a category,
       
   164   // and also to money_get/put, num_get/put, and time_get/put
       
   165   // instantiated using ordinary pointers as the input/output
       
   166   // iterators.  (The default is [io]streambuf_iterator.)
       
   167 
       
   168 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   169 
       
   170     collate<char>::GetFacetLocaleId()._M_index = 1;
       
   171 
       
   172     ctype<char>::GetFacetLocaleId()._M_index = 2;
       
   173 
       
   174  # ifndef _STLP_NO_MBSTATE_T
       
   175     codecvt<char, char, mbstate_t>::GetFacetLocaleId()._M_index = 3;
       
   176   #  ifndef _STLP_NO_WCHAR_T
       
   177     codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId()._M_index = 22;
       
   178   #  endif//!_STLP_NO_WCHAR_T
       
   179  # endif//!_STLP_NO_MBSTATE_T
       
   180 
       
   181     moneypunct<char, true>::GetFacetLocaleId()._M_index = 4;
       
   182     moneypunct<char, false>::GetFacetLocaleId()._M_index = 5;
       
   183     messages<char>::GetFacetLocaleId()._M_index = 7;
       
   184     numpunct<char>::GetFacetLocaleId()._M_index = 6;
       
   185 
       
   186  # ifndef _STLP_NO_WCHAR_T
       
   187     collate<wchar_t>::GetFacetLocaleId()._M_index = 20;
       
   188     ctype<wchar_t>::GetFacetLocaleId()._M_index = 21;
       
   189 
       
   190     moneypunct<wchar_t, true>::GetFacetLocaleId()._M_index = 23;
       
   191     moneypunct<wchar_t, false>::GetFacetLocaleId()._M_index = 24;
       
   192 
       
   193     numpunct<wchar_t>::GetFacetLocaleId()._M_index = 25;
       
   194     messages<wchar_t>::GetFacetLocaleId()._M_index = 26;
       
   195  # endif //!_STLP_NO_WCHAR_T
       
   196 
       
   197 
       
   198   money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index                     = 8;
       
   199   money_get<char, const char*>::GetFacetLocaleId()._M_index        = 9;
       
   200   money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index                     = 10;
       
   201   money_put<char, char*>::GetFacetLocaleId()._M_index              = 11;
       
   202 
       
   203   num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index                       = 12;
       
   204   num_get<char, const char*>::GetFacetLocaleId()._M_index          = 13;
       
   205   num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index                       = 14;
       
   206   num_put<char, char*>::GetFacetLocaleId()._M_index                = 15;
       
   207   time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index                      = 16;
       
   208   time_get<char, const char*>::GetFacetLocaleId()._M_index         = 17;
       
   209   time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()._M_index                      = 18;
       
   210   time_put<char, char*>::GetFacetLocaleId()._M_index               = 19;
       
   211   //adding new iterator type
       
   212   num_put<char, back_insert_iterator<string> >::GetFacetLocaleId()._M_index  = 40;
       
   213 #else
       
   214   money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index                     = 8;
       
   215   money_get<char, const char*>::id._M_index        = 9;
       
   216   money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index                     = 10;
       
   217   money_put<char, char*>::id._M_index              = 11;
       
   218 
       
   219   num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index                       = 12;
       
   220   num_get<char, const char*>::id._M_index          = 13;
       
   221   num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index                       = 14;
       
   222   num_put<char, char*>::id._M_index                = 15;
       
   223   time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index                      = 16;
       
   224   time_get<char, const char*>::id._M_index         = 17;
       
   225   time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index                      = 18;
       
   226   time_put<char, char*>::id._M_index               = 19;
       
   227 #endif
       
   228 
       
   229 # ifndef _STLP_NO_WCHAR_T
       
   230 
       
   231 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   232   money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()._M_index          = 27;
       
   233   money_get<wchar_t, const wchar_t*>::GetFacetLocaleId()._M_index  = 28;
       
   234   money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()._M_index          = 29;
       
   235   money_put<wchar_t, wchar_t*>::GetFacetLocaleId()._M_index        = 30;
       
   236 
       
   237   num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()._M_index            = 31;
       
   238   num_get<wchar_t, const wchar_t*>::GetFacetLocaleId()._M_index    = 32;
       
   239   num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::GetFacetLocaleId()._M_index           = 33;
       
   240   num_put<wchar_t, wchar_t*>::GetFacetLocaleId()._M_index          = 34;
       
   241   time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()._M_index           = 35;
       
   242   time_get<wchar_t, const wchar_t*>::GetFacetLocaleId()._M_index   = 36;
       
   243   time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()._M_index           = 37;
       
   244   time_put<wchar_t, wchar_t*>::GetFacetLocaleId()._M_index         = 38;
       
   245 #else
       
   246   money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index                  = 27;
       
   247   money_get<wchar_t, const wchar_t*>::id._M_index  = 28;
       
   248   money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index                  = 29;
       
   249   money_put<wchar_t, wchar_t*>::id._M_index        = 30;
       
   250 
       
   251   num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index                       = 31;
       
   252   num_get<wchar_t, const wchar_t*>::id._M_index    = 32;
       
   253   num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index                      = 33;
       
   254   num_put<wchar_t, wchar_t*>::id._M_index          = 34;
       
   255   time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index                   = 35;
       
   256   time_get<wchar_t, const wchar_t*>::id._M_index   = 36;
       
   257   time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index                   = 37;
       
   258   time_put<wchar_t, wchar_t*>::id._M_index         = 38;
       
   259 #endif
       
   260   //  messages<wchar_t>::id._M_index                   = 38;
       
   261 # endif
       
   262 
       
   263   //  locale::id::_S_max                               = 39;
       
   264 }
       
   265 
       
   266 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   267 static _Stl_aligned_buffer<_Locale_impl> _S_classic_locale;
       
   268 
       
   269 static _Stl_aligned_buffer<collate<char> > _S_collate_char;
       
   270 static _Stl_aligned_buffer<ctype<char> > _S_ctype_char;
       
   271 
       
   272 # ifndef _STLP_NO_MBSTATE_T
       
   273 static _Stl_aligned_buffer<codecvt<char, char, mbstate_t> > _S_codecvt_char;
       
   274 # endif
       
   275 
       
   276 static _Stl_aligned_buffer<moneypunct<char, true> > _S_moneypunct_true_char;
       
   277 static _Stl_aligned_buffer<moneypunct<char, false> > _S_moneypunct_false_char;
       
   278 static _Stl_aligned_buffer<numpunct<char> > _S_numpunct_char;
       
   279 static _Stl_aligned_buffer<messages<char> > _S_messages_char;
       
   280 
       
   281 static _Stl_aligned_buffer<money_get<char, istreambuf_iterator<char, char_traits<char> > > > _S_money_get_char;
       
   282 static _Stl_aligned_buffer<money_put<char, ostreambuf_iterator<char, char_traits<char> > > > _S_money_put_char;
       
   283 static _Stl_aligned_buffer<num_get<char, istreambuf_iterator<char, char_traits<char> > > > _S_num_get_char;
       
   284 static _Stl_aligned_buffer<num_put<char, ostreambuf_iterator<char, char_traits<char> > > > _S_num_put_char;
       
   285 static _Stl_aligned_buffer<time_get<char, istreambuf_iterator<char, char_traits<char> > > > _S_time_get_char;
       
   286 static _Stl_aligned_buffer<time_put<char, ostreambuf_iterator<char, char_traits<char> > > > _S_time_put_char;
       
   287 
       
   288 static _Stl_aligned_buffer<money_get<char, const char*> > _S_money_get_char_const_char;
       
   289 static _Stl_aligned_buffer<money_put<char, char*> > _S_money_put_char_char;
       
   290 static _Stl_aligned_buffer<num_get<char, const char*> > _S_num_get_char_const_char;
       
   291 static _Stl_aligned_buffer<num_put<char, char*> > _S_num_put_char_char;
       
   292 static _Stl_aligned_buffer<time_get<char, const char*> > _S_time_get_char_const_char;
       
   293 static _Stl_aligned_buffer<time_put<char, char*> > _S_time_put_char_char;
       
   294 
       
   295 # ifndef _STLP_NO_WCHAR_T
       
   296 static _Stl_aligned_buffer<collate<wchar_t> > _S_collate_wchar;
       
   297 static _Stl_aligned_buffer<ctype<wchar_t> > _S_ctype_wchar;
       
   298 # ifndef _STLP_NO_MBSTATE_T
       
   299 static _Stl_aligned_buffer<codecvt<wchar_t, char, mbstate_t> > _S_codecvt_wchar;
       
   300 # endif //!_STLP_NO_MBSTATE_T
       
   301 static _Stl_aligned_buffer<moneypunct<wchar_t, true> > _S_moneypunct_true_wchar;
       
   302 static _Stl_aligned_buffer<moneypunct<wchar_t, false> > _S_moneypunct_false_wchar;
       
   303 static _Stl_aligned_buffer<numpunct<wchar_t> > _S_numpunct_wchar;
       
   304 static _Stl_aligned_buffer<messages<wchar_t> > _S_messages_wchar;
       
   305 
       
   306 static _Stl_aligned_buffer<money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > > _S_money_get_wchar;
       
   307 static _Stl_aligned_buffer<money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > > _S_money_put_wchar;
       
   308 static _Stl_aligned_buffer<num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > > _S_num_get_wchar;
       
   309 static _Stl_aligned_buffer<num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > > _S_num_put_wchar;
       
   310 static _Stl_aligned_buffer<time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > > _S_time_get_wchar;
       
   311 static _Stl_aligned_buffer<time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > > _S_time_put_wchar;
       
   312 
       
   313 static _Stl_aligned_buffer<money_get<wchar_t, const wchar_t*> > _S_money_get_wchar_const_wchar;
       
   314 static _Stl_aligned_buffer<money_put<wchar_t, wchar_t*> > _S_money_put_wchar_wchar;
       
   315 static _Stl_aligned_buffer<num_get<wchar_t, const wchar_t*> > _S_num_get_wchar_const_wchar;
       
   316 static _Stl_aligned_buffer<num_put<wchar_t, wchar_t*> > _S_num_put_wchar_wchar;
       
   317 static _Stl_aligned_buffer<time_get<wchar_t, const wchar_t*> > _S_time_get_wchar_const_wchar;
       
   318 static _Stl_aligned_buffer<time_put<wchar_t, wchar_t*> > _S_time_put_wchar_wchar;
       
   319 # endif //!_STLP_NO_WCHAR_T
       
   320 
       
   321 static _Messages _Null_messages;
       
   322 
       
   323 static locale::facet* _S_classic_facets[] = {
       
   324   __REINTERPRET_CAST(locale::facet*,0),
       
   325   __REINTERPRET_CAST(locale::facet*,&_S_collate_char),
       
   326   __REINTERPRET_CAST(locale::facet*,&_S_ctype_char), 
       
   327 # ifndef _STLP_NO_MBSTATE_T
       
   328     __REINTERPRET_CAST(locale::facet*,&_S_codecvt_char),
       
   329 # else
       
   330     __REINTERPRET_CAST(locale::facet*,0), 
       
   331 # endif //!_STLP_NO_MBSTATE_T
       
   332   __REINTERPRET_CAST(locale::facet*,&_S_moneypunct_true_char),
       
   333   __REINTERPRET_CAST(locale::facet*,&_S_moneypunct_false_char),
       
   334   __REINTERPRET_CAST(locale::facet*,&_S_numpunct_char),
       
   335   __REINTERPRET_CAST(locale::facet*,&_S_messages_char),
       
   336 
       
   337   __REINTERPRET_CAST(locale::facet*,&_S_money_get_char),
       
   338   __REINTERPRET_CAST(locale::facet*,&_S_money_get_char_const_char),
       
   339   __REINTERPRET_CAST(locale::facet*,&_S_money_put_char),
       
   340   __REINTERPRET_CAST(locale::facet*,&_S_money_put_char_char),
       
   341 
       
   342   __REINTERPRET_CAST(locale::facet*,&_S_num_get_char),
       
   343   __REINTERPRET_CAST(locale::facet*,&_S_num_get_char_const_char),
       
   344   __REINTERPRET_CAST(locale::facet*,&_S_num_put_char),
       
   345   __REINTERPRET_CAST(locale::facet*,&_S_num_put_char_char),
       
   346   __REINTERPRET_CAST(locale::facet*,&_S_time_get_char),
       
   347   __REINTERPRET_CAST(locale::facet*,&_S_time_get_char_const_char),
       
   348   __REINTERPRET_CAST(locale::facet*,&_S_time_put_char),
       
   349   __REINTERPRET_CAST(locale::facet*,&_S_time_put_char_char),
       
   350 # ifndef _STLP_NO_WCHAR_T
       
   351   __REINTERPRET_CAST(locale::facet*,&_S_collate_wchar),
       
   352   __REINTERPRET_CAST(locale::facet*,&_S_ctype_wchar), 
       
   353 # ifndef _STLP_NO_MBSTATE_T
       
   354   __REINTERPRET_CAST(locale::facet*,&_S_codecvt_wchar),
       
   355 # else 
       
   356   __REINTERPRET_CAST(locale::facet*,0)
       
   357 # endif //!_STLP_NO_MBSTATE_T
       
   358   __REINTERPRET_CAST(locale::facet*,&_S_moneypunct_true_wchar),
       
   359   __REINTERPRET_CAST(locale::facet*,&_S_moneypunct_false_wchar),
       
   360   __REINTERPRET_CAST(locale::facet*,&_S_numpunct_wchar),
       
   361   __REINTERPRET_CAST(locale::facet*,&_S_messages_wchar),
       
   362 
       
   363   __REINTERPRET_CAST(locale::facet*,&_S_money_get_wchar),
       
   364   __REINTERPRET_CAST(locale::facet*,&_S_money_get_wchar_const_wchar),
       
   365   __REINTERPRET_CAST(locale::facet*,&_S_money_put_wchar),
       
   366   __REINTERPRET_CAST(locale::facet*,&_S_money_put_wchar_wchar),
       
   367 
       
   368   __REINTERPRET_CAST(locale::facet*,&_S_num_get_wchar),
       
   369   __REINTERPRET_CAST(locale::facet*,&_S_num_get_wchar_const_wchar),
       
   370   __REINTERPRET_CAST(locale::facet*,&_S_num_put_wchar),
       
   371   __REINTERPRET_CAST(locale::facet*,&_S_num_put_wchar_wchar),
       
   372   __REINTERPRET_CAST(locale::facet*,&_S_time_get_wchar),
       
   373   __REINTERPRET_CAST(locale::facet*,&_S_time_get_wchar_const_wchar),
       
   374   __REINTERPRET_CAST(locale::facet*,&_S_time_put_wchar),
       
   375   __REINTERPRET_CAST(locale::facet*,&_S_time_put_wchar_wchar),
       
   376 # endif //!_STLP_NO_WCHAR_T
       
   377   0
       
   378 };
       
   379 # endif //!__LIBSTD_CPP_SYMBIAN32_WSD__
       
   380 
       
   381 //Put all static variable initialization in this file
       
   382 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   383 
       
   384 #ifndef __WINSCW__
       
   385 _STLP_STATIC_MEMBER_EXP_DECLSPEC _Libcpp_wsd* g_libcpp_wsd = NULL;
       
   386 #endif
       
   387 
       
   388 void locale_impl_init()
       
   389 {
       
   390 	int index = 0;
       
   391 
       
   392 #ifdef __WINSCW__
       
   393 	_Libcpp_wsd* g_libcpp_wsd = &get_libcpp_wsdptr();
       
   394 #else
       
   395 	g_libcpp_wsd  = &get_libcpp_wsdptr();
       
   396 #endif
       
   397 
       
   398 	if (!g_libcpp_wsd)
       
   399 		return;
       
   400 
       
   401 	//initialize _S_max
       
   402 	get_locale_id_S_max() = 39;
       
   403 
       
   404 	get_locale_impl_S_global_impl() = 0;
       
   405 
       
   406 	//initialize the page size
       
   407 	filebuf_page_size_init();
       
   408 
       
   409 	//initialize the array in num_get
       
   410 	num_get_array_init();
       
   411 
       
   412 	//initialize the mutex lock in locale.cpp
       
   413 	locale_mutex_lock_init();
       
   414 
       
   415 	//initialize _S_index in ios.cpp
       
   416 	ios_base_S_index_init();
       
   417 
       
   418 	//initialize _S_count of _Loc_init
       
   419 	ios_base_Loc_init_S_count_init();
       
   420 
       
   421 	//initialize _S_count of Init
       
   422 	ios_base_Init_S_count_init();
       
   423 
       
   424 	//initialize S_was_synced of ios_base
       
   425 	ios_base_S_was_synced_init();
       
   426 
       
   427 	//initialize the mutex in locale_catalog.cpp
       
   428 	locale_catalog_category_hash_lock_init();
       
   429 
       
   430 	//initialize float and double limits in complex_trig.cpp
       
   431 	complex_trig_limit_init();
       
   432 
       
   433 	//initialize the string
       
   434 	locale_impl_string_init();
       
   435 
       
   436 	//initialize empty string in monetary.cpp
       
   437 	monetary_empty_string_init();
       
   438 
       
   439 	//initialize true/false name in numpunct.cpp
       
   440 	numpunct_name_init();
       
   441 
       
   442 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,0);
       
   443 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_collate_char());
       
   444 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_ctype_char());
       
   445 
       
   446 # ifndef _STLP_NO_MBSTATE_T
       
   447 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_codecvt_char());
       
   448 # else
       
   449 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,0);
       
   450 # endif
       
   451 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_moneypunct_true_char());
       
   452 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_moneypunct_false_char());
       
   453 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_numpunct_char());
       
   454 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_messages_char());
       
   455 
       
   456 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_get_char());
       
   457 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_get_char_const_char());
       
   458 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_put_char());
       
   459 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_put_char_char());
       
   460 
       
   461 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_get_char());
       
   462 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_get_char_const_char());
       
   463 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_put_char());
       
   464 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_put_char_char());
       
   465 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_get_char());
       
   466 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_get_char_const_char());
       
   467 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_put_char());
       
   468 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_put_char_char());
       
   469 # ifndef _STLP_NO_WCHAR_T
       
   470 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_collate_wchar());
       
   471 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_ctype_wchar());
       
   472 # ifndef _STLP_NO_MBSTATE_T
       
   473 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_codecvt_wchar());
       
   474 # else
       
   475 	get_locale_impl_S_classic_facets()[index++] =  __REINTERPRET_CAST(locale::facet*,0);
       
   476 # endif //!_STLP_NO_MBSTATE_T
       
   477 
       
   478 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_moneypunct_true_wchar());
       
   479 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_moneypunct_false_wchar());
       
   480 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_numpunct_wchar());
       
   481 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_messages_wchar());
       
   482 
       
   483 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_get_wchar());
       
   484 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_get_wchar_const_wchar());
       
   485 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_put_wchar());
       
   486 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_money_put_wchar_wchar());
       
   487 
       
   488 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_get_wchar());
       
   489 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_get_wchar_const_wchar());
       
   490 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_put_wchar());
       
   491 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_put_wchar_wchar());
       
   492 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_get_wchar());
       
   493 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_get_wchar_const_wchar());
       
   494 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_put_wchar());
       
   495 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_time_put_wchar_wchar());
       
   496 # endif  //!_STLP_NO_WCHAR_T
       
   497 	//support for back_insert iterator
       
   498 	get_locale_impl_S_classic_facets()[index++] = __REINTERPRET_CAST(locale::facet*,&get_locale_impl_S_num_put_char_back_insert_iterator());
       
   499 	get_locale_impl_S_classic_facets()[index] = 0;
       
   500 }
       
   501 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   502 
       
   503 _Locale_impl* 
       
   504 _Locale_impl::make_classic_locale() {
       
   505   // The classic locale contains every facet that belongs to a category.
       
   506 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   507 	_Locale_impl* classic = __REINTERPRET_CAST(_Locale_impl*, &get_locale_impl_S_classic_locale());
       
   508 # else
       
   509 	_Locale_impl* classic = __REINTERPRET_CAST(_Locale_impl*, &_S_classic_locale);
       
   510 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   511   
       
   512   new (classic) _Locale_impl("C");
       
   513 
       
   514 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   515   classic->facets = get_locale_impl_S_classic_facets();
       
   516   classic->_M_size = get_locale_id_S_max();
       
   517 # else
       
   518   classic->facets = _S_classic_facets;
       
   519   classic->_M_size = locale::id::_S_max;
       
   520 # endif  //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   521 
       
   522 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   523   // ctype category
       
   524   new(&get_locale_impl_S_ctype_char()) ctype<char>(0, false, 1);
       
   525   // collate category
       
   526   new(&get_locale_impl_S_collate_char()) collate<char>(1);
       
   527   new(&get_locale_impl_S_codecvt_char()) codecvt<char, char, mbstate_t>(1);
       
   528   // numeric category
       
   529   new(&get_locale_impl_S_numpunct_char()) numpunct<char>(1);
       
   530   new (&get_locale_impl_S_num_get_char()) num_get<char, istreambuf_iterator<char, char_traits<char> > >(1);
       
   531   new (&get_locale_impl_S_num_put_char()) num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1);
       
   532   new (&get_locale_impl_S_time_get_char()) time_get<char, istreambuf_iterator<char, char_traits<char> > >(1);
       
   533   new (&get_locale_impl_S_time_put_char()) time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1);  
       
   534   new (&get_locale_impl_S_num_get_char_const_char()) num_get<char, const char*>(1);
       
   535   new (&get_locale_impl_S_num_put_char_char()) num_put<char, char*>(1);
       
   536   new (&get_locale_impl_S_num_put_char_back_insert_iterator()) num_put<char, back_insert_iterator<string> >(1);
       
   537   new (&get_locale_impl_S_time_get_char_const_char()) time_get<char, const char*>(1);
       
   538   new (&get_locale_impl_S_time_put_char_char()) time_put<char, char*>(1);
       
   539 
       
   540   // monetary category
       
   541   new (&get_locale_impl_S_moneypunct_true_char()) moneypunct<char, true>(1);
       
   542   new (&get_locale_impl_S_moneypunct_false_char()) moneypunct<char, false>(1);
       
   543   new (&get_locale_impl_S_money_get_char()) money_get<char, istreambuf_iterator<char, char_traits<char> > >(1);
       
   544   new (&get_locale_impl_S_money_put_char()) money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1);
       
   545   new (&get_locale_impl_S_money_get_char_const_char()) money_get<char, const char*>(1);
       
   546   new (&get_locale_impl_S_money_put_char_char()) money_put<char, char*>(1);
       
   547 
       
   548   // messages category
       
   549   new (&get_locale_impl_S_messages_char())messages<char>(&get_locale_impl_messages());
       
   550 # ifndef _STLP_NO_WCHAR_T
       
   551   // ctype category
       
   552   new(&get_locale_impl_S_ctype_wchar()) ctype<wchar_t>(1);
       
   553   // collate category
       
   554   new(&get_locale_impl_S_collate_wchar()) collate<wchar_t>(1);
       
   555   new(&get_locale_impl_S_codecvt_wchar()) codecvt<wchar_t, char, mbstate_t>(1);
       
   556   // numeric category
       
   557   new(&get_locale_impl_S_numpunct_wchar()) numpunct<wchar_t>(1);
       
   558   new (&get_locale_impl_S_num_get_wchar()) num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   559   new (&get_locale_impl_S_num_put_wchar()) num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   560   new (&get_locale_impl_S_time_get_wchar()) time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   561   new (&get_locale_impl_S_time_put_wchar()) time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   562   new (&get_locale_impl_S_messages_wchar())messages<wchar_t>(&get_locale_impl_messages());
       
   563   new (&get_locale_impl_S_num_get_wchar_const_wchar()) num_get<wchar_t, const wchar_t*>(1); 
       
   564   new (&get_locale_impl_S_num_put_wchar_wchar()) num_put<wchar_t, wchar_t*>(1); 
       
   565   new (&get_locale_impl_S_time_get_wchar_const_wchar()) time_get<wchar_t, const wchar_t*>(1); 
       
   566   new (&get_locale_impl_S_time_put_wchar_wchar()) time_put<wchar_t, wchar_t*>(1);   
       
   567   // monetary category
       
   568   new (&get_locale_impl_S_moneypunct_true_wchar()) moneypunct<wchar_t, true>(1);
       
   569   new (&get_locale_impl_S_moneypunct_false_wchar()) moneypunct<wchar_t, false>(1);
       
   570   new (&get_locale_impl_S_money_get_wchar()) money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   571   new (&get_locale_impl_S_money_put_wchar()) money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   572   new (&get_locale_impl_S_money_get_wchar_const_wchar()) money_get<wchar_t, const wchar_t*>(1);
       
   573   new (&get_locale_impl_S_money_put_wchar_wchar()) money_put<wchar_t, wchar_t*>(1);
       
   574 # endif //!_STLP_NO_WCHAR_T
       
   575 # else //!__LIBSTD_CPP_SYMBIAN32_WSD__
       
   576   // ctype category
       
   577   new(&_S_ctype_char) ctype<char>(0, false, 1);
       
   578   // collate category
       
   579   new(&_S_collate_char) collate<char>(1);
       
   580   new(&_S_codecvt_char) codecvt<char, char, mbstate_t>(1);
       
   581   // numeric category
       
   582   new(&_S_numpunct_char) numpunct<char>(1);
       
   583   new (&_S_num_get_char) num_get<char, istreambuf_iterator<char, char_traits<char> > >(1);
       
   584   new (&_S_num_put_char) num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1);
       
   585   new (&_S_time_get_char) time_get<char, istreambuf_iterator<char, char_traits<char> > >(1);
       
   586   new (&_S_time_put_char) time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1);
       
   587   new (&_S_num_get_char_const_char) num_get<char, const char*>(1);
       
   588   new (&_S_num_put_char_char) num_put<char, char*>(1);
       
   589   new (&_S_time_get_char_const_char) time_get<char, const char*>(1);
       
   590   new (&_S_time_put_char_char) time_put<char, char*>(1);
       
   591   // monetary category
       
   592   new (&_S_moneypunct_true_char) moneypunct<char, true>(1);
       
   593   new (&_S_moneypunct_false_char) moneypunct<char, false>(1);
       
   594   new (&_S_money_get_char) money_get<char, istreambuf_iterator<char, char_traits<char> > >(1);
       
   595   new (&_S_money_put_char) money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1);
       
   596   new (&_S_money_get_char_const_char) money_get<char, const char*>(1);
       
   597   new (&_S_money_put_char_char) money_put<char, char*>(1);
       
   598   // messages category
       
   599   new (&_S_messages_char)messages<char>(&_Null_messages);
       
   600 
       
   601 # ifndef _STLP_NO_WCHAR_T
       
   602   // ctype category
       
   603   new(&_S_ctype_wchar) ctype<wchar_t>(1);
       
   604   // collate category
       
   605   new(&_S_collate_wchar) collate<wchar_t>(1);
       
   606   new(&_S_codecvt_wchar) codecvt<wchar_t, char, mbstate_t>(1);
       
   607   // numeric category
       
   608   new(&_S_numpunct_wchar) numpunct<wchar_t>(1);
       
   609   new (&_S_num_get_wchar) num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   610   new (&_S_num_put_wchar) num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   611   new (&_S_time_get_wchar) time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   612   new (&_S_time_put_wchar) time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   613   new (&_S_messages_wchar)messages<wchar_t>(&_Null_messages);
       
   614   new (&_S_num_get_wchar_const_wchar) num_get<wchar_t, const wchar_t*>(1); 
       
   615   new (&_S_num_put_wchar_wchar) num_put<wchar_t, wchar_t*>(1); 
       
   616   new (&_S_time_get_wchar_const_wchar) time_get<wchar_t, const wchar_t*>(1); 
       
   617   new (&_S_time_put_wchar_wchar) time_put<wchar_t, wchar_t*>(1); 
       
   618   // monetary category
       
   619   new (&_S_moneypunct_true_wchar) moneypunct<wchar_t, true>(1);
       
   620   new (&_S_moneypunct_false_wchar) moneypunct<wchar_t, false>(1);
       
   621   new (&_S_money_get_wchar) money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   622   new (&_S_money_put_wchar) money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1);
       
   623   new (&_S_money_get_wchar_const_wchar) money_get<wchar_t, const wchar_t*>(1);
       
   624   new (&_S_money_put_wchar_wchar) money_put<wchar_t, wchar_t*>(1);
       
   625 # endif //!_STLP_NO_WCHAR_T
       
   626 
       
   627 # endif //__LIBSTD_CPP_SYMBIAN32_WSD__
       
   628   return classic;
       
   629 }
       
   630 
       
   631 
       
   632 //----------------------------------------------------------------------
       
   633 
       
   634 // Declarations of (non-template) facets' static data members
       
   635 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   636 
       
   637 size_t locale::id::_S_max = 39;
       
   638 
       
   639 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id collate<char>::id = { 1 };
       
   640 
       
   641 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id ctype<char>::id = { 2 };
       
   642 
       
   643 # ifndef _STLP_NO_MBSTATE_T
       
   644 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id codecvt<char, char, mbstate_t>::id = { 3 };
       
   645 #  ifndef _STLP_NO_WCHAR_T
       
   646 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 };
       
   647 #  endif//!_STLP_NO_WCHAR_T
       
   648 # endif//!_STLP_NO_MBSTATE_T
       
   649 
       
   650 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id moneypunct<char, true>::id = { 4 };
       
   651 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id moneypunct<char, false>::id = { 5 };
       
   652 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id messages<char>::id = { 7 };
       
   653 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id numpunct<char>::id = { 6 } ;
       
   654 
       
   655 # ifndef _STLP_NO_WCHAR_T
       
   656 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id collate<wchar_t>::id = { 20 };
       
   657 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id ctype<wchar_t>::id = { 21 };
       
   658 
       
   659 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id moneypunct<wchar_t, true>::id = { 23 } ;
       
   660 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id moneypunct<wchar_t, false>::id = { 24 } ;
       
   661 
       
   662 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id numpunct<wchar_t>::id = { 25 };
       
   663 _STLP_STATIC_MEMBER_EXP_DECLSPEC locale::id messages<wchar_t>::id = { 26 };
       
   664 # endif //!_STLP_NO_WCHAR_T
       
   665 # endif //!__LIBSTD_CPP_SYMBIAN32_WSD__
       
   666 //
       
   667 // locale class
       
   668 //
       
   669 
       
   670 _STLP_EXP_DECLSPEC locale::facet::~facet() {}
       
   671 
       
   672 # if ! defined ( _STLP_MEMBER_TEMPLATES ) || defined (_STLP_INLINE_MEMBER_TEMPLATES)
       
   673 // members that fail to be templates 
       
   674 bool locale::operator()(const string& __x,
       
   675                         const string& __y) const {
       
   676   return __locale_do_operator_call(this, __x, __y);
       
   677 }
       
   678 
       
   679 #  ifndef _STLP_NO_WCHAR_T
       
   680 bool locale::operator()(const wstring& __x,
       
   681                   const wstring& __y) const {
       
   682   return __locale_do_operator_call(this, __x, __y);
       
   683 }
       
   684 #  endif
       
   685 # endif
       
   686 
       
   687 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   688 _Locale_impl*   _Locale_impl::_S_global_impl    = 0;
       
   689 static _Stl_aligned_buffer<locale> _S_b_classic;
       
   690 _STLP_STATIC_MUTEX _Locale_impl::_S_global_locale_lock _STLP_MUTEX_INITIALIZER;
       
   691 // locale          _Locale_impl::_S_classic(__REINTERPRET_CAST(_Locale_impl*, &_S_classic_locale));
       
   692 # endif
       
   693 
       
   694 
       
   695 
       
   696   
       
   697 //----------------------------------------------------------------------
       
   698 // class locale
       
   699 
       
   700 _STLP_EXP_DECLSPEC void _STLP_CALL
       
   701 locale::_M_throw_runtime_error(const char* name)
       
   702 {
       
   703   char buf[256];
       
   704 
       
   705   if (name) {
       
   706     const char* prefix = "bad locale name: ";
       
   707     strcpy(buf, prefix);
       
   708     strncat(buf, name, 256 - strlen(prefix));
       
   709     buf[255] = '\0';
       
   710   }
       
   711   else {
       
   712     strcpy(buf, "locale error");
       
   713   }
       
   714   _STLP_THROW(runtime_error(buf));
       
   715 }
       
   716 
       
   717 #if defined(__SYMBIAN32__) || (!( defined (__BORLANDC__) && defined(_RTLDLL)))
       
   718 
       
   719 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   720 void ios_base_Loc_init_S_count_init()
       
   721 {
       
   722 	get_ios_base_Loc_init_S_count() = 0;	
       
   723 }
       
   724 # else
       
   725 long ios_base::_Loc_init::_S_count = 0;
       
   726 # endif
       
   727 
       
   728 _STLP_EXP_DECLSPEC ios_base::_Loc_init::_Loc_init() {
       
   729   //  if (_S_count++ == 0)
       
   730       locale::_S_initialize();
       
   731 }
       
   732 
       
   733 _STLP_EXP_DECLSPEC ios_base::_Loc_init::~_Loc_init() {
       
   734   //    if (--_S_count == 0)
       
   735       locale::_S_uninitialize();
       
   736 }
       
   737 
       
   738 #endif /* _RTLDLL */
       
   739 
       
   740 // Initialization of the locale system.  This must be called before
       
   741 // any locales are constructed.  (Meaning that it must be called when
       
   742 // the I/O library itself is initialized.)
       
   743 void _STLP_CALL
       
   744 locale::_S_initialize()
       
   745 {
       
   746   // additional check for singleton count : linker may choose to alter the order of function calls on initialization
       
   747 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   748 	if (get_ios_base_Loc_init_S_count()++ > 0 )
       
   749     	return;
       
   750 # else
       
   751 	if (ios_base::_Loc_init::_S_count++ > 0 )
       
   752     	return;
       
   753 # endif  
       
   754   
       
   755   _Stl_loc_assign_ids();
       
   756   
       
   757 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   758 	get_locale_impl_S_global_impl() = _Locale_impl::make_classic_locale();
       
   759 	locale* loc = __REINTERPRET_CAST(locale*, &get_locale_impl_S_b_classic());
       
   760 	new (loc) locale (get_locale_impl_S_global_impl());
       
   761 	global_iostream_init();
       
   762 # else
       
   763 	_Locale_impl::_S_global_impl = _Locale_impl::make_classic_locale();
       
   764 	locale* loc = __REINTERPRET_CAST(locale*, &_S_b_classic);
       
   765 	new (loc) locale (_Locale_impl::_S_global_impl);
       
   766 # endif  
       
   767   
       
   768 }
       
   769 
       
   770 void _STLP_CALL
       
   771 locale::_S_uninitialize()
       
   772 {
       
   773   // additional check for singleton count : linker may choose to alter the order of function calls on initialization
       
   774  #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   775  	if (--get_ios_base_Loc_init_S_count() != 0 )
       
   776     	return;
       
   777  # else
       
   778  	if (--ios_base::_Loc_init::_S_count != 0 )
       
   779     	return;
       
   780  # endif
       
   781   
       
   782  #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   783  	get_locale_impl_S_global_impl()->decr();
       
   784  # else
       
   785  	_Locale_impl::_S_global_impl->decr();
       
   786  # endif	  
       
   787 }
       
   788 
       
   789 // Default constructor: create a copy of the global locale.
       
   790 _STLP_EXP_DECLSPEC locale::locale() : _M_impl(0) {
       
   791  #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   792  	_M_impl = _S_copy_impl(get_locale_impl_S_global_impl());
       
   793  # else
       
   794  	_M_impl = _S_copy_impl(_Locale_impl::_S_global_impl);
       
   795  # endif  
       
   796 }
       
   797 
       
   798 _STLP_EXP_DECLSPEC locale::locale(_Locale_impl* impl) : _M_impl(impl)
       
   799 {}
       
   800 
       
   801 // Copy constructor
       
   802 _STLP_EXP_DECLSPEC locale::locale(const locale& L) _STLP_NOTHROW
       
   803   : _M_impl(0)
       
   804 {
       
   805   _M_impl = _S_copy_impl(L._M_impl);
       
   806 }
       
   807 
       
   808 // Destructor.
       
   809 _STLP_EXP_DECLSPEC locale::~locale() _STLP_NOTHROW
       
   810 {
       
   811   if (_M_impl) {
       
   812   _M_impl->decr();
       
   813   _M_impl = 0;
       
   814   }
       
   815 }
       
   816 
       
   817 // Assignment operator.  Much like the copy constructor: just a bit of
       
   818 // pointer twiddling.
       
   819 _STLP_EXP_DECLSPEC const locale& locale::operator=(const locale& L) _STLP_NOTHROW
       
   820 {
       
   821   if (this->_M_impl != L._M_impl) {
       
   822     this->_M_impl->decr();
       
   823     this->_M_impl = _S_copy_impl(L._M_impl);
       
   824   }
       
   825   return *this;
       
   826 }
       
   827 
       
   828 _STLP_EXP_DECLSPEC locale::facet* locale::_M_get_facet(const locale::id& n) const
       
   829 {
       
   830   return n._M_index < _M_impl->size()
       
   831     ? __REINTERPRET_CAST(locale::facet*,_M_impl->facets[n._M_index])
       
   832     : __REINTERPRET_CAST(locale::facet*, 0);
       
   833 }
       
   834 
       
   835 _STLP_EXP_DECLSPEC locale::facet* locale::_M_use_facet(const locale::id& n) const
       
   836 {
       
   837   locale::facet* f = (n._M_index < _M_impl->size()
       
   838 		      ? __REINTERPRET_CAST(locale::facet*,_M_impl->facets[n._M_index])
       
   839 		      : __REINTERPRET_CAST(locale::facet*, 0));
       
   840   if (!f)
       
   841     _M_impl->_M_throw_bad_cast();
       
   842   return f;
       
   843 }
       
   844 
       
   845 _STLP_EXP_DECLSPEC string locale::name() const {
       
   846   return _M_impl->name;
       
   847 }
       
   848 
       
   849 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   850 void locale_impl_string_init()
       
   851 {
       
   852 	get_locale_impl_nameless().copy("*", 1);
       
   853 }
       
   854 # else
       
   855 static string _Nameless("*");
       
   856 # endif
       
   857 
       
   858 // Compare two locales for equality.
       
   859 _STLP_EXP_DECLSPEC bool locale::operator==(const locale& L) const {
       
   860 
       
   861 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   862   return this->_M_impl == L._M_impl ||
       
   863          (this->name() == L.name() && this->name() != get_locale_impl_nameless());
       
   864 # else
       
   865   return this->_M_impl == L._M_impl ||
       
   866          (this->name() == L.name() && this->name() != _Nameless);
       
   867 # endif  //__LIBSTD_CPP_SYMBIAN32_WSD__       
       
   868 }
       
   869 
       
   870 _STLP_EXP_DECLSPEC bool locale::operator!=(const locale& L) const {
       
   871   return !(*this == L);
       
   872 }
       
   873 
       
   874 // Static member functions.
       
   875 _STLP_EXP_DECLSPEC const locale&  _STLP_CALL
       
   876 locale::classic() {
       
   877   //  return _Locale_impl::_S_classic;
       
   878 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   879   return *__REINTERPRET_CAST(const locale*, &get_locale_impl_S_b_classic());	
       
   880 # else  
       
   881   return *__REINTERPRET_CAST(const locale*, &_S_b_classic);
       
   882 # endif
       
   883 }
       
   884 
       
   885 _STLP_EXP_DECLSPEC locale  _STLP_CALL
       
   886 locale::global(const locale& L) 
       
   887 {
       
   888   locale old;                   // A copy of the old global locale.
       
   889 
       
   890   L._M_impl->incr();
       
   891   { 
       
   892 
       
   893 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   894     _STLP_auto_lock lock(get_locale_impl_S_global_locale_lock());\
       
   895     get_locale_impl_S_global_impl()->decr();     // We made a copy, so it can't be zero.
       
   896     get_locale_impl_S_global_impl() = L._M_impl;
       
   897 # else
       
   898     _STLP_auto_lock lock(_Locale_impl::_S_global_locale_lock);\
       
   899 	_Locale_impl::_S_global_impl->decr();     // We made a copy, so it can't be zero.
       
   900     _Locale_impl::_S_global_impl = L._M_impl;
       
   901 # endif    
       
   902   }
       
   903 
       
   904                                 // Set the global C locale, if appropriate.
       
   905 #if !defined(_STLP_WINCE)
       
   906 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
       
   907 	if (L.name() != get_locale_impl_nameless())
       
   908 # else
       
   909 	if (L.name() != _Nameless)
       
   910 # endif  
       
   911     setlocale(LC_ALL, L.name().c_str());
       
   912 #endif
       
   913 
       
   914   return old;
       
   915 }
       
   916 
       
   917 
       
   918 // static data members.
       
   919 
       
   920 # if !defined (_STLP_STATIC_CONST_INIT_BUG) && ! defined (_STLP_USE_DECLSPEC)
       
   921 
       
   922 const locale::category locale::none;
       
   923 const locale::category locale::collate;
       
   924 const locale::category locale::ctype;
       
   925 const locale::category locale::monetary;
       
   926 const locale::category locale::numeric;
       
   927 const locale::category locale::time; 
       
   928 const locale::category locale::messages;
       
   929 const locale::category locale::all;
       
   930 
       
   931 # endif
       
   932 
       
   933 
       
   934 #if defined(__SYMBIAN32__) && defined( __WINSCW__)
       
   935 
       
   936 extern "C" bool __uncaught_exception(void);
       
   937 
       
   938 _STLP_EXP_DECLSPEC bool uncaught_exception()
       
   939 {
       
   940     // providing default implementation
       
   941 
       
   942 #if __MWERKS__ > 0x3200
       
   943 	return __uncaught_exception();
       
   944 #else
       
   945 	// no uncaught_exception() implementation on CW 2.4.7
       
   946 	return false;
       
   947 #endif
       
   948 
       
   949 }
       
   950 #endif
       
   951 
       
   952 _STLP_END_NAMESPACE
       
   953 
       
   954 //
       
   955 // Facets included in classic locale :
       
   956 //
       
   957 
       
   958 
       
   959