sl@0: /*
sl@0:  * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0:  *
sl@0:  * Copyright (c) 1999
sl@0:  * Silicon Graphics Computer Systems, Inc.
sl@0:  *
sl@0:  * Copyright (c) 1999
sl@0:  * Boris Fomitchev
sl@0:  *
sl@0:  * This material is provided "as is", with absolutely no warranty expressed
sl@0:  * or implied. Any use is at your own risk.
sl@0:  *
sl@0:  * Permission to use or copy this software for any purpose is hereby granted
sl@0:  * without fee, provided the above notices are retained on all copies.
sl@0:  * Permission to modify the code and to distribute modified code is granted,
sl@0:  * provided the above notices are retained, and a notice that the code was
sl@0:  * modified is included with the above copyright notice.
sl@0:  *
sl@0:  */
sl@0: #include "stlport_prefix.h"
sl@0: 
sl@0: #include <locale>
sl@0: #include <typeinfo>
sl@0: #include <algorithm>
sl@0: #include <stdexcept>
sl@0: 
sl@0: #include "c_locale.h"
sl@0: #include "aligned_buffer.h"
sl@0: #include "locale_impl.h"
sl@0: #include "message_facets.h"
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__)
sl@0: #include "libstdcppwsd.h"
sl@0: 
sl@0: std::_Stl_aligned_buffer<std::_Locale_impl::Init>& get_Loc_init_buf()
sl@0:     {
sl@0:     return *(std::_Stl_aligned_buffer<std::_Locale_impl::Init> *)(get_libcpp_wsd().__Loc_init_buf);
sl@0:     }
sl@0: 
sl@0: #define __Loc_init_buf		get_Loc_init_buf()
sl@0: #define _S_count 			get_Loc_init_S_count()
sl@0: #define _Index_lock			get_locale_Index_lock()
sl@0: #define _S_index			get_S_index()
sl@0: #define _S_max				get_locale_id_S_max()
sl@0: #define _Stl_classic_locale get_Stl_classic_locale()
sl@0: #define _Stl_global_locale  get_Stl_global_locale()
sl@0: 
sl@0: #endif  //__SYMBIAN32__WSD__
sl@0: 
sl@0: _STLP_BEGIN_NAMESPACE
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__) && defined(_STLP_DEBUG)
sl@0: #define _Nameless *get_Nameless()
sl@0: #else
sl@0: static const string _Nameless("*");
sl@0: #endif
sl@0: 
sl@0: static inline bool is_C_locale_name (const char* name)
sl@0: { return ((name[0] == 'C') && (name[1] == 0)); }
sl@0: 
sl@0: _Locale_impl * _STLP_CALL _copy_Locale_impl(_Locale_impl *loc)
sl@0: {
sl@0:   _STLP_ASSERT( loc != 0 );
sl@0:   loc->_M_incr();
sl@0:   _Locale_impl *loc_new = new _Locale_impl(*loc);
sl@0:   loc->_M_decr();
sl@0:   return loc_new;
sl@0: }
sl@0: 
sl@0: locale::facet * _STLP_CALL _get_facet(locale::facet *f)
sl@0: {
sl@0:   if (f != 0)
sl@0:     f->_M_incr();
sl@0:   return f;
sl@0: }
sl@0: 
sl@0: void _STLP_CALL _release_facet(locale::facet *&f)
sl@0: {
sl@0:   if ((f != 0) && (f->_M_decr() == 0)) {
sl@0:     delete f;
sl@0:     f = 0;
sl@0:   }
sl@0: }
sl@0: # if !defined(__SYMBIAN32__WSD__)
sl@0: # if !defined(__SYMBIAN32__NO_STATIC_IMPORTS__)
sl@0: _STLP_STATIC_MEMBER_DECLSPEC size_t locale::id::_S_max = 39;
sl@0: #else
sl@0: size_t locale::id::_S_max = 39;
sl@0: #endif
sl@0: # endif //__SYMBIAN32__WSD__
sl@0: 
sl@0: static void _Stl_loc_assign_ids();
sl@0: 
sl@0: #if !defined(__SYMBIAN32__WSD__)
sl@0: static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf;
sl@0: #endif
sl@0: 
sl@0: _Locale_impl::Init::Init() {
sl@0:   if (_M_count()._M_incr() == 1) {
sl@0:     _Locale_impl::_S_initialize();
sl@0:   }
sl@0: }
sl@0: 
sl@0: _Locale_impl::Init::~Init() {
sl@0:   if (_M_count()._M_decr() == 0) {
sl@0:     _Locale_impl::_S_uninitialize();
sl@0:   }
sl@0: }
sl@0: 
sl@0: _Refcount_Base& _Locale_impl::Init::_M_count() const {
sl@0: #if !defined(__SYMBIAN32__WSD__)	
sl@0:   static _Refcount_Base _S_count(0);
sl@0: #endif
sl@0:   return _S_count;
sl@0: }
sl@0: 
sl@0: _Locale_impl::_Locale_impl(const char* s)
sl@0:   : _Refcount_Base(0), name(s), facets_vec() {
sl@0:   facets_vec.reserve( locale::id::_S_max );
sl@0:   new (&__Loc_init_buf) Init();
sl@0: }
sl@0: 
sl@0: _Locale_impl::_Locale_impl( _Locale_impl const& locimpl )
sl@0:   : _Refcount_Base(0), name(locimpl.name), facets_vec() {
sl@0:   for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet);
sl@0:   facets_vec = locimpl.facets_vec;
sl@0:   new (&__Loc_init_buf) Init();
sl@0: }
sl@0: 
sl@0: _Locale_impl::_Locale_impl( size_t n, const char* s)
sl@0:   : _Refcount_Base(0), name(s), facets_vec(n, 0) {
sl@0:   new (&__Loc_init_buf) Init();
sl@0: }
sl@0: 
sl@0: _Locale_impl::~_Locale_impl() {
sl@0:   (&__Loc_init_buf)->~Init();
sl@0:   for_each( facets_vec.begin(), facets_vec.end(), _release_facet);
sl@0: }
sl@0: 
sl@0: // Initialization of the locale system.  This must be called before
sl@0: // any locales are constructed.  (Meaning that it must be called when
sl@0: // the I/O library itself is initialized.)
sl@0: void _STLP_CALL _Locale_impl::_S_initialize() {
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__)
sl@0:   //initialize wsd obj pointer
sl@0:   locale_impl_init();
sl@0: # endif
sl@0: 
sl@0:   _Stl_loc_assign_ids();
sl@0:   make_classic_locale();
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__)   
sl@0:   global_iostream_init();
sl@0: # endif
sl@0: }
sl@0: 
sl@0: // Release of the classic locale ressources. Has to be called after the last
sl@0: // locale destruction and not only after the classic locale destruction as
sl@0: // the facets can be shared between different facets.
sl@0: void _STLP_CALL _Locale_impl::_S_uninitialize() {
sl@0:   //Not necessary anymore as classic facets are now 'normal' dynamically allocated
sl@0:   //facets with a reference counter telling to _release_facet when the facet can be
sl@0:   //deleted.
sl@0:   //free_classic_locale();
sl@0: }
sl@0: 
sl@0: // _Locale_impl non-inline member functions.
sl@0: void _STLP_CALL _Locale_impl::_M_throw_bad_cast() {
sl@0:   _STLP_THROW(bad_cast());
sl@0: }
sl@0: 
sl@0: void _Locale_impl::insert( _Locale_impl *from, const locale::id& n ) {
sl@0:   size_t index = n._M_index;
sl@0:   if (index > 0 && index < from->size()) {
sl@0:     this->insert( from->facets_vec[index], index);
sl@0:   }
sl@0: }
sl@0: 
sl@0: locale::facet* _Locale_impl::insert(locale::facet *f, size_t index) {
sl@0:   if (f == 0 || index == 0)
sl@0:     return 0;
sl@0: 
sl@0:   if (index >= facets_vec.size()) {
sl@0:     facets_vec.resize(index + 1);
sl@0:   }
sl@0: 
sl@0:   if (f != facets_vec[index])
sl@0:   {
sl@0:     _release_facet(facets_vec[index]);
sl@0:     facets_vec[index] = _get_facet(f);
sl@0:   }
sl@0: 
sl@0:   return f;
sl@0: }
sl@0: 
sl@0: #if !defined (__DMC__)
sl@0: _Locale_name_hint* _Locale_extract_hint(ctype_byname<char>* ct)
sl@0: { return _Locale_get_ctype_hint(ct->_M_ctype); }
sl@0: _Locale_name_hint* _Locale_extract_hint(numpunct_byname<char>* punct)
sl@0: { return _Locale_get_numeric_hint(punct->_M_numeric); }
sl@0: #  if defined (__GNUC__) && (__GNUC__ < 3)
sl@0: template <class _Ch, class _InIt>
sl@0: _Locale_name_hint* _Locale_time_extract_hint(time_get_byname<_Ch, _InIt>* tget)
sl@0: #  else
sl@0: _Locale_name_hint* _Locale_time_extract_hint(time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >* tget)
sl@0: #  endif
sl@0: { return _Locale_get_time_hint(tget->_M_time); }
sl@0: _Locale_name_hint* _Locale_extract_hint(collate_byname<char>* coll)
sl@0: { return _Locale_get_collate_hint(coll->_M_collate); }
sl@0: _Locale_name_hint* _Locale_extract_hint(moneypunct_byname<char, false>* money)
sl@0: { return _Locale_get_monetary_hint(money->_M_monetary); }
sl@0: #endif
sl@0: 
sl@0: //
sl@0: // <locale> content which is dependent on the name
sl@0: //
sl@0: #if defined(__SYMBIAN32__WSD__) 
sl@0: #define id					GetFacetLocaleId()
sl@0: #endif
sl@0: 
sl@0: template <class Facet>
sl@0: static inline locale::facet* _Locale_insert(_Locale_impl *__that, Facet* f)
sl@0: { return __that->insert(f, Facet::id._M_index); }
sl@0: 
sl@0: /*
sl@0:  * Six functions, one for each category.  Each of them takes a
sl@0:  * _Locale* and a name, constructs that appropriate category
sl@0:  * facets by name, and inserts them into the locale.
sl@0:  */
sl@0: _Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* pname, _Locale_name_hint* hint) {
sl@0:   char buf[_Locale_MAX_SIMPLE_NAME];
sl@0:   _Locale_impl* i2 = locale::classic()._M_impl;
sl@0: 
sl@0:   if (pname == 0 || pname[0] == 0)
sl@0:     pname = _Locale_ctype_default(buf);
sl@0: 
sl@0:   if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0:     this->insert(i2, ctype<char>::id);
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0:     this->insert(i2, codecvt<char, char, mbstate_t>::id);
sl@0: #endif
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     this->insert(i2, ctype<wchar_t>::id);
sl@0: #  ifndef _STLP_NO_MBSTATE_T
sl@0:     this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
sl@0: #  endif
sl@0: #endif
sl@0:   } else {
sl@0:     ctype<char>*    ct                      = 0;
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0:     codecvt<char, char, mbstate_t>*    cvt  = 0;
sl@0: #endif
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     ctype<wchar_t>* wct                     = 0;
sl@0:     codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
sl@0: #endif
sl@0:     _STLP_TRY {
sl@0:       ctype_byname<char> *ctbn = new ctype_byname<char>(pname, 0, hint);
sl@0:       ct   = ctbn;
sl@0: #if !defined (__DMC__)
sl@0:       if (hint == 0) hint = _Locale_extract_hint(ctbn);
sl@0: #endif
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0:       cvt  = new codecvt_byname<char, char, mbstate_t>(pname);
sl@0: #endif
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:       wct  = new ctype_byname<wchar_t>(pname, 0, hint);
sl@0:       wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname, 0, hint);
sl@0: #endif
sl@0:     }
sl@0: 
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0: #  ifdef _STLP_NO_MBSTATE_T
sl@0:     _STLP_UNWIND(delete ct; delete wct; delete wcvt);
sl@0: #  else
sl@0:     _STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
sl@0: #  endif
sl@0: #else
sl@0: #  ifdef _STLP_NO_MBSTATE_T
sl@0:     _STLP_UNWIND(delete ct);
sl@0: #  else
sl@0:     _STLP_UNWIND(delete ct; delete cvt);
sl@0: #  endif
sl@0: #endif
sl@0:     _Locale_insert(this, ct);
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0:     _Locale_insert(this, cvt);
sl@0: #endif
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _Locale_insert(this, wct);
sl@0:     _Locale_insert(this, wcvt);
sl@0: #endif
sl@0:   }
sl@0:   return hint;
sl@0: }
sl@0: 
sl@0: _Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* pname, _Locale_name_hint* hint) {
sl@0:   _Locale_impl* i2 = locale::classic()._M_impl;
sl@0: 
sl@0:   numpunct<char>* punct = 0;
sl@0:   num_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0;
sl@0:   num_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0;
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:   numpunct<wchar_t>* wpunct = 0;
sl@0:   num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0;
sl@0:   num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0;
sl@0: #endif
sl@0: 
sl@0:   char buf[_Locale_MAX_SIMPLE_NAME];
sl@0:   if (pname == 0 || pname[0] == 0)
sl@0:     pname = _Locale_numeric_default(buf);
sl@0: 
sl@0:   if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0:     this->insert(i2, numpunct<char>::id);
sl@0:     this->insert(i2,
sl@0:                  num_put<char, ostreambuf_iterator<char, char_traits<char> >  >::id);
sl@0:     this->insert(i2,
sl@0:                  num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     this->insert(i2, numpunct<wchar_t>::id);
sl@0:     this->insert(i2,
sl@0:                  num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> >  >::id);
sl@0:     this->insert(i2,
sl@0:                  num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0: #endif
sl@0:   }
sl@0:   else {
sl@0:     _STLP_TRY {
sl@0:       numpunct_byname<char> *punctbn = new numpunct_byname<char>(pname, 0, hint);
sl@0:       punct  = punctbn;
sl@0: #if !defined (__DMC__)
sl@0:       if (hint == 0) hint = _Locale_extract_hint(punctbn);
sl@0: #endif
sl@0:       get    = new num_get<char, istreambuf_iterator<char, char_traits<char> > >;
sl@0:       put    = new num_put<char, ostreambuf_iterator<char, char_traits<char> > >;
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:       wpunct = new numpunct_byname<wchar_t>(pname, 0, hint);
sl@0:       wget   = new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0:       wput   = new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0: #endif
sl@0:     }
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _STLP_UNWIND(delete punct; delete wpunct; delete get; delete wget; delete put; delete wput);
sl@0: #else
sl@0:     _STLP_UNWIND(delete punct; delete get;delete put);
sl@0: #endif
sl@0: 
sl@0:     _Locale_insert(this,punct);
sl@0:     _Locale_insert(this,get);
sl@0:     _Locale_insert(this,put);
sl@0: 
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _Locale_insert(this,wpunct);
sl@0:     _Locale_insert(this,wget);
sl@0:     _Locale_insert(this,wput);
sl@0: #endif
sl@0:   }
sl@0:   return hint;
sl@0: }
sl@0: 
sl@0: _Locale_name_hint* _Locale_impl::insert_time_facets(const char* pname, _Locale_name_hint* hint) {
sl@0:   _Locale_impl* i2 = locale::classic()._M_impl;
sl@0:   time_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0;
sl@0:   time_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0;
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:   time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0;
sl@0:   time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0;
sl@0: #endif
sl@0: 
sl@0:   char buf[_Locale_MAX_SIMPLE_NAME];
sl@0:   if (pname == 0 || pname[0] == 0)
sl@0:     pname = _Locale_time_default(buf);
sl@0: 
sl@0:   if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0: 
sl@0:     this->insert(i2,
sl@0:                  time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
sl@0:     this->insert(i2,
sl@0:                  time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     this->insert(i2,
sl@0:                  time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0:     this->insert(i2,
sl@0:                  time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0: #endif
sl@0:   } else {
sl@0:     _STLP_TRY {
sl@0:       time_get_byname<char, istreambuf_iterator<char, char_traits<char> > > *getbn =
sl@0:         new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(pname, 0, hint);
sl@0:       get  = getbn;
sl@0: #if !defined (__DMC__)
sl@0:       if (hint == 0) hint = _Locale_time_extract_hint(getbn);
sl@0: #endif
sl@0:       put  = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(pname, 0, hint);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:       wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname, 0, hint);
sl@0:       wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname, 0, hint);
sl@0: #endif
sl@0:     }
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _STLP_UNWIND(delete get; delete wget; delete put; delete wput);
sl@0: #else
sl@0:     _STLP_UNWIND(delete get; delete put);
sl@0: #endif
sl@0:     _Locale_insert(this,get);
sl@0:     _Locale_insert(this,put);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _Locale_insert(this,wget);
sl@0:     _Locale_insert(this,wput);
sl@0: #endif
sl@0:   }
sl@0:   return hint;
sl@0: }
sl@0: 
sl@0: _Locale_name_hint* _Locale_impl::insert_collate_facets(const char* nam, _Locale_name_hint* hint) {
sl@0:   _Locale_impl* i2 = locale::classic()._M_impl;
sl@0: 
sl@0:   collate<char> *col = 0;
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:   collate<wchar_t> *wcol = 0;
sl@0: #endif
sl@0: 
sl@0:   char buf[_Locale_MAX_SIMPLE_NAME];
sl@0:   if (nam == 0 || nam[0] == 0)
sl@0:     nam = _Locale_collate_default(buf);
sl@0: 
sl@0:   if (nam == 0 || nam[0] == 0 || is_C_locale_name(nam)) {
sl@0:     this->insert(i2, collate<char>::id);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     this->insert(i2, collate<wchar_t>::id);
sl@0: #endif
sl@0:   }
sl@0:   else {
sl@0:     _STLP_TRY {
sl@0:       collate_byname<char> *colbn = new collate_byname<char>(nam, 0, hint);
sl@0:       col   = colbn;
sl@0: #if !defined (__DMC__)
sl@0:       if (hint == 0) hint = _Locale_extract_hint(colbn);
sl@0: #endif
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:       wcol  = new collate_byname<wchar_t>(nam, 0, hint);
sl@0: #endif
sl@0:     }
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _STLP_UNWIND(delete col; delete wcol);
sl@0: #else
sl@0:     _STLP_UNWIND(delete col);
sl@0: #endif
sl@0:     _Locale_insert(this,col);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _Locale_insert(this,wcol);
sl@0: #endif
sl@0:   }
sl@0:   return hint;
sl@0: }
sl@0: 
sl@0: _Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* pname, _Locale_name_hint* hint) {
sl@0:   _Locale_impl* i2 = locale::classic()._M_impl;
sl@0: 
sl@0:   moneypunct<char, false> *punct = 0;
sl@0:   moneypunct<char, true> *ipunct = 0;
sl@0:   money_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0;
sl@0:   money_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0;
sl@0: 
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:   moneypunct<wchar_t, false>* wpunct = 0;
sl@0:   moneypunct<wchar_t, true>* wipunct = 0;
sl@0:   money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0;
sl@0:   money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0;
sl@0: #endif
sl@0: 
sl@0:   char buf[_Locale_MAX_SIMPLE_NAME];
sl@0:   if (pname == 0 || pname[0] == 0)
sl@0:     pname = _Locale_monetary_default(buf);
sl@0: 
sl@0:   if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0:     this->insert(i2, moneypunct<char, false>::id);
sl@0:     this->insert(i2, moneypunct<char, true>::id);
sl@0:     this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
sl@0:     this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     this->insert(i2, moneypunct<wchar_t, false>::id);
sl@0:     this->insert(i2, moneypunct<wchar_t, true>::id);
sl@0:     this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0:     this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0: #endif
sl@0:   }
sl@0:   else {
sl@0:     _STLP_TRY {
sl@0:       moneypunct_byname<char, false>* punctbn = new moneypunct_byname<char, false>(pname, 0, hint);
sl@0:       punct   = punctbn;
sl@0: #if !defined (__DMC__)
sl@0:       if (hint == 0) hint = _Locale_extract_hint(punctbn);
sl@0: #endif
sl@0:       ipunct  = new moneypunct_byname<char, true>(pname, 0, hint);
sl@0:       get     = new money_get<char, istreambuf_iterator<char, char_traits<char> > >;
sl@0:       put     = new money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:       wpunct  = new moneypunct_byname<wchar_t, false>(pname, 0, hint);
sl@0:       wipunct = new moneypunct_byname<wchar_t, true>(pname, 0, hint);
sl@0:       wget    = new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0:       wput    = new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0: #endif
sl@0:     }
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _STLP_UNWIND(delete punct; delete ipunct; delete wpunct; delete wipunct; delete get; delete wget; delete put; delete wput);
sl@0: #else
sl@0:     _STLP_UNWIND(delete punct; delete ipunct; delete get; delete put);
sl@0: #endif
sl@0:     _Locale_insert(this,punct);
sl@0:     _Locale_insert(this,ipunct);
sl@0:     _Locale_insert(this,get);
sl@0:     _Locale_insert(this,put);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _Locale_insert(this,wget);
sl@0:     _Locale_insert(this,wpunct);
sl@0:     _Locale_insert(this,wipunct);
sl@0:     _Locale_insert(this,wput);
sl@0: #endif
sl@0:   }
sl@0:   return hint;
sl@0: }
sl@0: 
sl@0: _Locale_name_hint* _Locale_impl::insert_messages_facets(const char* pname, _Locale_name_hint* hint) {
sl@0:   _Locale_impl* i2 = locale::classic()._M_impl;
sl@0:   messages<char> *msg = 0;
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:   messages<wchar_t> *wmsg = 0;
sl@0: #endif
sl@0: 
sl@0:   char buf[_Locale_MAX_SIMPLE_NAME];
sl@0:   if (pname == 0 || pname[0] == 0)
sl@0:     pname = _Locale_messages_default(buf);
sl@0: 
sl@0:   if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0:     this->insert(i2, messages<char>::id);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     this->insert(i2, messages<wchar_t>::id);
sl@0: #endif
sl@0:   }
sl@0:   else {
sl@0:     _STLP_TRY {
sl@0:       msg  = new messages_byname<char>(pname, 0, hint);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:       wmsg = new messages_byname<wchar_t>(pname, 0, hint);
sl@0: #endif
sl@0:     }
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _STLP_UNWIND(delete msg; delete wmsg);
sl@0: #else
sl@0:     _STLP_UNWIND(delete msg);
sl@0: #endif
sl@0:     _Locale_insert(this,msg);
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     _Locale_insert(this,wmsg);
sl@0: #endif
sl@0:   }
sl@0:   return hint;
sl@0: }
sl@0: 
sl@0: static void _Stl_loc_assign_ids() {
sl@0:   // This assigns ids to every facet that is a member of a category,
sl@0:   // and also to money_get/put, num_get/put, and time_get/put
sl@0:   // instantiated using ordinary pointers as the input/output
sl@0:   // iterators.  (The default is [io]streambuf_iterator.)
sl@0: 
sl@0: #ifdef __SYMBIAN32__WSD__
sl@0: 	collate<char>::id._M_index =  1;
sl@0: 	ctype<char>::id._M_index = 2;
sl@0: 
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0: 	codecvt<char, char, mbstate_t>::id._M_index = 3;
sl@0: #  ifndef _STLP_NO_WCHAR_T
sl@0: 	codecvt<wchar_t, char, mbstate_t>::id._M_index = 22;
sl@0: #  endif
sl@0: #endif
sl@0: 	moneypunct<char, true>::id._M_index = 4;
sl@0: 	moneypunct<char, false>::id._M_index = 5;
sl@0: 	numpunct<char>::id._M_index = 6;
sl@0: 	messages<char>::id._M_index =7;
sl@0: 	
sl@0: 	collate<wchar_t>::id._M_index = 20;
sl@0: 	ctype<wchar_t>::id._M_index = 21;
sl@0: 	moneypunct<wchar_t, true>::id._M_index = 23;
sl@0: 	moneypunct<wchar_t, false>::id._M_index = 24;
sl@0: 	numpunct<wchar_t>::id._M_index = 25;
sl@0: 	messages<wchar_t>::id._M_index = 26;
sl@0: #endif
sl@0: 
sl@0: 
sl@0:   money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index          = 8;
sl@0:   //money_get<char, const char*>::id._M_index                                             = 9;
sl@0:   money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index          = 10;
sl@0:   //money_put<char, char*>::id._M_index                                                   = 11;
sl@0: 
sl@0:   num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index            = 12;
sl@0:   //num_get<char, const char*>::id._M_index                                               = 13;
sl@0:   num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index            = 14;
sl@0:   //num_put<char, char*>::id._M_index                                                     = 15;
sl@0:   time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index           = 16;
sl@0:   //time_get<char, const char*>::id._M_index                                              = 17;
sl@0:   time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index           = 18;
sl@0:   //time_put<char, char*>::id._M_index                                                    = 19;
sl@0: 
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:   money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 27;
sl@0:   //money_get<wchar_t, const wchar_t*>::id._M_index                                       = 28;
sl@0:   money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 29;
sl@0:   //money_put<wchar_t, wchar_t*>::id._M_index                                             = 30;
sl@0: 
sl@0:   num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index   = 31;
sl@0:   //num_get<wchar_t, const wchar_t*>::id._M_index                                         = 32;
sl@0:   num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index  = 33;
sl@0:   //num_put<wchar_t, wchar_t*>::id._M_index                                               = 34;
sl@0:   time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index  = 35;
sl@0:   //time_get<wchar_t, const wchar_t*>::id._M_index                                        = 36;
sl@0:   time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index  = 37;
sl@0:   //time_put<wchar_t, wchar_t*>::id._M_index                                              = 38;
sl@0: #endif
sl@0:   //  locale::id::_S_max                               = 39;
sl@0: }
sl@0: 
sl@0: // To access those static instance use the getter below, they guaranty
sl@0: // a correct initialization.
sl@0: #if !defined(__SYMBIAN32__WSD__)
sl@0: static locale *_Stl_classic_locale = 0;
sl@0: static locale *_Stl_global_locale = 0;
sl@0: #endif
sl@0: 
sl@0: static locale* _Stl_get_classic_locale() {
sl@0: #if !defined(__SYMBIAN32__WSD__)
sl@0:   static _Locale_impl::Init init;
sl@0: #endif  
sl@0:   return _Stl_classic_locale;
sl@0: }
sl@0: 
sl@0: static locale* _Stl_get_global_locale() {
sl@0: #if !defined(__SYMBIAN32__WSD__)
sl@0:   static _Locale_impl::Init init;
sl@0: #endif
sl@0:   return _Stl_global_locale;
sl@0: }
sl@0: 
sl@0: #if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__)
sl@0: /*
sl@0:  * The following static variable needs to be initialized before STLport
sl@0:  * users static variable in order for him to be able to use Standard
sl@0:  * streams in its variable initialization.
sl@0:  * This variable is here because MSVC do not allow to change the initialization
sl@0:  * segment in a given translation unit, iostream.cpp already contains an
sl@0:  * initialization segment specification.
sl@0:  */
sl@0: #  pragma warning (disable : 4073)
sl@0: #  pragma init_seg(lib)
sl@0: #endif
sl@0: 
sl@0: #if !defined(__SYMBIAN32__WSD__)
sl@0: static ios_base::Init _IosInit;
sl@0: #endif
sl@0: 
sl@0: void _Locale_impl::make_classic_locale() {
sl@0:   // This funcion will be called once: during build classic _Locale_impl
sl@0: 
sl@0:   // The classic locale contains every facet that belongs to a category.
sl@0:   static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf;
sl@0:   _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C");
sl@0: 
sl@0:   locale::facet* classic_facets[] = {
sl@0:     0,
sl@0:     new collate<char>(1),
sl@0:     new ctype<char>(0, false, 1),
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0:     new codecvt<char, char, mbstate_t>(1),
sl@0: #else
sl@0:     0,
sl@0: #endif
sl@0:     new moneypunct<char, true>(1),
sl@0:     new moneypunct<char, false>(1),
sl@0:     new numpunct<char>(1),
sl@0:     new messages<char>(new _STLP_PRIV _Messages()),
sl@0:     new money_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
sl@0:     0,
sl@0:     new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
sl@0:     0,
sl@0:     new num_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
sl@0:     0,
sl@0:     new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
sl@0:     0,
sl@0:     new time_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
sl@0:     0,
sl@0:     new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
sl@0:     0,
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0:     new collate<wchar_t>(1),
sl@0:     new ctype<wchar_t>(1),
sl@0: 
sl@0: #  ifndef _STLP_NO_MBSTATE_T
sl@0:     new codecvt<wchar_t, char, mbstate_t>(1),
sl@0: #  else
sl@0:     0,
sl@0: #  endif
sl@0:     new moneypunct<wchar_t, true>(1),
sl@0:     new moneypunct<wchar_t, false>(1),
sl@0:     new numpunct<wchar_t>(1),
sl@0:     new messages<wchar_t>(new _STLP_PRIV _Messages()),
sl@0: 
sl@0:     new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0:     0,
sl@0:     new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0:     0,
sl@0: 
sl@0:     new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0:     0,
sl@0:     new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0:     0,
sl@0:     new time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0:     0,
sl@0:     new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0:     0,
sl@0: #endif
sl@0:     0
sl@0:   };
sl@0: 
sl@0:   const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *);
sl@0:   classic->facets_vec.reserve(nb_classic_facets);
sl@0:   classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets);
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__)
sl@0:   ::set_Stl_classic_locale(new (WSDAlloc(sizeof(locale))) locale(classic));
sl@0:   ::set_Stl_global_locale (new (WSDAlloc(sizeof(locale))) locale(_copy_Locale_impl(classic)));
sl@0: #else
sl@0:   static locale _Locale_classic(classic);
sl@0:   _Stl_classic_locale = &_Locale_classic;
sl@0: 
sl@0:   static locale _Locale_global(_copy_Locale_impl(classic));
sl@0:   _Stl_global_locale = &_Locale_global;
sl@0: #endif  
sl@0: }
sl@0: 
sl@0: #if defined (__BORLANDC__) && (__BORLANDC__ < 0x564)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0: /* 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_get<char, const char*>::id;
sl@0: */
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_put<char, char*>::id;
sl@0: */
sl@0: 
sl@0: #  if !defined (_STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_get<wchar_t, const wchar_t*>::id;
sl@0: */
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id time_put<wchar_t, wchar_t*>::id;
sl@0: */
sl@0: #  endif /* _STLP_NO_WCHAR_T */
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_get<char, const char*>::id;
sl@0: */
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_put<char, char*>::id;
sl@0: */
sl@0: 
sl@0: #  if !defined (_STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id;
sl@0: */
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id;
sl@0: */
sl@0: #  endif
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_get<char, const char*>::id;
sl@0: */
sl@0: 
sl@0: #  if !defined (STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id;
sl@0: */
sl@0: #  endif
sl@0: 
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_put<char, char*>::id;
sl@0: */
sl@0: 
sl@0: #  if !defined (_STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: /*
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id;
sl@0: */
sl@0: #  endif
sl@0: #endif
sl@0: 
sl@0: // Declarations of (non-template) facets' static data members
sl@0: # if defined(__SYMBIAN32__WSD__)
sl@0:   /* no definitions */
sl@0: #elif defined (__EPOC32__)
sl@0: 
sl@0: locale::id collate<char>::id = { 1 };
sl@0: locale::id ctype<char>::id = { 2 };
sl@0: 
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0: locale::id codecvt<char, char, mbstate_t>::id = { 3 };
sl@0: #  ifndef _STLP_NO_WCHAR_T
sl@0: locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 };
sl@0: #  endif
sl@0: #endif
sl@0: 
sl@0: locale::id moneypunct<char, true>::id = { 4 };
sl@0: locale::id moneypunct<char, false>::id = { 5 };
sl@0: locale::id numpunct<char>::id = { 6 } ;
sl@0: locale::id messages<char>::id = { 7 };
sl@0: 
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0: locale::id collate<wchar_t>::id = { 20 };
sl@0: locale::id ctype<wchar_t>::id = { 21 };
sl@0: 
sl@0: locale::id moneypunct<wchar_t, true>::id = { 23 } ;
sl@0: locale::id moneypunct<wchar_t, false>::id = { 24 } ;
sl@0: 
sl@0: locale::id numpunct<wchar_t>::id = { 25 };
sl@0: locale::id messages<wchar_t>::id = { 26 };
sl@0: #endif
sl@0: 
sl@0: #if defined(__SYMBIAN32__NO_STATIC_IMPORTS__)
sl@0: //ACCESS FUNCTIONS
sl@0: _STLP_DECLSPEC locale::id& collate<char>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return collate<char>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& ctype<char>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return ctype<char>::id;
sl@0: 	}
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0: _STLP_DECLSPEC locale::id& codecvt<char, char, mbstate_t>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return codecvt<char, char, mbstate_t>::id;
sl@0: 	}
sl@0: #  ifndef _STLP_NO_WCHAR_T
sl@0: _STLP_DECLSPEC locale::id& codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return codecvt<wchar_t, char, mbstate_t>::id;
sl@0: 	}
sl@0: #  endif
sl@0: #endif
sl@0: 
sl@0: _STLP_DECLSPEC locale::id& moneypunct<char, true>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return moneypunct<char, true>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& moneypunct<char, false>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return moneypunct<char, false>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& numpunct<char>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return numpunct<char>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& messages<char>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return messages<char>::id;
sl@0: 	}
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0: _STLP_DECLSPEC locale::id& collate<wchar_t>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return collate<wchar_t>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& ctype<wchar_t>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return ctype<wchar_t>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& moneypunct<wchar_t, true>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return moneypunct<wchar_t, true>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& moneypunct<wchar_t, false>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return moneypunct<wchar_t, false>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& numpunct<wchar_t>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return numpunct<wchar_t>::id;
sl@0: 	}
sl@0: _STLP_DECLSPEC locale::id& messages<wchar_t>::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return messages<wchar_t>::id;
sl@0: 	}
sl@0: #endif	
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return money_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0:     }
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0:     }
sl@0: # if !defined (_STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: 	}
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: 	}
sl@0: # endif
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return num_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0:     }
sl@0: # if !defined (STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0:     }
sl@0: # endif
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0:     }
sl@0: # if !defined (_STLP_NO_WCHAR_T)
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id& num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0:     }
sl@0: # endif
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id&
sl@0: time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0:     {
sl@0: 	return time_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0:     }
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id&
sl@0: time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0: 	}
sl@0: # ifndef _STLP_NO_WCHAR_T
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id&
sl@0: time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: 	}
sl@0: template <>
sl@0: _STLP_DECLSPEC locale::id&
sl@0: time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0: 	{
sl@0: 	return time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0: 	}
sl@0: # endif
sl@0: 
sl@0: # endif // __SYMBIAN32__NO_STATIC_IMPORTS__
sl@0: 
sl@0: 
sl@0: #else  // original STLPort 
sl@0: 
sl@0: // size_t locale::id::_S_max = 39; // made before
sl@0: 
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id collate<char>::id = { 1 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id ctype<char>::id = { 2 };
sl@0: 
sl@0: #ifndef _STLP_NO_MBSTATE_T
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt<char, char, mbstate_t>::id = { 3 };
sl@0: #  ifndef _STLP_NO_WCHAR_T
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 };
sl@0: #  endif
sl@0: #endif
sl@0: 
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<char, true>::id = { 4 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<char, false>::id = { 5 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct<char>::id = { 6 } ;
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id messages<char>::id = { 7 };
sl@0: 
sl@0: #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564)
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 8 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 10 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 12 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 14 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 16 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 18 };
sl@0: /*
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<char, const char*>::id = { 9 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<char, char*>::id = { 11 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<char, const char*>::id = { 13 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<char, char*>::id = { 15 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<char, const char*>::id = { 17 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<char, char*>::id = { 19 };
sl@0: */
sl@0: #endif
sl@0: 
sl@0: #ifndef _STLP_NO_WCHAR_T
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id collate<wchar_t>::id = { 20 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id ctype<wchar_t>::id = { 21 };
sl@0: 
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<wchar_t, true>::id = { 23 } ;
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<wchar_t, false>::id = { 24 } ;
sl@0: 
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct<wchar_t>::id = { 25 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id messages<wchar_t>::id = { 26 };
sl@0: 
sl@0: #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564)
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 27 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 29 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 31 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id = { 33 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 35 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 37 };
sl@0: /*
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id = { 28 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id = { 30 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id = { 32 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id = { 34 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<wchar_t, const wchar_t*>::id = { 36 };
sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<wchar_t, wchar_t*>::id = { 38 };
sl@0: */
sl@0: #  endif
sl@0: #endif
sl@0: # endif //!__SYMBIAN32__WSD__
sl@0: 
sl@0: _STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc)
sl@0: {
sl@0:   _STLP_ASSERT( loc != 0 );
sl@0:   loc->_M_incr();
sl@0:   return loc;
sl@0: }
sl@0: 
sl@0: void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc)
sl@0: {
sl@0:   _STLP_ASSERT( loc != 0 );
sl@0:   if (loc->_M_decr() == 0) {
sl@0:     if (*loc != *_Stl_classic_locale)
sl@0:       delete loc;
sl@0:     else
sl@0:       loc->~_Locale_impl();
sl@0:     loc = 0;
sl@0:   }
sl@0: }
sl@0: 
sl@0: _STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc)
sl@0: {
sl@0:   _STLP_ASSERT( loc != 0 );
sl@0:   loc->_M_incr();
sl@0:   _Locale_impl *loc_new = new _Locale_impl(*loc);
sl@0:   loc->_M_decr();
sl@0:   loc_new->name = _Nameless;
sl@0:   return loc_new;
sl@0: }
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__) 
sl@0: #undef id 
sl@0: #endif
sl@0: 
sl@0: _STLP_END_NAMESPACE
sl@0: 
sl@0: #if defined(__SYMBIAN32__WSD__)
sl@0: void locale_impl_init()
sl@0: {
sl@0: 	//initialize _S_max
sl@0: 	std::locale::id::get_locale_id_S_max() = 39;
sl@0: 
sl@0: 	//initialize the mutex lock in locale.cpp
sl@0: 	locale_index_lock_init();
sl@0: 
sl@0: 	//initialize _S_count of Init
sl@0: 	std::ios_base::Init::ios_base_Init_S_count_init();
sl@0: 
sl@0: 	//initialize S_was_synced of ios_base
sl@0: 	std::ios_base::ios_base_S_was_synced_init();
sl@0: 
sl@0: 	//initialize the mutex in locale_catalog.cpp
sl@0: 	stlp_priv::locale_catalog_category_hash_lock_init();
sl@0: 	
sl@0: 	//initialize category map in locale_catalog.cpp
sl@0: 	stlp_priv::Category_Map_Init();
sl@0: 	
sl@0: 	//initialize empty string in monetary.cpp
sl@0: 	monetary_empty_string_init();
sl@0: }
sl@0: # endif //__SYMBIAN32__WSD__
sl@0: 
sl@0: 
sl@0: // locale use many static functions/pointers from this file:
sl@0: // to avoid making ones extern, simple #include implementation of locale
sl@0: 
sl@0: #include "locale.cpp"
sl@0: