os/ossrv/genericopenlibs/cppstdlib/stl/src/locale_impl.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
 * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0
     3
 *
sl@0
     4
 * Copyright (c) 1999
sl@0
     5
 * Silicon Graphics Computer Systems, Inc.
sl@0
     6
 *
sl@0
     7
 * Copyright (c) 1999
sl@0
     8
 * Boris Fomitchev
sl@0
     9
 *
sl@0
    10
 * This material is provided "as is", with absolutely no warranty expressed
sl@0
    11
 * or implied. Any use is at your own risk.
sl@0
    12
 *
sl@0
    13
 * Permission to use or copy this software for any purpose is hereby granted
sl@0
    14
 * without fee, provided the above notices are retained on all copies.
sl@0
    15
 * Permission to modify the code and to distribute modified code is granted,
sl@0
    16
 * provided the above notices are retained, and a notice that the code was
sl@0
    17
 * modified is included with the above copyright notice.
sl@0
    18
 *
sl@0
    19
 */
sl@0
    20
#include "stlport_prefix.h"
sl@0
    21
sl@0
    22
#include <locale>
sl@0
    23
#include <typeinfo>
sl@0
    24
#include <algorithm>
sl@0
    25
#include <stdexcept>
sl@0
    26
sl@0
    27
#include "c_locale.h"
sl@0
    28
#include "aligned_buffer.h"
sl@0
    29
#include "locale_impl.h"
sl@0
    30
#include "message_facets.h"
sl@0
    31
sl@0
    32
#if defined(__SYMBIAN32__WSD__)
sl@0
    33
#include "libstdcppwsd.h"
sl@0
    34
sl@0
    35
std::_Stl_aligned_buffer<std::_Locale_impl::Init>& get_Loc_init_buf()
sl@0
    36
    {
sl@0
    37
    return *(std::_Stl_aligned_buffer<std::_Locale_impl::Init> *)(get_libcpp_wsd().__Loc_init_buf);
sl@0
    38
    }
sl@0
    39
sl@0
    40
#define __Loc_init_buf		get_Loc_init_buf()
sl@0
    41
#define _S_count 			get_Loc_init_S_count()
sl@0
    42
#define _Index_lock			get_locale_Index_lock()
sl@0
    43
#define _S_index			get_S_index()
sl@0
    44
#define _S_max				get_locale_id_S_max()
sl@0
    45
#define _Stl_classic_locale get_Stl_classic_locale()
sl@0
    46
#define _Stl_global_locale  get_Stl_global_locale()
sl@0
    47
sl@0
    48
#endif  //__SYMBIAN32__WSD__
sl@0
    49
sl@0
    50
_STLP_BEGIN_NAMESPACE
sl@0
    51
sl@0
    52
#if defined(__SYMBIAN32__WSD__) && defined(_STLP_DEBUG)
sl@0
    53
#define _Nameless *get_Nameless()
sl@0
    54
#else
sl@0
    55
static const string _Nameless("*");
sl@0
    56
#endif
sl@0
    57
sl@0
    58
static inline bool is_C_locale_name (const char* name)
sl@0
    59
{ return ((name[0] == 'C') && (name[1] == 0)); }
sl@0
    60
sl@0
    61
_Locale_impl * _STLP_CALL _copy_Locale_impl(_Locale_impl *loc)
sl@0
    62
{
sl@0
    63
  _STLP_ASSERT( loc != 0 );
sl@0
    64
  loc->_M_incr();
sl@0
    65
  _Locale_impl *loc_new = new _Locale_impl(*loc);
sl@0
    66
  loc->_M_decr();
sl@0
    67
  return loc_new;
sl@0
    68
}
sl@0
    69
sl@0
    70
locale::facet * _STLP_CALL _get_facet(locale::facet *f)
sl@0
    71
{
sl@0
    72
  if (f != 0)
sl@0
    73
    f->_M_incr();
sl@0
    74
  return f;
sl@0
    75
}
sl@0
    76
sl@0
    77
void _STLP_CALL _release_facet(locale::facet *&f)
sl@0
    78
{
sl@0
    79
  if ((f != 0) && (f->_M_decr() == 0)) {
sl@0
    80
    delete f;
sl@0
    81
    f = 0;
sl@0
    82
  }
sl@0
    83
}
sl@0
    84
# if !defined(__SYMBIAN32__WSD__)
sl@0
    85
# if !defined(__SYMBIAN32__NO_STATIC_IMPORTS__)
sl@0
    86
_STLP_STATIC_MEMBER_DECLSPEC size_t locale::id::_S_max = 39;
sl@0
    87
#else
sl@0
    88
size_t locale::id::_S_max = 39;
sl@0
    89
#endif
sl@0
    90
# endif //__SYMBIAN32__WSD__
sl@0
    91
sl@0
    92
static void _Stl_loc_assign_ids();
sl@0
    93
sl@0
    94
#if !defined(__SYMBIAN32__WSD__)
sl@0
    95
static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf;
sl@0
    96
#endif
sl@0
    97
sl@0
    98
_Locale_impl::Init::Init() {
sl@0
    99
  if (_M_count()._M_incr() == 1) {
sl@0
   100
    _Locale_impl::_S_initialize();
sl@0
   101
  }
sl@0
   102
}
sl@0
   103
sl@0
   104
_Locale_impl::Init::~Init() {
sl@0
   105
  if (_M_count()._M_decr() == 0) {
sl@0
   106
    _Locale_impl::_S_uninitialize();
sl@0
   107
  }
sl@0
   108
}
sl@0
   109
sl@0
   110
_Refcount_Base& _Locale_impl::Init::_M_count() const {
sl@0
   111
#if !defined(__SYMBIAN32__WSD__)	
sl@0
   112
  static _Refcount_Base _S_count(0);
sl@0
   113
#endif
sl@0
   114
  return _S_count;
sl@0
   115
}
sl@0
   116
sl@0
   117
_Locale_impl::_Locale_impl(const char* s)
sl@0
   118
  : _Refcount_Base(0), name(s), facets_vec() {
sl@0
   119
  facets_vec.reserve( locale::id::_S_max );
sl@0
   120
  new (&__Loc_init_buf) Init();
sl@0
   121
}
sl@0
   122
sl@0
   123
_Locale_impl::_Locale_impl( _Locale_impl const& locimpl )
sl@0
   124
  : _Refcount_Base(0), name(locimpl.name), facets_vec() {
sl@0
   125
  for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet);
sl@0
   126
  facets_vec = locimpl.facets_vec;
sl@0
   127
  new (&__Loc_init_buf) Init();
sl@0
   128
}
sl@0
   129
sl@0
   130
_Locale_impl::_Locale_impl( size_t n, const char* s)
sl@0
   131
  : _Refcount_Base(0), name(s), facets_vec(n, 0) {
sl@0
   132
  new (&__Loc_init_buf) Init();
sl@0
   133
}
sl@0
   134
sl@0
   135
_Locale_impl::~_Locale_impl() {
sl@0
   136
  (&__Loc_init_buf)->~Init();
sl@0
   137
  for_each( facets_vec.begin(), facets_vec.end(), _release_facet);
sl@0
   138
}
sl@0
   139
sl@0
   140
// Initialization of the locale system.  This must be called before
sl@0
   141
// any locales are constructed.  (Meaning that it must be called when
sl@0
   142
// the I/O library itself is initialized.)
sl@0
   143
void _STLP_CALL _Locale_impl::_S_initialize() {
sl@0
   144
sl@0
   145
#if defined(__SYMBIAN32__WSD__)
sl@0
   146
  //initialize wsd obj pointer
sl@0
   147
  locale_impl_init();
sl@0
   148
# endif
sl@0
   149
sl@0
   150
  _Stl_loc_assign_ids();
sl@0
   151
  make_classic_locale();
sl@0
   152
sl@0
   153
#if defined(__SYMBIAN32__WSD__)   
sl@0
   154
  global_iostream_init();
sl@0
   155
# endif
sl@0
   156
}
sl@0
   157
sl@0
   158
// Release of the classic locale ressources. Has to be called after the last
sl@0
   159
// locale destruction and not only after the classic locale destruction as
sl@0
   160
// the facets can be shared between different facets.
sl@0
   161
void _STLP_CALL _Locale_impl::_S_uninitialize() {
sl@0
   162
  //Not necessary anymore as classic facets are now 'normal' dynamically allocated
sl@0
   163
  //facets with a reference counter telling to _release_facet when the facet can be
sl@0
   164
  //deleted.
sl@0
   165
  //free_classic_locale();
sl@0
   166
}
sl@0
   167
sl@0
   168
// _Locale_impl non-inline member functions.
sl@0
   169
void _STLP_CALL _Locale_impl::_M_throw_bad_cast() {
sl@0
   170
  _STLP_THROW(bad_cast());
sl@0
   171
}
sl@0
   172
sl@0
   173
void _Locale_impl::insert( _Locale_impl *from, const locale::id& n ) {
sl@0
   174
  size_t index = n._M_index;
sl@0
   175
  if (index > 0 && index < from->size()) {
sl@0
   176
    this->insert( from->facets_vec[index], index);
sl@0
   177
  }
sl@0
   178
}
sl@0
   179
sl@0
   180
locale::facet* _Locale_impl::insert(locale::facet *f, size_t index) {
sl@0
   181
  if (f == 0 || index == 0)
sl@0
   182
    return 0;
sl@0
   183
sl@0
   184
  if (index >= facets_vec.size()) {
sl@0
   185
    facets_vec.resize(index + 1);
sl@0
   186
  }
sl@0
   187
sl@0
   188
  if (f != facets_vec[index])
sl@0
   189
  {
sl@0
   190
    _release_facet(facets_vec[index]);
sl@0
   191
    facets_vec[index] = _get_facet(f);
sl@0
   192
  }
sl@0
   193
sl@0
   194
  return f;
sl@0
   195
}
sl@0
   196
sl@0
   197
#if !defined (__DMC__)
sl@0
   198
_Locale_name_hint* _Locale_extract_hint(ctype_byname<char>* ct)
sl@0
   199
{ return _Locale_get_ctype_hint(ct->_M_ctype); }
sl@0
   200
_Locale_name_hint* _Locale_extract_hint(numpunct_byname<char>* punct)
sl@0
   201
{ return _Locale_get_numeric_hint(punct->_M_numeric); }
sl@0
   202
#  if defined (__GNUC__) && (__GNUC__ < 3)
sl@0
   203
template <class _Ch, class _InIt>
sl@0
   204
_Locale_name_hint* _Locale_time_extract_hint(time_get_byname<_Ch, _InIt>* tget)
sl@0
   205
#  else
sl@0
   206
_Locale_name_hint* _Locale_time_extract_hint(time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >* tget)
sl@0
   207
#  endif
sl@0
   208
{ return _Locale_get_time_hint(tget->_M_time); }
sl@0
   209
_Locale_name_hint* _Locale_extract_hint(collate_byname<char>* coll)
sl@0
   210
{ return _Locale_get_collate_hint(coll->_M_collate); }
sl@0
   211
_Locale_name_hint* _Locale_extract_hint(moneypunct_byname<char, false>* money)
sl@0
   212
{ return _Locale_get_monetary_hint(money->_M_monetary); }
sl@0
   213
#endif
sl@0
   214
sl@0
   215
//
sl@0
   216
// <locale> content which is dependent on the name
sl@0
   217
//
sl@0
   218
#if defined(__SYMBIAN32__WSD__) 
sl@0
   219
#define id					GetFacetLocaleId()
sl@0
   220
#endif
sl@0
   221
sl@0
   222
template <class Facet>
sl@0
   223
static inline locale::facet* _Locale_insert(_Locale_impl *__that, Facet* f)
sl@0
   224
{ return __that->insert(f, Facet::id._M_index); }
sl@0
   225
sl@0
   226
/*
sl@0
   227
 * Six functions, one for each category.  Each of them takes a
sl@0
   228
 * _Locale* and a name, constructs that appropriate category
sl@0
   229
 * facets by name, and inserts them into the locale.
sl@0
   230
 */
sl@0
   231
_Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* pname, _Locale_name_hint* hint) {
sl@0
   232
  char buf[_Locale_MAX_SIMPLE_NAME];
sl@0
   233
  _Locale_impl* i2 = locale::classic()._M_impl;
sl@0
   234
sl@0
   235
  if (pname == 0 || pname[0] == 0)
sl@0
   236
    pname = _Locale_ctype_default(buf);
sl@0
   237
sl@0
   238
  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0
   239
    this->insert(i2, ctype<char>::id);
sl@0
   240
#ifndef _STLP_NO_MBSTATE_T
sl@0
   241
    this->insert(i2, codecvt<char, char, mbstate_t>::id);
sl@0
   242
#endif
sl@0
   243
#ifndef _STLP_NO_WCHAR_T
sl@0
   244
    this->insert(i2, ctype<wchar_t>::id);
sl@0
   245
#  ifndef _STLP_NO_MBSTATE_T
sl@0
   246
    this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
sl@0
   247
#  endif
sl@0
   248
#endif
sl@0
   249
  } else {
sl@0
   250
    ctype<char>*    ct                      = 0;
sl@0
   251
#ifndef _STLP_NO_MBSTATE_T
sl@0
   252
    codecvt<char, char, mbstate_t>*    cvt  = 0;
sl@0
   253
#endif
sl@0
   254
#ifndef _STLP_NO_WCHAR_T
sl@0
   255
    ctype<wchar_t>* wct                     = 0;
sl@0
   256
    codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
sl@0
   257
#endif
sl@0
   258
    _STLP_TRY {
sl@0
   259
      ctype_byname<char> *ctbn = new ctype_byname<char>(pname, 0, hint);
sl@0
   260
      ct   = ctbn;
sl@0
   261
#if !defined (__DMC__)
sl@0
   262
      if (hint == 0) hint = _Locale_extract_hint(ctbn);
sl@0
   263
#endif
sl@0
   264
#ifndef _STLP_NO_MBSTATE_T
sl@0
   265
      cvt  = new codecvt_byname<char, char, mbstate_t>(pname);
sl@0
   266
#endif
sl@0
   267
#ifndef _STLP_NO_WCHAR_T
sl@0
   268
      wct  = new ctype_byname<wchar_t>(pname, 0, hint);
sl@0
   269
      wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname, 0, hint);
sl@0
   270
#endif
sl@0
   271
    }
sl@0
   272
sl@0
   273
#ifndef _STLP_NO_WCHAR_T
sl@0
   274
#  ifdef _STLP_NO_MBSTATE_T
sl@0
   275
    _STLP_UNWIND(delete ct; delete wct; delete wcvt);
sl@0
   276
#  else
sl@0
   277
    _STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
sl@0
   278
#  endif
sl@0
   279
#else
sl@0
   280
#  ifdef _STLP_NO_MBSTATE_T
sl@0
   281
    _STLP_UNWIND(delete ct);
sl@0
   282
#  else
sl@0
   283
    _STLP_UNWIND(delete ct; delete cvt);
sl@0
   284
#  endif
sl@0
   285
#endif
sl@0
   286
    _Locale_insert(this, ct);
sl@0
   287
#ifndef _STLP_NO_MBSTATE_T
sl@0
   288
    _Locale_insert(this, cvt);
sl@0
   289
#endif
sl@0
   290
#ifndef _STLP_NO_WCHAR_T
sl@0
   291
    _Locale_insert(this, wct);
sl@0
   292
    _Locale_insert(this, wcvt);
sl@0
   293
#endif
sl@0
   294
  }
sl@0
   295
  return hint;
sl@0
   296
}
sl@0
   297
sl@0
   298
_Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* pname, _Locale_name_hint* hint) {
sl@0
   299
  _Locale_impl* i2 = locale::classic()._M_impl;
sl@0
   300
sl@0
   301
  numpunct<char>* punct = 0;
sl@0
   302
  num_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0;
sl@0
   303
  num_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0;
sl@0
   304
#ifndef _STLP_NO_WCHAR_T
sl@0
   305
  numpunct<wchar_t>* wpunct = 0;
sl@0
   306
  num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0;
sl@0
   307
  num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0;
sl@0
   308
#endif
sl@0
   309
sl@0
   310
  char buf[_Locale_MAX_SIMPLE_NAME];
sl@0
   311
  if (pname == 0 || pname[0] == 0)
sl@0
   312
    pname = _Locale_numeric_default(buf);
sl@0
   313
sl@0
   314
  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0
   315
    this->insert(i2, numpunct<char>::id);
sl@0
   316
    this->insert(i2,
sl@0
   317
                 num_put<char, ostreambuf_iterator<char, char_traits<char> >  >::id);
sl@0
   318
    this->insert(i2,
sl@0
   319
                 num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
sl@0
   320
#ifndef _STLP_NO_WCHAR_T
sl@0
   321
    this->insert(i2, numpunct<wchar_t>::id);
sl@0
   322
    this->insert(i2,
sl@0
   323
                 num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> >  >::id);
sl@0
   324
    this->insert(i2,
sl@0
   325
                 num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0
   326
#endif
sl@0
   327
  }
sl@0
   328
  else {
sl@0
   329
    _STLP_TRY {
sl@0
   330
      numpunct_byname<char> *punctbn = new numpunct_byname<char>(pname, 0, hint);
sl@0
   331
      punct  = punctbn;
sl@0
   332
#if !defined (__DMC__)
sl@0
   333
      if (hint == 0) hint = _Locale_extract_hint(punctbn);
sl@0
   334
#endif
sl@0
   335
      get    = new num_get<char, istreambuf_iterator<char, char_traits<char> > >;
sl@0
   336
      put    = new num_put<char, ostreambuf_iterator<char, char_traits<char> > >;
sl@0
   337
#ifndef _STLP_NO_WCHAR_T
sl@0
   338
      wpunct = new numpunct_byname<wchar_t>(pname, 0, hint);
sl@0
   339
      wget   = new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0
   340
      wput   = new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0
   341
#endif
sl@0
   342
    }
sl@0
   343
#ifndef _STLP_NO_WCHAR_T
sl@0
   344
    _STLP_UNWIND(delete punct; delete wpunct; delete get; delete wget; delete put; delete wput);
sl@0
   345
#else
sl@0
   346
    _STLP_UNWIND(delete punct; delete get;delete put);
sl@0
   347
#endif
sl@0
   348
sl@0
   349
    _Locale_insert(this,punct);
sl@0
   350
    _Locale_insert(this,get);
sl@0
   351
    _Locale_insert(this,put);
sl@0
   352
sl@0
   353
#ifndef _STLP_NO_WCHAR_T
sl@0
   354
    _Locale_insert(this,wpunct);
sl@0
   355
    _Locale_insert(this,wget);
sl@0
   356
    _Locale_insert(this,wput);
sl@0
   357
#endif
sl@0
   358
  }
sl@0
   359
  return hint;
sl@0
   360
}
sl@0
   361
sl@0
   362
_Locale_name_hint* _Locale_impl::insert_time_facets(const char* pname, _Locale_name_hint* hint) {
sl@0
   363
  _Locale_impl* i2 = locale::classic()._M_impl;
sl@0
   364
  time_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0;
sl@0
   365
  time_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0;
sl@0
   366
#ifndef _STLP_NO_WCHAR_T
sl@0
   367
  time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0;
sl@0
   368
  time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0;
sl@0
   369
#endif
sl@0
   370
sl@0
   371
  char buf[_Locale_MAX_SIMPLE_NAME];
sl@0
   372
  if (pname == 0 || pname[0] == 0)
sl@0
   373
    pname = _Locale_time_default(buf);
sl@0
   374
sl@0
   375
  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0
   376
sl@0
   377
    this->insert(i2,
sl@0
   378
                 time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
sl@0
   379
    this->insert(i2,
sl@0
   380
                 time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
sl@0
   381
#ifndef _STLP_NO_WCHAR_T
sl@0
   382
    this->insert(i2,
sl@0
   383
                 time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0
   384
    this->insert(i2,
sl@0
   385
                 time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0
   386
#endif
sl@0
   387
  } else {
sl@0
   388
    _STLP_TRY {
sl@0
   389
      time_get_byname<char, istreambuf_iterator<char, char_traits<char> > > *getbn =
sl@0
   390
        new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(pname, 0, hint);
sl@0
   391
      get  = getbn;
sl@0
   392
#if !defined (__DMC__)
sl@0
   393
      if (hint == 0) hint = _Locale_time_extract_hint(getbn);
sl@0
   394
#endif
sl@0
   395
      put  = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(pname, 0, hint);
sl@0
   396
#ifndef _STLP_NO_WCHAR_T
sl@0
   397
      wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname, 0, hint);
sl@0
   398
      wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(pname, 0, hint);
sl@0
   399
#endif
sl@0
   400
    }
sl@0
   401
#ifndef _STLP_NO_WCHAR_T
sl@0
   402
    _STLP_UNWIND(delete get; delete wget; delete put; delete wput);
sl@0
   403
#else
sl@0
   404
    _STLP_UNWIND(delete get; delete put);
sl@0
   405
#endif
sl@0
   406
    _Locale_insert(this,get);
sl@0
   407
    _Locale_insert(this,put);
sl@0
   408
#ifndef _STLP_NO_WCHAR_T
sl@0
   409
    _Locale_insert(this,wget);
sl@0
   410
    _Locale_insert(this,wput);
sl@0
   411
#endif
sl@0
   412
  }
sl@0
   413
  return hint;
sl@0
   414
}
sl@0
   415
sl@0
   416
_Locale_name_hint* _Locale_impl::insert_collate_facets(const char* nam, _Locale_name_hint* hint) {
sl@0
   417
  _Locale_impl* i2 = locale::classic()._M_impl;
sl@0
   418
sl@0
   419
  collate<char> *col = 0;
sl@0
   420
#ifndef _STLP_NO_WCHAR_T
sl@0
   421
  collate<wchar_t> *wcol = 0;
sl@0
   422
#endif
sl@0
   423
sl@0
   424
  char buf[_Locale_MAX_SIMPLE_NAME];
sl@0
   425
  if (nam == 0 || nam[0] == 0)
sl@0
   426
    nam = _Locale_collate_default(buf);
sl@0
   427
sl@0
   428
  if (nam == 0 || nam[0] == 0 || is_C_locale_name(nam)) {
sl@0
   429
    this->insert(i2, collate<char>::id);
sl@0
   430
#ifndef _STLP_NO_WCHAR_T
sl@0
   431
    this->insert(i2, collate<wchar_t>::id);
sl@0
   432
#endif
sl@0
   433
  }
sl@0
   434
  else {
sl@0
   435
    _STLP_TRY {
sl@0
   436
      collate_byname<char> *colbn = new collate_byname<char>(nam, 0, hint);
sl@0
   437
      col   = colbn;
sl@0
   438
#if !defined (__DMC__)
sl@0
   439
      if (hint == 0) hint = _Locale_extract_hint(colbn);
sl@0
   440
#endif
sl@0
   441
#ifndef _STLP_NO_WCHAR_T
sl@0
   442
      wcol  = new collate_byname<wchar_t>(nam, 0, hint);
sl@0
   443
#endif
sl@0
   444
    }
sl@0
   445
#ifndef _STLP_NO_WCHAR_T
sl@0
   446
    _STLP_UNWIND(delete col; delete wcol);
sl@0
   447
#else
sl@0
   448
    _STLP_UNWIND(delete col);
sl@0
   449
#endif
sl@0
   450
    _Locale_insert(this,col);
sl@0
   451
#ifndef _STLP_NO_WCHAR_T
sl@0
   452
    _Locale_insert(this,wcol);
sl@0
   453
#endif
sl@0
   454
  }
sl@0
   455
  return hint;
sl@0
   456
}
sl@0
   457
sl@0
   458
_Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* pname, _Locale_name_hint* hint) {
sl@0
   459
  _Locale_impl* i2 = locale::classic()._M_impl;
sl@0
   460
sl@0
   461
  moneypunct<char, false> *punct = 0;
sl@0
   462
  moneypunct<char, true> *ipunct = 0;
sl@0
   463
  money_get<char, istreambuf_iterator<char, char_traits<char> > > *get = 0;
sl@0
   464
  money_put<char, ostreambuf_iterator<char, char_traits<char> > > *put = 0;
sl@0
   465
sl@0
   466
#ifndef _STLP_NO_WCHAR_T
sl@0
   467
  moneypunct<wchar_t, false>* wpunct = 0;
sl@0
   468
  moneypunct<wchar_t, true>* wipunct = 0;
sl@0
   469
  money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wget = 0;
sl@0
   470
  money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > *wput = 0;
sl@0
   471
#endif
sl@0
   472
sl@0
   473
  char buf[_Locale_MAX_SIMPLE_NAME];
sl@0
   474
  if (pname == 0 || pname[0] == 0)
sl@0
   475
    pname = _Locale_monetary_default(buf);
sl@0
   476
sl@0
   477
  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0
   478
    this->insert(i2, moneypunct<char, false>::id);
sl@0
   479
    this->insert(i2, moneypunct<char, true>::id);
sl@0
   480
    this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
sl@0
   481
    this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
sl@0
   482
#ifndef _STLP_NO_WCHAR_T
sl@0
   483
    this->insert(i2, moneypunct<wchar_t, false>::id);
sl@0
   484
    this->insert(i2, moneypunct<wchar_t, true>::id);
sl@0
   485
    this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0
   486
    this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
sl@0
   487
#endif
sl@0
   488
  }
sl@0
   489
  else {
sl@0
   490
    _STLP_TRY {
sl@0
   491
      moneypunct_byname<char, false>* punctbn = new moneypunct_byname<char, false>(pname, 0, hint);
sl@0
   492
      punct   = punctbn;
sl@0
   493
#if !defined (__DMC__)
sl@0
   494
      if (hint == 0) hint = _Locale_extract_hint(punctbn);
sl@0
   495
#endif
sl@0
   496
      ipunct  = new moneypunct_byname<char, true>(pname, 0, hint);
sl@0
   497
      get     = new money_get<char, istreambuf_iterator<char, char_traits<char> > >;
sl@0
   498
      put     = new money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
sl@0
   499
#ifndef _STLP_NO_WCHAR_T
sl@0
   500
      wpunct  = new moneypunct_byname<wchar_t, false>(pname, 0, hint);
sl@0
   501
      wipunct = new moneypunct_byname<wchar_t, true>(pname, 0, hint);
sl@0
   502
      wget    = new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0
   503
      wput    = new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
sl@0
   504
#endif
sl@0
   505
    }
sl@0
   506
#ifndef _STLP_NO_WCHAR_T
sl@0
   507
    _STLP_UNWIND(delete punct; delete ipunct; delete wpunct; delete wipunct; delete get; delete wget; delete put; delete wput);
sl@0
   508
#else
sl@0
   509
    _STLP_UNWIND(delete punct; delete ipunct; delete get; delete put);
sl@0
   510
#endif
sl@0
   511
    _Locale_insert(this,punct);
sl@0
   512
    _Locale_insert(this,ipunct);
sl@0
   513
    _Locale_insert(this,get);
sl@0
   514
    _Locale_insert(this,put);
sl@0
   515
#ifndef _STLP_NO_WCHAR_T
sl@0
   516
    _Locale_insert(this,wget);
sl@0
   517
    _Locale_insert(this,wpunct);
sl@0
   518
    _Locale_insert(this,wipunct);
sl@0
   519
    _Locale_insert(this,wput);
sl@0
   520
#endif
sl@0
   521
  }
sl@0
   522
  return hint;
sl@0
   523
}
sl@0
   524
sl@0
   525
_Locale_name_hint* _Locale_impl::insert_messages_facets(const char* pname, _Locale_name_hint* hint) {
sl@0
   526
  _Locale_impl* i2 = locale::classic()._M_impl;
sl@0
   527
  messages<char> *msg = 0;
sl@0
   528
#ifndef _STLP_NO_WCHAR_T
sl@0
   529
  messages<wchar_t> *wmsg = 0;
sl@0
   530
#endif
sl@0
   531
sl@0
   532
  char buf[_Locale_MAX_SIMPLE_NAME];
sl@0
   533
  if (pname == 0 || pname[0] == 0)
sl@0
   534
    pname = _Locale_messages_default(buf);
sl@0
   535
sl@0
   536
  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
sl@0
   537
    this->insert(i2, messages<char>::id);
sl@0
   538
#ifndef _STLP_NO_WCHAR_T
sl@0
   539
    this->insert(i2, messages<wchar_t>::id);
sl@0
   540
#endif
sl@0
   541
  }
sl@0
   542
  else {
sl@0
   543
    _STLP_TRY {
sl@0
   544
      msg  = new messages_byname<char>(pname, 0, hint);
sl@0
   545
#ifndef _STLP_NO_WCHAR_T
sl@0
   546
      wmsg = new messages_byname<wchar_t>(pname, 0, hint);
sl@0
   547
#endif
sl@0
   548
    }
sl@0
   549
#ifndef _STLP_NO_WCHAR_T
sl@0
   550
    _STLP_UNWIND(delete msg; delete wmsg);
sl@0
   551
#else
sl@0
   552
    _STLP_UNWIND(delete msg);
sl@0
   553
#endif
sl@0
   554
    _Locale_insert(this,msg);
sl@0
   555
#ifndef _STLP_NO_WCHAR_T
sl@0
   556
    _Locale_insert(this,wmsg);
sl@0
   557
#endif
sl@0
   558
  }
sl@0
   559
  return hint;
sl@0
   560
}
sl@0
   561
sl@0
   562
static void _Stl_loc_assign_ids() {
sl@0
   563
  // This assigns ids to every facet that is a member of a category,
sl@0
   564
  // and also to money_get/put, num_get/put, and time_get/put
sl@0
   565
  // instantiated using ordinary pointers as the input/output
sl@0
   566
  // iterators.  (The default is [io]streambuf_iterator.)
sl@0
   567
sl@0
   568
#ifdef __SYMBIAN32__WSD__
sl@0
   569
	collate<char>::id._M_index =  1;
sl@0
   570
	ctype<char>::id._M_index = 2;
sl@0
   571
sl@0
   572
#ifndef _STLP_NO_MBSTATE_T
sl@0
   573
	codecvt<char, char, mbstate_t>::id._M_index = 3;
sl@0
   574
#  ifndef _STLP_NO_WCHAR_T
sl@0
   575
	codecvt<wchar_t, char, mbstate_t>::id._M_index = 22;
sl@0
   576
#  endif
sl@0
   577
#endif
sl@0
   578
	moneypunct<char, true>::id._M_index = 4;
sl@0
   579
	moneypunct<char, false>::id._M_index = 5;
sl@0
   580
	numpunct<char>::id._M_index = 6;
sl@0
   581
	messages<char>::id._M_index =7;
sl@0
   582
	
sl@0
   583
	collate<wchar_t>::id._M_index = 20;
sl@0
   584
	ctype<wchar_t>::id._M_index = 21;
sl@0
   585
	moneypunct<wchar_t, true>::id._M_index = 23;
sl@0
   586
	moneypunct<wchar_t, false>::id._M_index = 24;
sl@0
   587
	numpunct<wchar_t>::id._M_index = 25;
sl@0
   588
	messages<wchar_t>::id._M_index = 26;
sl@0
   589
#endif
sl@0
   590
sl@0
   591
sl@0
   592
  money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index          = 8;
sl@0
   593
  //money_get<char, const char*>::id._M_index                                             = 9;
sl@0
   594
  money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index          = 10;
sl@0
   595
  //money_put<char, char*>::id._M_index                                                   = 11;
sl@0
   596
sl@0
   597
  num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index            = 12;
sl@0
   598
  //num_get<char, const char*>::id._M_index                                               = 13;
sl@0
   599
  num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index            = 14;
sl@0
   600
  //num_put<char, char*>::id._M_index                                                     = 15;
sl@0
   601
  time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index           = 16;
sl@0
   602
  //time_get<char, const char*>::id._M_index                                              = 17;
sl@0
   603
  time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index           = 18;
sl@0
   604
  //time_put<char, char*>::id._M_index                                                    = 19;
sl@0
   605
sl@0
   606
#ifndef _STLP_NO_WCHAR_T
sl@0
   607
  money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 27;
sl@0
   608
  //money_get<wchar_t, const wchar_t*>::id._M_index                                       = 28;
sl@0
   609
  money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 29;
sl@0
   610
  //money_put<wchar_t, wchar_t*>::id._M_index                                             = 30;
sl@0
   611
sl@0
   612
  num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index   = 31;
sl@0
   613
  //num_get<wchar_t, const wchar_t*>::id._M_index                                         = 32;
sl@0
   614
  num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index  = 33;
sl@0
   615
  //num_put<wchar_t, wchar_t*>::id._M_index                                               = 34;
sl@0
   616
  time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index  = 35;
sl@0
   617
  //time_get<wchar_t, const wchar_t*>::id._M_index                                        = 36;
sl@0
   618
  time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index  = 37;
sl@0
   619
  //time_put<wchar_t, wchar_t*>::id._M_index                                              = 38;
sl@0
   620
#endif
sl@0
   621
  //  locale::id::_S_max                               = 39;
sl@0
   622
}
sl@0
   623
sl@0
   624
// To access those static instance use the getter below, they guaranty
sl@0
   625
// a correct initialization.
sl@0
   626
#if !defined(__SYMBIAN32__WSD__)
sl@0
   627
static locale *_Stl_classic_locale = 0;
sl@0
   628
static locale *_Stl_global_locale = 0;
sl@0
   629
#endif
sl@0
   630
sl@0
   631
static locale* _Stl_get_classic_locale() {
sl@0
   632
#if !defined(__SYMBIAN32__WSD__)
sl@0
   633
  static _Locale_impl::Init init;
sl@0
   634
#endif  
sl@0
   635
  return _Stl_classic_locale;
sl@0
   636
}
sl@0
   637
sl@0
   638
static locale* _Stl_get_global_locale() {
sl@0
   639
#if !defined(__SYMBIAN32__WSD__)
sl@0
   640
  static _Locale_impl::Init init;
sl@0
   641
#endif
sl@0
   642
  return _Stl_global_locale;
sl@0
   643
}
sl@0
   644
sl@0
   645
#if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__)
sl@0
   646
/*
sl@0
   647
 * The following static variable needs to be initialized before STLport
sl@0
   648
 * users static variable in order for him to be able to use Standard
sl@0
   649
 * streams in its variable initialization.
sl@0
   650
 * This variable is here because MSVC do not allow to change the initialization
sl@0
   651
 * segment in a given translation unit, iostream.cpp already contains an
sl@0
   652
 * initialization segment specification.
sl@0
   653
 */
sl@0
   654
#  pragma warning (disable : 4073)
sl@0
   655
#  pragma init_seg(lib)
sl@0
   656
#endif
sl@0
   657
sl@0
   658
#if !defined(__SYMBIAN32__WSD__)
sl@0
   659
static ios_base::Init _IosInit;
sl@0
   660
#endif
sl@0
   661
sl@0
   662
void _Locale_impl::make_classic_locale() {
sl@0
   663
  // This funcion will be called once: during build classic _Locale_impl
sl@0
   664
sl@0
   665
  // The classic locale contains every facet that belongs to a category.
sl@0
   666
  static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf;
sl@0
   667
  _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C");
sl@0
   668
sl@0
   669
  locale::facet* classic_facets[] = {
sl@0
   670
    0,
sl@0
   671
    new collate<char>(1),
sl@0
   672
    new ctype<char>(0, false, 1),
sl@0
   673
#ifndef _STLP_NO_MBSTATE_T
sl@0
   674
    new codecvt<char, char, mbstate_t>(1),
sl@0
   675
#else
sl@0
   676
    0,
sl@0
   677
#endif
sl@0
   678
    new moneypunct<char, true>(1),
sl@0
   679
    new moneypunct<char, false>(1),
sl@0
   680
    new numpunct<char>(1),
sl@0
   681
    new messages<char>(new _STLP_PRIV _Messages()),
sl@0
   682
    new money_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
sl@0
   683
    0,
sl@0
   684
    new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
sl@0
   685
    0,
sl@0
   686
    new num_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
sl@0
   687
    0,
sl@0
   688
    new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
sl@0
   689
    0,
sl@0
   690
    new time_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
sl@0
   691
    0,
sl@0
   692
    new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
sl@0
   693
    0,
sl@0
   694
#ifndef _STLP_NO_WCHAR_T
sl@0
   695
    new collate<wchar_t>(1),
sl@0
   696
    new ctype<wchar_t>(1),
sl@0
   697
sl@0
   698
#  ifndef _STLP_NO_MBSTATE_T
sl@0
   699
    new codecvt<wchar_t, char, mbstate_t>(1),
sl@0
   700
#  else
sl@0
   701
    0,
sl@0
   702
#  endif
sl@0
   703
    new moneypunct<wchar_t, true>(1),
sl@0
   704
    new moneypunct<wchar_t, false>(1),
sl@0
   705
    new numpunct<wchar_t>(1),
sl@0
   706
    new messages<wchar_t>(new _STLP_PRIV _Messages()),
sl@0
   707
sl@0
   708
    new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0
   709
    0,
sl@0
   710
    new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0
   711
    0,
sl@0
   712
sl@0
   713
    new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0
   714
    0,
sl@0
   715
    new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0
   716
    0,
sl@0
   717
    new time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0
   718
    0,
sl@0
   719
    new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
sl@0
   720
    0,
sl@0
   721
#endif
sl@0
   722
    0
sl@0
   723
  };
sl@0
   724
sl@0
   725
  const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *);
sl@0
   726
  classic->facets_vec.reserve(nb_classic_facets);
sl@0
   727
  classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets);
sl@0
   728
sl@0
   729
#if defined(__SYMBIAN32__WSD__)
sl@0
   730
  ::set_Stl_classic_locale(new (WSDAlloc(sizeof(locale))) locale(classic));
sl@0
   731
  ::set_Stl_global_locale (new (WSDAlloc(sizeof(locale))) locale(_copy_Locale_impl(classic)));
sl@0
   732
#else
sl@0
   733
  static locale _Locale_classic(classic);
sl@0
   734
  _Stl_classic_locale = &_Locale_classic;
sl@0
   735
sl@0
   736
  static locale _Locale_global(_copy_Locale_impl(classic));
sl@0
   737
  _Stl_global_locale = &_Locale_global;
sl@0
   738
#endif  
sl@0
   739
}
sl@0
   740
sl@0
   741
#if defined (__BORLANDC__) && (__BORLANDC__ < 0x564)
sl@0
   742
template <>
sl@0
   743
_STLP_DECLSPEC locale::id time_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   744
/* 
sl@0
   745
template <>
sl@0
   746
_STLP_DECLSPEC locale::id time_get<char, const char*>::id;
sl@0
   747
*/
sl@0
   748
sl@0
   749
template <>
sl@0
   750
_STLP_DECLSPEC locale::id time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   751
/*
sl@0
   752
template <>
sl@0
   753
_STLP_DECLSPEC locale::id time_put<char, char*>::id;
sl@0
   754
*/
sl@0
   755
sl@0
   756
#  if !defined (_STLP_NO_WCHAR_T)
sl@0
   757
template <>
sl@0
   758
_STLP_DECLSPEC locale::id time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   759
/*
sl@0
   760
template <>
sl@0
   761
_STLP_DECLSPEC locale::id time_get<wchar_t, const wchar_t*>::id;
sl@0
   762
*/
sl@0
   763
sl@0
   764
template <>
sl@0
   765
_STLP_DECLSPEC locale::id time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   766
/*
sl@0
   767
template <>
sl@0
   768
_STLP_DECLSPEC locale::id time_put<wchar_t, wchar_t*>::id;
sl@0
   769
*/
sl@0
   770
#  endif /* _STLP_NO_WCHAR_T */
sl@0
   771
sl@0
   772
template <>
sl@0
   773
_STLP_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   774
/*
sl@0
   775
template <>
sl@0
   776
_STLP_DECLSPEC locale::id money_get<char, const char*>::id;
sl@0
   777
*/
sl@0
   778
sl@0
   779
template <>
sl@0
   780
_STLP_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   781
/*
sl@0
   782
template <>
sl@0
   783
_STLP_DECLSPEC locale::id money_put<char, char*>::id;
sl@0
   784
*/
sl@0
   785
sl@0
   786
#  if !defined (_STLP_NO_WCHAR_T)
sl@0
   787
template <>
sl@0
   788
_STLP_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   789
/*
sl@0
   790
template <>
sl@0
   791
_STLP_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id;
sl@0
   792
*/
sl@0
   793
sl@0
   794
template <>
sl@0
   795
_STLP_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   796
/*
sl@0
   797
template <>
sl@0
   798
_STLP_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id;
sl@0
   799
*/
sl@0
   800
#  endif
sl@0
   801
sl@0
   802
template <>
sl@0
   803
_STLP_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   804
/*
sl@0
   805
template <>
sl@0
   806
_STLP_DECLSPEC locale::id num_get<char, const char*>::id;
sl@0
   807
*/
sl@0
   808
sl@0
   809
#  if !defined (STLP_NO_WCHAR_T)
sl@0
   810
template <>
sl@0
   811
_STLP_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   812
/*
sl@0
   813
template <>
sl@0
   814
_STLP_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id;
sl@0
   815
*/
sl@0
   816
#  endif
sl@0
   817
sl@0
   818
template <>
sl@0
   819
_STLP_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   820
/*
sl@0
   821
template <>
sl@0
   822
_STLP_DECLSPEC locale::id num_put<char, char*>::id;
sl@0
   823
*/
sl@0
   824
sl@0
   825
#  if !defined (_STLP_NO_WCHAR_T)
sl@0
   826
template <>
sl@0
   827
_STLP_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   828
/*
sl@0
   829
template <>
sl@0
   830
_STLP_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id;
sl@0
   831
*/
sl@0
   832
#  endif
sl@0
   833
#endif
sl@0
   834
sl@0
   835
// Declarations of (non-template) facets' static data members
sl@0
   836
# if defined(__SYMBIAN32__WSD__)
sl@0
   837
  /* no definitions */
sl@0
   838
#elif defined (__EPOC32__)
sl@0
   839
sl@0
   840
locale::id collate<char>::id = { 1 };
sl@0
   841
locale::id ctype<char>::id = { 2 };
sl@0
   842
sl@0
   843
#ifndef _STLP_NO_MBSTATE_T
sl@0
   844
locale::id codecvt<char, char, mbstate_t>::id = { 3 };
sl@0
   845
#  ifndef _STLP_NO_WCHAR_T
sl@0
   846
locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 };
sl@0
   847
#  endif
sl@0
   848
#endif
sl@0
   849
sl@0
   850
locale::id moneypunct<char, true>::id = { 4 };
sl@0
   851
locale::id moneypunct<char, false>::id = { 5 };
sl@0
   852
locale::id numpunct<char>::id = { 6 } ;
sl@0
   853
locale::id messages<char>::id = { 7 };
sl@0
   854
sl@0
   855
#ifndef _STLP_NO_WCHAR_T
sl@0
   856
locale::id collate<wchar_t>::id = { 20 };
sl@0
   857
locale::id ctype<wchar_t>::id = { 21 };
sl@0
   858
sl@0
   859
locale::id moneypunct<wchar_t, true>::id = { 23 } ;
sl@0
   860
locale::id moneypunct<wchar_t, false>::id = { 24 } ;
sl@0
   861
sl@0
   862
locale::id numpunct<wchar_t>::id = { 25 };
sl@0
   863
locale::id messages<wchar_t>::id = { 26 };
sl@0
   864
#endif
sl@0
   865
sl@0
   866
#if defined(__SYMBIAN32__NO_STATIC_IMPORTS__)
sl@0
   867
//ACCESS FUNCTIONS
sl@0
   868
_STLP_DECLSPEC locale::id& collate<char>::GetFacetLocaleId()
sl@0
   869
	{
sl@0
   870
	return collate<char>::id;
sl@0
   871
	}
sl@0
   872
_STLP_DECLSPEC locale::id& ctype<char>::GetFacetLocaleId()
sl@0
   873
	{
sl@0
   874
	return ctype<char>::id;
sl@0
   875
	}
sl@0
   876
#ifndef _STLP_NO_MBSTATE_T
sl@0
   877
_STLP_DECLSPEC locale::id& codecvt<char, char, mbstate_t>::GetFacetLocaleId()
sl@0
   878
	{
sl@0
   879
	return codecvt<char, char, mbstate_t>::id;
sl@0
   880
	}
sl@0
   881
#  ifndef _STLP_NO_WCHAR_T
sl@0
   882
_STLP_DECLSPEC locale::id& codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId()
sl@0
   883
	{
sl@0
   884
	return codecvt<wchar_t, char, mbstate_t>::id;
sl@0
   885
	}
sl@0
   886
#  endif
sl@0
   887
#endif
sl@0
   888
sl@0
   889
_STLP_DECLSPEC locale::id& moneypunct<char, true>::GetFacetLocaleId()
sl@0
   890
	{
sl@0
   891
	return moneypunct<char, true>::id;
sl@0
   892
	}
sl@0
   893
_STLP_DECLSPEC locale::id& moneypunct<char, false>::GetFacetLocaleId()
sl@0
   894
	{
sl@0
   895
	return moneypunct<char, false>::id;
sl@0
   896
	}
sl@0
   897
_STLP_DECLSPEC locale::id& numpunct<char>::GetFacetLocaleId()
sl@0
   898
	{
sl@0
   899
	return numpunct<char>::id;
sl@0
   900
	}
sl@0
   901
_STLP_DECLSPEC locale::id& messages<char>::GetFacetLocaleId()
sl@0
   902
	{
sl@0
   903
	return messages<char>::id;
sl@0
   904
	}
sl@0
   905
#ifndef _STLP_NO_WCHAR_T
sl@0
   906
_STLP_DECLSPEC locale::id& collate<wchar_t>::GetFacetLocaleId()
sl@0
   907
	{
sl@0
   908
	return collate<wchar_t>::id;
sl@0
   909
	}
sl@0
   910
_STLP_DECLSPEC locale::id& ctype<wchar_t>::GetFacetLocaleId()
sl@0
   911
	{
sl@0
   912
	return ctype<wchar_t>::id;
sl@0
   913
	}
sl@0
   914
_STLP_DECLSPEC locale::id& moneypunct<wchar_t, true>::GetFacetLocaleId()
sl@0
   915
	{
sl@0
   916
	return moneypunct<wchar_t, true>::id;
sl@0
   917
	}
sl@0
   918
_STLP_DECLSPEC locale::id& moneypunct<wchar_t, false>::GetFacetLocaleId()
sl@0
   919
	{
sl@0
   920
	return moneypunct<wchar_t, false>::id;
sl@0
   921
	}
sl@0
   922
_STLP_DECLSPEC locale::id& numpunct<wchar_t>::GetFacetLocaleId()
sl@0
   923
	{
sl@0
   924
	return numpunct<wchar_t>::id;
sl@0
   925
	}
sl@0
   926
_STLP_DECLSPEC locale::id& messages<wchar_t>::GetFacetLocaleId()
sl@0
   927
	{
sl@0
   928
	return messages<wchar_t>::id;
sl@0
   929
	}
sl@0
   930
#endif	
sl@0
   931
template <>
sl@0
   932
_STLP_DECLSPEC locale::id& money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0
   933
    {
sl@0
   934
	return money_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   935
    }
sl@0
   936
template <>
sl@0
   937
_STLP_DECLSPEC locale::id& money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0
   938
    {
sl@0
   939
	return money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   940
    }
sl@0
   941
# if !defined (_STLP_NO_WCHAR_T)
sl@0
   942
template <>
sl@0
   943
_STLP_DECLSPEC locale::id& money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0
   944
	{
sl@0
   945
	return money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   946
	}
sl@0
   947
template <>
sl@0
   948
_STLP_DECLSPEC locale::id& money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0
   949
	{
sl@0
   950
	return money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   951
	}
sl@0
   952
# endif
sl@0
   953
template <>
sl@0
   954
_STLP_DECLSPEC locale::id& num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0
   955
    {
sl@0
   956
	return num_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   957
    }
sl@0
   958
# if !defined (STLP_NO_WCHAR_T)
sl@0
   959
template <>
sl@0
   960
_STLP_DECLSPEC locale::id& num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0
   961
    {
sl@0
   962
	return num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   963
    }
sl@0
   964
# endif
sl@0
   965
template <>
sl@0
   966
_STLP_DECLSPEC locale::id& num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0
   967
    {
sl@0
   968
	return num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   969
    }
sl@0
   970
# if !defined (_STLP_NO_WCHAR_T)
sl@0
   971
template <>
sl@0
   972
_STLP_DECLSPEC locale::id& num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0
   973
    {
sl@0
   974
	return num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   975
    }
sl@0
   976
# endif
sl@0
   977
template <>
sl@0
   978
_STLP_DECLSPEC locale::id&
sl@0
   979
time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0
   980
    {
sl@0
   981
	return time_get<char, istreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   982
    }
sl@0
   983
template <>
sl@0
   984
_STLP_DECLSPEC locale::id&
sl@0
   985
time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId()
sl@0
   986
	{
sl@0
   987
	return time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id;
sl@0
   988
	}
sl@0
   989
# ifndef _STLP_NO_WCHAR_T
sl@0
   990
template <>
sl@0
   991
_STLP_DECLSPEC locale::id&
sl@0
   992
time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0
   993
	{
sl@0
   994
	return time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
   995
	}
sl@0
   996
template <>
sl@0
   997
_STLP_DECLSPEC locale::id&
sl@0
   998
time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId()
sl@0
   999
	{
sl@0
  1000
	return time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id;
sl@0
  1001
	}
sl@0
  1002
# endif
sl@0
  1003
sl@0
  1004
# endif // __SYMBIAN32__NO_STATIC_IMPORTS__
sl@0
  1005
sl@0
  1006
sl@0
  1007
#else  // original STLPort 
sl@0
  1008
sl@0
  1009
// size_t locale::id::_S_max = 39; // made before
sl@0
  1010
sl@0
  1011
_STLP_STATIC_MEMBER_DECLSPEC locale::id collate<char>::id = { 1 };
sl@0
  1012
_STLP_STATIC_MEMBER_DECLSPEC locale::id ctype<char>::id = { 2 };
sl@0
  1013
sl@0
  1014
#ifndef _STLP_NO_MBSTATE_T
sl@0
  1015
_STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt<char, char, mbstate_t>::id = { 3 };
sl@0
  1016
#  ifndef _STLP_NO_WCHAR_T
sl@0
  1017
_STLP_STATIC_MEMBER_DECLSPEC locale::id codecvt<wchar_t, char, mbstate_t>::id = { 22 };
sl@0
  1018
#  endif
sl@0
  1019
#endif
sl@0
  1020
sl@0
  1021
_STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<char, true>::id = { 4 };
sl@0
  1022
_STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<char, false>::id = { 5 };
sl@0
  1023
_STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct<char>::id = { 6 } ;
sl@0
  1024
_STLP_STATIC_MEMBER_DECLSPEC locale::id messages<char>::id = { 7 };
sl@0
  1025
sl@0
  1026
#if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564)
sl@0
  1027
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 8 };
sl@0
  1028
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 10 };
sl@0
  1029
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 12 };
sl@0
  1030
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 14 };
sl@0
  1031
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<char, istreambuf_iterator<char, char_traits<char> > >::id = { 16 };
sl@0
  1032
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id = { 18 };
sl@0
  1033
/*
sl@0
  1034
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<char, const char*>::id = { 9 };
sl@0
  1035
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<char, char*>::id = { 11 };
sl@0
  1036
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<char, const char*>::id = { 13 };
sl@0
  1037
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<char, char*>::id = { 15 };
sl@0
  1038
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<char, const char*>::id = { 17 };
sl@0
  1039
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<char, char*>::id = { 19 };
sl@0
  1040
*/
sl@0
  1041
#endif
sl@0
  1042
sl@0
  1043
#ifndef _STLP_NO_WCHAR_T
sl@0
  1044
_STLP_STATIC_MEMBER_DECLSPEC locale::id collate<wchar_t>::id = { 20 };
sl@0
  1045
_STLP_STATIC_MEMBER_DECLSPEC locale::id ctype<wchar_t>::id = { 21 };
sl@0
  1046
sl@0
  1047
_STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<wchar_t, true>::id = { 23 } ;
sl@0
  1048
_STLP_STATIC_MEMBER_DECLSPEC locale::id moneypunct<wchar_t, false>::id = { 24 } ;
sl@0
  1049
sl@0
  1050
_STLP_STATIC_MEMBER_DECLSPEC locale::id numpunct<wchar_t>::id = { 25 };
sl@0
  1051
_STLP_STATIC_MEMBER_DECLSPEC locale::id messages<wchar_t>::id = { 26 };
sl@0
  1052
sl@0
  1053
#if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564)
sl@0
  1054
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 27 };
sl@0
  1055
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 29 };
sl@0
  1056
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 31 };
sl@0
  1057
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id = { 33 };
sl@0
  1058
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 35 };
sl@0
  1059
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id = { 37 };
sl@0
  1060
/*
sl@0
  1061
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_get<wchar_t, const wchar_t*>::id = { 28 };
sl@0
  1062
_STLP_STATIC_MEMBER_DECLSPEC locale::id money_put<wchar_t, wchar_t*>::id = { 30 };
sl@0
  1063
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_get<wchar_t, const wchar_t*>::id = { 32 };
sl@0
  1064
_STLP_STATIC_MEMBER_DECLSPEC locale::id num_put<wchar_t, wchar_t*>::id = { 34 };
sl@0
  1065
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_get<wchar_t, const wchar_t*>::id = { 36 };
sl@0
  1066
_STLP_STATIC_MEMBER_DECLSPEC locale::id time_put<wchar_t, wchar_t*>::id = { 38 };
sl@0
  1067
*/
sl@0
  1068
#  endif
sl@0
  1069
#endif
sl@0
  1070
# endif //!__SYMBIAN32__WSD__
sl@0
  1071
sl@0
  1072
_STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc)
sl@0
  1073
{
sl@0
  1074
  _STLP_ASSERT( loc != 0 );
sl@0
  1075
  loc->_M_incr();
sl@0
  1076
  return loc;
sl@0
  1077
}
sl@0
  1078
sl@0
  1079
void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc)
sl@0
  1080
{
sl@0
  1081
  _STLP_ASSERT( loc != 0 );
sl@0
  1082
  if (loc->_M_decr() == 0) {
sl@0
  1083
    if (*loc != *_Stl_classic_locale)
sl@0
  1084
      delete loc;
sl@0
  1085
    else
sl@0
  1086
      loc->~_Locale_impl();
sl@0
  1087
    loc = 0;
sl@0
  1088
  }
sl@0
  1089
}
sl@0
  1090
sl@0
  1091
_STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc)
sl@0
  1092
{
sl@0
  1093
  _STLP_ASSERT( loc != 0 );
sl@0
  1094
  loc->_M_incr();
sl@0
  1095
  _Locale_impl *loc_new = new _Locale_impl(*loc);
sl@0
  1096
  loc->_M_decr();
sl@0
  1097
  loc_new->name = _Nameless;
sl@0
  1098
  return loc_new;
sl@0
  1099
}
sl@0
  1100
sl@0
  1101
#if defined(__SYMBIAN32__WSD__) 
sl@0
  1102
#undef id 
sl@0
  1103
#endif
sl@0
  1104
sl@0
  1105
_STLP_END_NAMESPACE
sl@0
  1106
sl@0
  1107
#if defined(__SYMBIAN32__WSD__)
sl@0
  1108
void locale_impl_init()
sl@0
  1109
{
sl@0
  1110
	//initialize _S_max
sl@0
  1111
	std::locale::id::get_locale_id_S_max() = 39;
sl@0
  1112
sl@0
  1113
	//initialize the mutex lock in locale.cpp
sl@0
  1114
	locale_index_lock_init();
sl@0
  1115
sl@0
  1116
	//initialize _S_count of Init
sl@0
  1117
	std::ios_base::Init::ios_base_Init_S_count_init();
sl@0
  1118
sl@0
  1119
	//initialize S_was_synced of ios_base
sl@0
  1120
	std::ios_base::ios_base_S_was_synced_init();
sl@0
  1121
sl@0
  1122
	//initialize the mutex in locale_catalog.cpp
sl@0
  1123
	stlp_priv::locale_catalog_category_hash_lock_init();
sl@0
  1124
	
sl@0
  1125
	//initialize category map in locale_catalog.cpp
sl@0
  1126
	stlp_priv::Category_Map_Init();
sl@0
  1127
	
sl@0
  1128
	//initialize empty string in monetary.cpp
sl@0
  1129
	monetary_empty_string_init();
sl@0
  1130
}
sl@0
  1131
# endif //__SYMBIAN32__WSD__
sl@0
  1132
sl@0
  1133
sl@0
  1134
// locale use many static functions/pointers from this file:
sl@0
  1135
// to avoid making ones extern, simple #include implementation of locale
sl@0
  1136
sl@0
  1137
#include "locale.cpp"
sl@0
  1138