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 sl@0: #include sl@0: #include sl@0: #include 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& get_Loc_init_buf() sl@0: { sl@0: return *(std::_Stl_aligned_buffer *)(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* ct) sl@0: { return _Locale_get_ctype_hint(ct->_M_ctype); } sl@0: _Locale_name_hint* _Locale_extract_hint(numpunct_byname* punct) sl@0: { return _Locale_get_numeric_hint(punct->_M_numeric); } sl@0: # if defined (__GNUC__) && (__GNUC__ < 3) sl@0: template 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 > >* tget) sl@0: # endif sl@0: { return _Locale_get_time_hint(tget->_M_time); } sl@0: _Locale_name_hint* _Locale_extract_hint(collate_byname* coll) sl@0: { return _Locale_get_collate_hint(coll->_M_collate); } sl@0: _Locale_name_hint* _Locale_extract_hint(moneypunct_byname* money) sl@0: { return _Locale_get_monetary_hint(money->_M_monetary); } sl@0: #endif sl@0: sl@0: // sl@0: // 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 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::id); sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: this->insert(i2, codecvt::id); sl@0: #endif sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: this->insert(i2, ctype::id); sl@0: # ifndef _STLP_NO_MBSTATE_T sl@0: this->insert(i2, codecvt::id); sl@0: # endif sl@0: #endif sl@0: } else { sl@0: ctype* ct = 0; sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: codecvt* cvt = 0; sl@0: #endif sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: ctype* wct = 0; sl@0: codecvt* wcvt = 0; sl@0: #endif sl@0: _STLP_TRY { sl@0: ctype_byname *ctbn = new ctype_byname(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(pname); sl@0: #endif sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: wct = new ctype_byname(pname, 0, hint); sl@0: wcvt = new codecvt_byname(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* punct = 0; sl@0: num_get > > *get = 0; sl@0: num_put > > *put = 0; sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: numpunct* wpunct = 0; sl@0: num_get > > *wget = 0; sl@0: num_put > > *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::id); sl@0: this->insert(i2, sl@0: num_put > >::id); sl@0: this->insert(i2, sl@0: num_get > >::id); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: this->insert(i2, numpunct::id); sl@0: this->insert(i2, sl@0: num_get > >::id); sl@0: this->insert(i2, sl@0: num_put > >::id); sl@0: #endif sl@0: } sl@0: else { sl@0: _STLP_TRY { sl@0: numpunct_byname *punctbn = new numpunct_byname(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 > >; sl@0: put = new num_put > >; sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: wpunct = new numpunct_byname(pname, 0, hint); sl@0: wget = new num_get > >; sl@0: wput = new num_put > >; 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 > > *get = 0; sl@0: time_put > > *put = 0; sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: time_get > > *wget = 0; sl@0: time_put > > *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 > >::id); sl@0: this->insert(i2, sl@0: time_put > >::id); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: this->insert(i2, sl@0: time_get > >::id); sl@0: this->insert(i2, sl@0: time_put > >::id); sl@0: #endif sl@0: } else { sl@0: _STLP_TRY { sl@0: time_get_byname > > *getbn = sl@0: new time_get_byname > >(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 > >(pname, 0, hint); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: wget = new time_get_byname > >(pname, 0, hint); sl@0: wput = new time_put_byname > >(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 *col = 0; sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: collate *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::id); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: this->insert(i2, collate::id); sl@0: #endif sl@0: } sl@0: else { sl@0: _STLP_TRY { sl@0: collate_byname *colbn = new collate_byname(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(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 *punct = 0; sl@0: moneypunct *ipunct = 0; sl@0: money_get > > *get = 0; sl@0: money_put > > *put = 0; sl@0: sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: moneypunct* wpunct = 0; sl@0: moneypunct* wipunct = 0; sl@0: money_get > > *wget = 0; sl@0: money_put > > *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::id); sl@0: this->insert(i2, moneypunct::id); sl@0: this->insert(i2, money_get > >::id); sl@0: this->insert(i2, money_put > >::id); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: this->insert(i2, moneypunct::id); sl@0: this->insert(i2, moneypunct::id); sl@0: this->insert(i2, money_get > >::id); sl@0: this->insert(i2, money_put > >::id); sl@0: #endif sl@0: } sl@0: else { sl@0: _STLP_TRY { sl@0: moneypunct_byname* punctbn = new moneypunct_byname(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(pname, 0, hint); sl@0: get = new money_get > >; sl@0: put = new money_put > >; sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: wpunct = new moneypunct_byname(pname, 0, hint); sl@0: wipunct = new moneypunct_byname(pname, 0, hint); sl@0: wget = new money_get > >; sl@0: wput = new money_put > >; 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 *msg = 0; sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: messages *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::id); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: this->insert(i2, messages::id); sl@0: #endif sl@0: } sl@0: else { sl@0: _STLP_TRY { sl@0: msg = new messages_byname(pname, 0, hint); sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: wmsg = new messages_byname(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::id._M_index = 1; sl@0: ctype::id._M_index = 2; sl@0: sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: codecvt::id._M_index = 3; sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: codecvt::id._M_index = 22; sl@0: # endif sl@0: #endif sl@0: moneypunct::id._M_index = 4; sl@0: moneypunct::id._M_index = 5; sl@0: numpunct::id._M_index = 6; sl@0: messages::id._M_index =7; sl@0: sl@0: collate::id._M_index = 20; sl@0: ctype::id._M_index = 21; sl@0: moneypunct::id._M_index = 23; sl@0: moneypunct::id._M_index = 24; sl@0: numpunct::id._M_index = 25; sl@0: messages::id._M_index = 26; sl@0: #endif sl@0: sl@0: sl@0: money_get > >::id._M_index = 8; sl@0: //money_get::id._M_index = 9; sl@0: money_put > >::id._M_index = 10; sl@0: //money_put::id._M_index = 11; sl@0: sl@0: num_get > >::id._M_index = 12; sl@0: //num_get::id._M_index = 13; sl@0: num_put > >::id._M_index = 14; sl@0: //num_put::id._M_index = 15; sl@0: time_get > >::id._M_index = 16; sl@0: //time_get::id._M_index = 17; sl@0: time_put > >::id._M_index = 18; sl@0: //time_put::id._M_index = 19; sl@0: sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: money_get > >::id._M_index = 27; sl@0: //money_get::id._M_index = 28; sl@0: money_put > >::id._M_index = 29; sl@0: //money_put::id._M_index = 30; sl@0: sl@0: num_get > >::id._M_index = 31; sl@0: //num_get::id._M_index = 32; sl@0: num_put > > ::id._M_index = 33; sl@0: //num_put::id._M_index = 34; sl@0: time_get > >::id._M_index = 35; sl@0: //time_get::id._M_index = 36; sl@0: time_put > >::id._M_index = 37; sl@0: //time_put::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(1), sl@0: new ctype(0, false, 1), sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: new codecvt(1), sl@0: #else sl@0: 0, sl@0: #endif sl@0: new moneypunct(1), sl@0: new moneypunct(1), sl@0: new numpunct(1), sl@0: new messages(new _STLP_PRIV _Messages()), sl@0: new money_get > >(1), sl@0: 0, sl@0: new money_put > >(1), sl@0: 0, sl@0: new num_get > >(1), sl@0: 0, sl@0: new num_put > >(1), sl@0: 0, sl@0: new time_get > >(1), sl@0: 0, sl@0: new time_put > >(1), sl@0: 0, sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: new collate(1), sl@0: new ctype(1), sl@0: sl@0: # ifndef _STLP_NO_MBSTATE_T sl@0: new codecvt(1), sl@0: # else sl@0: 0, sl@0: # endif sl@0: new moneypunct(1), sl@0: new moneypunct(1), sl@0: new numpunct(1), sl@0: new messages(new _STLP_PRIV _Messages()), sl@0: sl@0: new money_get > >(1), sl@0: 0, sl@0: new money_put > >(1), sl@0: 0, sl@0: sl@0: new num_get > >(1), sl@0: 0, sl@0: new num_put > >(1), sl@0: 0, sl@0: new time_get > >(1), sl@0: 0, sl@0: new time_put > >(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 > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_get::id; sl@0: */ sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_put > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_put::id; sl@0: */ sl@0: sl@0: # if !defined (_STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_get > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_get::id; sl@0: */ sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_put > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id time_put::id; sl@0: */ sl@0: # endif /* _STLP_NO_WCHAR_T */ sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_get > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_get::id; sl@0: */ sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_put > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_put::id; sl@0: */ sl@0: sl@0: # if !defined (_STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_get > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_get::id; sl@0: */ sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_put > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id money_put::id; sl@0: */ sl@0: # endif sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_get > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_get::id; sl@0: */ sl@0: sl@0: # if !defined (STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_get > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_get::id; sl@0: */ sl@0: # endif sl@0: sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_put > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_put::id; sl@0: */ sl@0: sl@0: # if !defined (_STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_put > >::id; sl@0: /* sl@0: template <> sl@0: _STLP_DECLSPEC locale::id num_put::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::id = { 1 }; sl@0: locale::id ctype::id = { 2 }; sl@0: sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: locale::id codecvt::id = { 3 }; sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: locale::id codecvt::id = { 22 }; sl@0: # endif sl@0: #endif sl@0: sl@0: locale::id moneypunct::id = { 4 }; sl@0: locale::id moneypunct::id = { 5 }; sl@0: locale::id numpunct::id = { 6 } ; sl@0: locale::id messages::id = { 7 }; sl@0: sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: locale::id collate::id = { 20 }; sl@0: locale::id ctype::id = { 21 }; sl@0: sl@0: locale::id moneypunct::id = { 23 } ; sl@0: locale::id moneypunct::id = { 24 } ; sl@0: sl@0: locale::id numpunct::id = { 25 }; sl@0: locale::id messages::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::GetFacetLocaleId() sl@0: { sl@0: return collate::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& ctype::GetFacetLocaleId() sl@0: { sl@0: return ctype::id; sl@0: } sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: _STLP_DECLSPEC locale::id& codecvt::GetFacetLocaleId() sl@0: { sl@0: return codecvt::id; sl@0: } sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: _STLP_DECLSPEC locale::id& codecvt::GetFacetLocaleId() sl@0: { sl@0: return codecvt::id; sl@0: } sl@0: # endif sl@0: #endif sl@0: sl@0: _STLP_DECLSPEC locale::id& moneypunct::GetFacetLocaleId() sl@0: { sl@0: return moneypunct::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& moneypunct::GetFacetLocaleId() sl@0: { sl@0: return moneypunct::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& numpunct::GetFacetLocaleId() sl@0: { sl@0: return numpunct::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& messages::GetFacetLocaleId() sl@0: { sl@0: return messages::id; sl@0: } sl@0: #ifndef _STLP_NO_WCHAR_T sl@0: _STLP_DECLSPEC locale::id& collate::GetFacetLocaleId() sl@0: { sl@0: return collate::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& ctype::GetFacetLocaleId() sl@0: { sl@0: return ctype::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& moneypunct::GetFacetLocaleId() sl@0: { sl@0: return moneypunct::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& moneypunct::GetFacetLocaleId() sl@0: { sl@0: return moneypunct::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& numpunct::GetFacetLocaleId() sl@0: { sl@0: return numpunct::id; sl@0: } sl@0: _STLP_DECLSPEC locale::id& messages::GetFacetLocaleId() sl@0: { sl@0: return messages::id; sl@0: } sl@0: #endif sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& money_get > >::GetFacetLocaleId() sl@0: { sl@0: return money_get > >::id; sl@0: } sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& money_put > >::GetFacetLocaleId() sl@0: { sl@0: return money_put > >::id; sl@0: } sl@0: # if !defined (_STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& money_get > >::GetFacetLocaleId() sl@0: { sl@0: return money_get > >::id; sl@0: } sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& money_put > >::GetFacetLocaleId() sl@0: { sl@0: return money_put > >::id; sl@0: } sl@0: # endif sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& num_get > >::GetFacetLocaleId() sl@0: { sl@0: return num_get > >::id; sl@0: } sl@0: # if !defined (STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& num_get > >::GetFacetLocaleId() sl@0: { sl@0: return num_get > >::id; sl@0: } sl@0: # endif sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& num_put > >::GetFacetLocaleId() sl@0: { sl@0: return num_put > >::id; sl@0: } sl@0: # if !defined (_STLP_NO_WCHAR_T) sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& num_put > >::GetFacetLocaleId() sl@0: { sl@0: return num_put > >::id; sl@0: } sl@0: # endif sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& sl@0: time_get > >::GetFacetLocaleId() sl@0: { sl@0: return time_get > >::id; sl@0: } sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& sl@0: time_put > >::GetFacetLocaleId() sl@0: { sl@0: return time_put > >::id; sl@0: } sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& sl@0: time_get > >::GetFacetLocaleId() sl@0: { sl@0: return time_get > >::id; sl@0: } sl@0: template <> sl@0: _STLP_DECLSPEC locale::id& sl@0: time_put > >::GetFacetLocaleId() sl@0: { sl@0: return time_put > >::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::id = { 1 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id ctype::id = { 2 }; sl@0: sl@0: #ifndef _STLP_NO_MBSTATE_T sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt::id = { 3 }; sl@0: # ifndef _STLP_NO_WCHAR_T sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt::id = { 22 }; sl@0: # endif sl@0: #endif sl@0: sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct::id = { 4 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct::id = { 5 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct::id = { 6 } ; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id messages::id = { 7 }; sl@0: sl@0: #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564) sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get > >::id = { 8 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put > >::id = { 10 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get > >::id = { 12 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put > >::id = { 14 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get > >::id = { 16 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put > >::id = { 18 }; sl@0: /* sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get::id = { 9 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put::id = { 11 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get::id = { 13 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put::id = { 15 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get::id = { 17 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put::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::id = { 20 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id ctype::id = { 21 }; sl@0: sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct::id = { 23 } ; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct::id = { 24 } ; sl@0: sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct::id = { 25 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id messages::id = { 26 }; sl@0: sl@0: #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564) sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get > >::id = { 27 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put > >::id = { 29 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get > >::id = { 31 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put > > ::id = { 33 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get > >::id = { 35 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put > >::id = { 37 }; sl@0: /* sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_get::id = { 28 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id money_put::id = { 30 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_get::id = { 32 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id num_put::id = { 34 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_get::id = { 36 }; sl@0: _STLP_STATIC_MEMBER_DECLSPEC locale::id time_put::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: