ReactOS  0.4.14-dev-317-g96040ec
_Locale_impl Class Reference

#include <locale_impl.h>

Inheritance diagram for _Locale_impl:
Collaboration diagram for _Locale_impl:

Classes

class  Init
 

Public Member Functions

 _Locale_impl (const char *s)
 
 _Locale_impl (const _Locale_impl &)
 
 _Locale_impl (size_t n, const char *s)
 
size_t size () const
 
locale::facetinsert (locale::facet *, const locale::id &n)
 
void insert (_Locale_impl *from, const locale::id &n)
 
_Locale_name_hintinsert_ctype_facets (const char *&name, char *buf, _Locale_name_hint *hint)
 
_Locale_name_hintinsert_numeric_facets (const char *&name, char *buf, _Locale_name_hint *hint)
 
_Locale_name_hintinsert_time_facets (const char *&name, char *buf, _Locale_name_hint *hint)
 
_Locale_name_hintinsert_collate_facets (const char *&name, char *buf, _Locale_name_hint *hint)
 
_Locale_name_hintinsert_monetary_facets (const char *&name, char *buf, _Locale_name_hint *hint)
 
_Locale_name_hintinsert_messages_facets (const char *&name, char *buf, _Locale_name_hint *hint)
 
bool operator != (const locale &__loc) const
 
- Public Member Functions inherited from _Refcount_Base
 _Refcount_Base (__stl_atomic_t __n)
 
__stl_atomic_t _M_incr ()
 
__stl_atomic_t _M_decr ()
 

Static Public Member Functions

static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_bad_cast ()
 
static void _STLP_CALL _S_initialize ()
 
static void _STLP_CALL _S_uninitialize ()
 
static void make_classic_locale ()
 
static void free_classic_locale ()
 

Public Attributes

basic_string< char, char_traits< char >, allocator< char > > name
 

Private Member Functions

 ~_Locale_impl ()
 
void operator= (const _Locale_impl &)
 

Private Attributes

vector< locale::facet * > facets_vec
 

Friends

class Init
 
class locale
 
_Locale_impl *_STLP_CALL _copy_Nameless_Locale_impl (_Locale_impl *)
 
void _STLP_CALL _release_Locale_impl (_Locale_impl *&loc)
 

Detailed Description

Definition at line 60 of file locale_impl.h.

Constructor & Destructor Documentation

◆ _Locale_impl() [1/3]

_Locale_impl::_Locale_impl ( const char s)

Definition at line 74 of file locale_impl.cpp.

75  : _Refcount_Base(0), name(s), facets_vec() {
77  new (&__Loc_init_buf) Init();
78 }
basic_string< char, char_traits< char >, allocator< char > > name
Definition: locale_impl.h:72
_Refcount_Base(__stl_atomic_t __n)
Definition: _threads.h:457
friend class Init
Definition: locale_impl.h:94
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
GLdouble s
Definition: gl.h:2039
static size_t _S_max
Definition: _locale.h:104
static _Stl_aligned_buffer< _Locale_impl::Init > __Loc_init_buf
Definition: locale_impl.cpp:55
void reserve(size_type __n)
Definition: _vector.c:62

Referenced by make_classic_locale().

◆ _Locale_impl() [2/3]

_Locale_impl::_Locale_impl ( const _Locale_impl locimpl)

Definition at line 80 of file locale_impl.cpp.

81  : _Refcount_Base(0), name(locimpl.name), facets_vec() {
82  for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet);
83  facets_vec = locimpl.facets_vec;
84  new (&__Loc_init_buf) Init();
85 }
basic_string< char, char_traits< char >, allocator< char > > name
Definition: locale_impl.h:72
iterator end()
Definition: _vector.h:184
_Refcount_Base(__stl_atomic_t __n)
Definition: _threads.h:457
friend class Init
Definition: locale_impl.h:94
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
_STLP_BEGIN_NAMESPACE _STLP_INLINE_LOOP _Function for_each(_InputIter __first, _InputIter __last, _Function __f)
Definition: _algo.h:59
iterator begin()
Definition: _vector.h:182
locale::facet *_STLP_CALL _get_facet(locale::facet *f)
Definition: locale_impl.cpp:36
static _Stl_aligned_buffer< _Locale_impl::Init > __Loc_init_buf
Definition: locale_impl.cpp:55

◆ _Locale_impl() [3/3]

_Locale_impl::_Locale_impl ( size_t  n,
const char s 
)

Definition at line 87 of file locale_impl.cpp.

88  : _Refcount_Base(0), name(s), facets_vec(n, 0) {
89  new (&__Loc_init_buf) Init();
90 }
basic_string< char, char_traits< char >, allocator< char > > name
Definition: locale_impl.h:72
_Refcount_Base(__stl_atomic_t __n)
Definition: _threads.h:457
GLdouble n
Definition: glext.h:7729
friend class Init
Definition: locale_impl.h:94
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
GLdouble s
Definition: gl.h:2039
static _Stl_aligned_buffer< _Locale_impl::Init > __Loc_init_buf
Definition: locale_impl.cpp:55

◆ ~_Locale_impl()

_Locale_impl::~_Locale_impl ( )
private

Definition at line 92 of file locale_impl.cpp.

92  {
93  (&__Loc_init_buf)->~Init();
95 }
iterator end()
Definition: _vector.h:184
friend class Init
Definition: locale_impl.h:94
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
_STLP_BEGIN_NAMESPACE _STLP_INLINE_LOOP _Function for_each(_InputIter __first, _InputIter __last, _Function __f)
Definition: _algo.h:59
iterator begin()
Definition: _vector.h:182
void _STLP_CALL _release_facet(locale::facet *&f)
Definition: locale_impl.cpp:43
static _Stl_aligned_buffer< _Locale_impl::Init > __Loc_init_buf
Definition: locale_impl.cpp:55

Referenced by _release_Locale_impl().

Member Function Documentation

◆ _M_throw_bad_cast()

void _STLP_CALL _Locale_impl::_M_throw_bad_cast ( )
static

Definition at line 116 of file locale_impl.cpp.

116  {
117  _STLP_THROW(bad_cast());
118 }
#define _STLP_THROW(x)
Definition: features.h:820

Referenced by locale::_M_use_facet().

◆ _S_initialize()

void _STLP_CALL _Locale_impl::_S_initialize ( )
static

Definition at line 100 of file locale_impl.cpp.

100  {
103 }
static void _Stl_loc_assign_ids()
static void make_classic_locale()

Referenced by _Locale_impl::Init::Init().

◆ _S_uninitialize()

void _STLP_CALL _Locale_impl::_S_uninitialize ( )
static

Definition at line 108 of file locale_impl.cpp.

108  {
109  //Not necessary anymore as classic facets are now 'normal' dynamically allocated
110  //facets with a reference counter telling to _release_facet when the facet can be
111  //deleted.
112  //free_classic_locale();
113 }

Referenced by _Locale_impl::Init::~Init().

◆ free_classic_locale()

static void _Locale_impl::free_classic_locale ( )
static

◆ insert() [1/2]

locale::facet * _Locale_impl::insert ( locale::facet f,
const locale::id n 
)

Definition at line 126 of file locale_impl.cpp.

126  {
127  if (f == 0 || n._M_index == 0)
128  return 0;
129 
130  if (n._M_index >= facets_vec.size()) {
131  facets_vec.resize(n._M_index + 1);
132  }
133 
134  if (f != facets_vec[n._M_index])
135  {
136  _release_facet(facets_vec[n._M_index]);
137  facets_vec[n._M_index] = _get_facet(f);
138  }
139 
140  return f;
141 }
void resize(size_type __new_size, const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:636
GLdouble n
Definition: glext.h:7729
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
GLfloat f
Definition: glext.h:7540
locale::facet *_STLP_CALL _get_facet(locale::facet *f)
Definition: locale_impl.cpp:36
#define f
Definition: ke_i.h:83
void _STLP_CALL _release_facet(locale::facet *&f)
Definition: locale_impl.cpp:43
size_type size() const
Definition: _vector.h:192

Referenced by locale::_M_insert(), insert(), insert_collate_facets(), insert_ctype_facets(), insert_messages_facets(), insert_monetary_facets(), insert_numeric_facets(), insert_time_facets(), and locale::locale().

◆ insert() [2/2]

void _Locale_impl::insert ( _Locale_impl from,
const locale::id n 
)

Definition at line 120 of file locale_impl.cpp.

120  {
121  if (n._M_index > 0 && n._M_index < from->size()) {
122  this->insert(from->facets_vec[n._M_index], n);
123  }
124 }
locale::facet * insert(locale::facet *, const locale::id &n)
GLdouble n
Definition: glext.h:7729
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
CardRegion * from
Definition: spigame.cpp:19

◆ insert_collate_facets()

_Locale_name_hint * _Locale_impl::insert_collate_facets ( const char *&  name,
char buf,
_Locale_name_hint hint 
)

Definition at line 350 of file locale_impl.cpp.

350  {
351  if (name[0] == 0)
353 
354  if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
356  this->insert(i2, collate<char>::id);
357 #ifndef _STLP_NO_WCHAR_T
358  this->insert(i2, collate<wchar_t>::id);
359 #endif
360  }
361  else {
362  locale::facet *col = 0;
363 #ifndef _STLP_NO_WCHAR_T
364  locale::facet *wcol = 0;
365 #endif
366 
367  int __err_code;
368  _Locale_collate *__coll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code);
369  if (!__coll) {
370  if (__err_code == _STLP_LOC_NO_MEMORY) {
372  }
373  return hint;
374  }
375 
376  if (hint == 0) hint = _Locale_get_collate_hint(__coll);
377  _STLP_TRY {
378  col = new collate_byname<char>(__coll);
379  }
381 
382 #ifndef _STLP_NO_WCHAR_T
383  _Locale_collate *__wcoll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code);
384  if (!__wcoll) {
385  if (__err_code == _STLP_LOC_NO_MEMORY) {
386  delete col;
388  }
389  }
390  if (__wcoll) {
391  _STLP_TRY {
392  wcol = new collate_byname<wchar_t>(__wcoll);
393  }
394  _STLP_UNWIND(_STLP_PRIV __release_collate(__wcoll); delete col);
395  }
396 #endif
397 
398  this->insert(col, collate<char>::id);
399 #ifndef _STLP_NO_WCHAR_T
400  if (wcol) this->insert(wcol, collate<wchar_t>::id);
401 #endif
402  }
403  return hint;
404 }
locale::facet * insert(locale::facet *, const locale::id &n)
_Locale_collate *_STLP_CALL __acquire_collate(const char *&name, char *buf, _Locale_name_hint *hint, int *__err_code)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static bool is_C_locale_name(const char *name)
Definition: locale_impl.cpp:33
void _STLP_CALL __release_collate(_Locale_collate *cat)
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
_STLP_TEMPLATE_NULL class collate_byname< wchar_t >
Definition: _iosfwd.h:112
#define _STLP_LOC_NO_MEMORY
Definition: c_locale.h:103
#define _STLP_UNWIND(action)
Definition: features.h:824
#define _STLP_PRIV
Definition: _dm.h:70
DWORD hint
Definition: vfdcmd.c:88
_Locale_impl * _M_impl
Definition: _locale.h:203
#define _STLP_TRY
Definition: features.h:817
const char * _Locale_collate_default(char *__buf)
Definition: name.c:36
_STLP_TEMPLATE_NULL class collate_byname< char >
Definition: _iosfwd.h:106
#define _STLP_THROW_BAD_ALLOC
Definition: _new.h:116
struct _Locale_name_hint * _Locale_get_collate_hint(struct _Locale_collate *)

Referenced by locale::locale().

◆ insert_ctype_facets()

_Locale_name_hint * _Locale_impl::insert_ctype_facets ( const char *&  name,
char buf,
_Locale_name_hint hint 
)

Definition at line 150 of file locale_impl.cpp.

150  {
151  if (name[0] == 0)
153 
154  if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
156  this->insert(i2, ctype<char>::id);
158 #ifndef _STLP_NO_WCHAR_T
159  this->insert(i2, ctype<wchar_t>::id);
161 #endif
162  } else {
163  locale::facet* ct = 0;
164  locale::facet* cvt = 0;
165 #ifndef _STLP_NO_WCHAR_T
166  locale::facet* wct = 0;
167  locale::facet* wcvt = 0;
168 #endif
169  int __err_code;
170  _Locale_ctype *__lct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code);
171  if (!__lct) {
172  locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
173  return hint;
174  }
175 
176  if (hint == 0) hint = _Locale_get_ctype_hint(__lct);
177 
178  _STLP_TRY {
179  ct = new ctype_byname<char>(__lct);
180  }
182 
183  _STLP_TRY {
185  }
186  _STLP_UNWIND(delete ct);
187 
188 #ifndef _STLP_NO_WCHAR_T
189  _STLP_TRY {
190  _Locale_ctype *__lwct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code);
191  if (!__lwct) {
192  locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
193  return hint;
194  }
195 
196  _STLP_TRY {
197  wct = new ctype_byname<wchar_t>(__lwct);
198  }
200 
201  _Locale_codecvt *__lwcvt = _STLP_PRIV __acquire_codecvt(name, buf, hint, &__err_code);
202  if (__lwcvt) {
203  _STLP_TRY {
204  wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(__lwcvt);
205  }
206  _STLP_UNWIND(_STLP_PRIV __release_codecvt(__lwcvt); delete wct);
207  }
208  }
209  _STLP_UNWIND(delete cvt; delete ct);
210 #endif
211 
212  this->insert(ct, ctype<char>::id);
214 #ifndef _STLP_NO_WCHAR_T
215  this->insert(wct, ctype<wchar_t>::id);
216  if (wcvt) this->insert(wcvt, codecvt<wchar_t, char, mbstate_t>::id);
217 #endif
218  }
219  return hint;
220 }
locale::facet * insert(locale::facet *, const locale::id &n)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static bool is_C_locale_name(const char *name)
Definition: locale_impl.cpp:33
_STLP_TEMPLATE_NULL class ctype_byname< wchar_t >
Definition: _iosfwd.h:110
struct _Locale_name_hint * _Locale_get_ctype_hint(struct _Locale_ctype *)
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_creation_failure(int __err_code, const char *name, const char *facet)
Definition: locale.cpp:68
#define _STLP_UNWIND(action)
Definition: features.h:824
const char * _Locale_ctype_default(char *__buf)
Definition: _ctype.h:58
#define _STLP_PRIV
Definition: _dm.h:70
_Locale_codecvt *_STLP_CALL __acquire_codecvt(const char *&name, char *buf, _Locale_name_hint *hint, int *__err_code)
static char * cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag)
Definition: fcvtbuf.c:45
DWORD hint
Definition: vfdcmd.c:88
_Locale_impl * _M_impl
Definition: _locale.h:203
#define _STLP_TRY
Definition: features.h:817
Definition: name.c:36
void _STLP_CALL __release_codecvt(_Locale_codecvt *cat)
void _STLP_CALL __release_ctype(_Locale_ctype *cat)
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _Locale_ctype *_STLP_CALL __acquire_ctype(const char *&name, char *buf, _Locale_name_hint *hint, int *__err_code)
_STLP_TEMPLATE_NULL class ctype_byname< char >
Definition: _iosfwd.h:104

Referenced by locale::locale().

◆ insert_messages_facets()

_Locale_name_hint * _Locale_impl::insert_messages_facets ( const char *&  name,
char buf,
_Locale_name_hint hint 
)

Definition at line 511 of file locale_impl.cpp.

511  {
512  if (name[0] == 0)
514 
515  if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
517  this->insert(i2, messages<char>::id);
518 #ifndef _STLP_NO_WCHAR_T
519  this->insert(i2, messages<wchar_t>::id);
520 #endif
521  }
522  else {
523  locale::facet *msg = 0;
524 #ifndef _STLP_NO_WCHAR_T
525  locale::facet *wmsg = 0;
526 #endif
527 
528  int __err_code;
529  _Locale_messages *__msg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code);
530  if (!__msg) {
531  if (__err_code == _STLP_LOC_NO_MEMORY) {
533  }
534  return hint;
535  }
536 
537  _STLP_TRY {
538  msg = new messages_byname<char>(__msg);
539  }
541 
542 #ifndef _STLP_NO_WCHAR_T
543  _STLP_TRY {
544  _Locale_messages *__wmsg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code);
545  if (!__wmsg) {
546  if (__err_code == _STLP_LOC_NO_MEMORY) {
548  }
549  }
550 
551  if (__wmsg) {
552  _STLP_TRY {
553  wmsg = new messages_byname<wchar_t>(__wmsg);
554  }
556  }
557  }
558  _STLP_UNWIND(delete msg);
559 #endif
560 
561  this->insert(msg, messages<char>::id);
562 #ifndef _STLP_NO_WCHAR_T
563  if (wmsg) this->insert(wmsg, messages<wchar_t>::id);
564 #endif
565  }
566  return hint;
567 }
locale::facet * insert(locale::facet *, const locale::id &n)
const char * _Locale_messages_default(char *__buf)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static bool is_C_locale_name(const char *name)
Definition: locale_impl.cpp:33
_Locale_messages *_STLP_CALL __acquire_messages(const char *&name, char *buf, _Locale_name_hint *hint, int *__err_code)
void _STLP_CALL __release_messages(_Locale_messages *cat)
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
#define _STLP_LOC_NO_MEMORY
Definition: c_locale.h:103
#define _STLP_UNWIND(action)
Definition: features.h:824
#define _STLP_PRIV
Definition: _dm.h:70
DWORD hint
Definition: vfdcmd.c:88
_Locale_impl * _M_impl
Definition: _locale.h:203
#define _STLP_TRY
Definition: features.h:817
#define msg(x)
Definition: auth_time.c:54
Definition: name.c:36
#define _STLP_THROW_BAD_ALLOC
Definition: _new.h:116

Referenced by locale::locale().

◆ insert_monetary_facets()

_Locale_name_hint * _Locale_impl::insert_monetary_facets ( const char *&  name,
char buf,
_Locale_name_hint hint 
)

Definition at line 406 of file locale_impl.cpp.

406  {
407  if (name[0] == 0)
409 
411 
412  // We first insert name independant facets taken from the classic locale instance:
413  this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
414  this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
415 #ifndef _STLP_NO_WCHAR_T
416  this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
417  this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
418 #endif
419 
420  if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
423 #ifndef _STLP_NO_WCHAR_T
426 #endif
427  }
428  else {
429  locale::facet *punct = 0;
430  locale::facet *ipunct = 0;
431 
432 #ifndef _STLP_NO_WCHAR_T
433  locale::facet* wpunct = 0;
434  locale::facet* wipunct = 0;
435 #endif
436 
437  int __err_code;
438  _Locale_monetary *__mon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
439  if (!__mon) {
440  if (__err_code == _STLP_LOC_NO_MEMORY) {
442  }
443  return hint;
444  }
445 
446  if (hint == 0) hint = _Locale_get_monetary_hint(__mon);
447 
448  _STLP_TRY {
449  punct = new moneypunct_byname<char, false>(__mon);
450  }
452 
453  _Locale_monetary *__imon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
454  if (!__imon) {
455  delete punct;
456  if (__err_code == _STLP_LOC_NO_MEMORY) {
458  }
459  return hint;
460  }
461 
462  _STLP_TRY {
463  ipunct = new moneypunct_byname<char, true>(__imon);
464  }
465  _STLP_UNWIND(_STLP_PRIV __release_monetary(__imon); delete punct);
466 
467 #ifndef _STLP_NO_WCHAR_T
468  _STLP_TRY {
469  _Locale_monetary *__wmon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
470  if (!__wmon) {
471  if (__err_code == _STLP_LOC_NO_MEMORY) {
473  }
474  }
475 
476  if (__wmon) {
477  _STLP_TRY {
478  wpunct = new moneypunct_byname<wchar_t, false>(__wmon);
479  }
481 
482  _Locale_monetary *__wimon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
483  if (!__wimon) {
484  delete wpunct;
485  if (__err_code == _STLP_LOC_NO_MEMORY) {
487  }
488  wpunct = 0;
489  }
490  else {
491  _STLP_TRY {
492  wipunct = new moneypunct_byname<wchar_t, true>(__wimon);
493  }
494  _STLP_UNWIND(_STLP_PRIV __release_monetary(__wimon); delete wpunct);
495  }
496  }
497  }
498  _STLP_UNWIND(delete ipunct; delete punct);
499 #endif
500 
501  this->insert(punct, moneypunct<char, false>::id);
502  this->insert(ipunct, moneypunct<char, true>::id);
503 #ifndef _STLP_NO_WCHAR_T
504  if (wpunct) this->insert(wpunct, moneypunct<wchar_t, false>::id);
505  if (wipunct) this->insert(wipunct, moneypunct<wchar_t, true>::id);
506 #endif
507  }
508  return hint;
509 }
struct _Locale_name_hint * _Locale_get_monetary_hint(struct _Locale_monetary *)
locale::facet * insert(locale::facet *, const locale::id &n)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static bool is_C_locale_name(const char *name)
Definition: locale_impl.cpp:33
const char * _Locale_monetary_default(char *__buf)
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
#define _STLP_LOC_NO_MEMORY
Definition: c_locale.h:103
#define _STLP_UNWIND(action)
Definition: features.h:824
void _STLP_CALL __release_monetary(_Locale_monetary *cat)
#define _STLP_PRIV
Definition: _dm.h:70
DWORD hint
Definition: vfdcmd.c:88
_Locale_impl * _M_impl
Definition: _locale.h:203
#define _STLP_TRY
Definition: features.h:817
Definition: name.c:36
#define _STLP_THROW_BAD_ALLOC
Definition: _new.h:116
_Locale_monetary *_STLP_CALL __acquire_monetary(const char *&name, char *buf, _Locale_name_hint *hint, int *__err_code)

Referenced by locale::locale().

◆ insert_numeric_facets()

_Locale_name_hint * _Locale_impl::insert_numeric_facets ( const char *&  name,
char buf,
_Locale_name_hint hint 
)

Definition at line 222 of file locale_impl.cpp.

222  {
223  if (name[0] == 0)
225 
227 
228  // We first insert name independant facets taken from the classic locale instance:
229  this->insert(i2,
230  num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
231  this->insert(i2,
232  num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
233 #ifndef _STLP_NO_WCHAR_T
234  this->insert(i2,
235  num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
236  this->insert(i2,
237  num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
238 #endif
239 
240  if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
241  this->insert(i2, numpunct<char>::id);
242 #ifndef _STLP_NO_WCHAR_T
243  this->insert(i2, numpunct<wchar_t>::id);
244 #endif
245  }
246  else {
247  locale::facet* punct = 0;
248 #ifndef _STLP_NO_WCHAR_T
249  locale::facet* wpunct = 0;
250 #endif
251 
252  int __err_code;
253  _Locale_numeric *__lpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code);
254  if (!__lpunct) {
255  locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
256  return hint;
257  }
258 
259  if (hint == 0) hint = _Locale_get_numeric_hint(__lpunct);
260  _STLP_TRY {
261  punct = new numpunct_byname<char>(__lpunct);
262  }
264 
265 #ifndef _STLP_NO_WCHAR_T
266  _Locale_numeric *__lwpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code);
267  if (!__lwpunct) {
268  delete punct;
269  locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
270  return hint;
271  }
272  if (__lwpunct) {
273  _STLP_TRY {
274  wpunct = new numpunct_byname<wchar_t>(__lwpunct);
275  }
276  _STLP_UNWIND(_STLP_PRIV __release_numeric(__lwpunct); delete punct);
277  }
278 #endif
279 
280  this->insert(punct, numpunct<char>::id);
281 #ifndef _STLP_NO_WCHAR_T
282  this->insert(wpunct, numpunct<wchar_t>::id);
283 #endif
284  }
285  return hint;
286 }
locale::facet * insert(locale::facet *, const locale::id &n)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static bool is_C_locale_name(const char *name)
Definition: locale_impl.cpp:33
const char * _Locale_numeric_default(char *__buf)
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
void _STLP_CALL __release_numeric(_Locale_numeric *cat)
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_creation_failure(int __err_code, const char *name, const char *facet)
Definition: locale.cpp:68
#define _STLP_UNWIND(action)
Definition: features.h:824
#define _STLP_PRIV
Definition: _dm.h:70
struct _Locale_name_hint * _Locale_get_numeric_hint(struct _Locale_numeric *)
DWORD hint
Definition: vfdcmd.c:88
_Locale_impl * _M_impl
Definition: _locale.h:203
#define _STLP_TRY
Definition: features.h:817
_Locale_numeric *_STLP_CALL __acquire_numeric(const char *&name, char *buf, _Locale_name_hint *hint, int *__err_code)
Definition: name.c:36

Referenced by locale::locale().

◆ insert_time_facets()

_Locale_name_hint * _Locale_impl::insert_time_facets ( const char *&  name,
char buf,
_Locale_name_hint hint 
)

Definition at line 288 of file locale_impl.cpp.

288  {
289  if (name[0] == 0)
291 
292  if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
294  this->insert(i2,
295  time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
296  this->insert(i2,
297  time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
298 #ifndef _STLP_NO_WCHAR_T
299  this->insert(i2,
300  time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
301  this->insert(i2,
302  time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
303 #endif
304  } else {
305  locale::facet *get = 0;
306  locale::facet *put = 0;
307 #ifndef _STLP_NO_WCHAR_T
308  locale::facet *wget = 0;
309  locale::facet *wput = 0;
310 #endif
311 
312  int __err_code;
313  _Locale_time *__time = _STLP_PRIV __acquire_time(name, buf, hint, &__err_code);
314  if (!__time) {
315  // time facets category is not mandatory for correct stream behavior so if platform
316  // do not support it we do not generate a runtime_error exception.
317  if (__err_code == _STLP_LOC_NO_MEMORY) {
319  }
320  return hint;
321  }
322 
323  if (!hint) hint = _Locale_get_time_hint(__time);
324  _STLP_TRY {
327 #ifndef _STLP_NO_WCHAR_T
330 #endif
331  }
332 #ifndef _STLP_NO_WCHAR_T
333  _STLP_UNWIND(delete wget; delete put; delete get; _STLP_PRIV __release_time(__time));
334 #else
335  _STLP_UNWIND(delete get; _STLP_PRIV __release_time(__time));
336 #endif
337 
338  _STLP_PRIV __release_time(__time);
339 
340  this->insert(get, time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
341  this->insert(put, time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
342 #ifndef _STLP_NO_WCHAR_T
343  this->insert(wget, time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
344  this->insert(wput, time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
345 #endif
346  }
347  return hint;
348 }
locale::facet * insert(locale::facet *, const locale::id &n)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static bool is_C_locale_name(const char *name)
Definition: locale_impl.cpp:33
const char * _Locale_time_default(char *__buf)
#define put(ret, state, sp, n)
Definition: match.c:105
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
#define _STLP_LOC_NO_MEMORY
Definition: c_locale.h:103
#define _STLP_UNWIND(action)
Definition: features.h:824
_Locale_time *_STLP_CALL __acquire_time(const char *&name, char *buf, _Locale_name_hint *, int *__err_code)
void get(int argc, const char *argv[])
Definition: cmds.c:480
#define _STLP_PRIV
Definition: _dm.h:70
void _STLP_CALL __release_time(_Locale_time *__time)
DWORD hint
Definition: vfdcmd.c:88
_Locale_impl * _M_impl
Definition: _locale.h:203
#define _STLP_TRY
Definition: features.h:817
Definition: name.c:36
struct _Locale_name_hint * _Locale_get_time_hint(struct _Locale_time *)
#define _STLP_THROW_BAD_ALLOC
Definition: _new.h:116

Referenced by locale::locale().

◆ make_classic_locale()

void _Locale_impl::make_classic_locale ( )
static

Definition at line 623 of file locale_impl.cpp.

623  {
624  // This funcion will be called once: during build classic _Locale_impl
625 
626  // The classic locale contains every facet that belongs to a category.
627  static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf;
628  _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C");
629 
630  locale::facet* classic_facets[] = {
631  0,
632  new collate<char>(1),
633  new ctype<char>(0, false, 1),
635  new moneypunct<char, true>(1),
637  new numpunct<char>(1),
638  new messages<char>(1),
640  new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
642  new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
644  new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
645 #ifndef _STLP_NO_WCHAR_T
646  new collate<wchar_t>(1),
647  new ctype<wchar_t>(1),
651  new numpunct<wchar_t>(1),
652  new messages<wchar_t>(1),
654  new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
656  new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
658  new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
659 #endif
660  0
661  };
662 
663  const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *);
664  classic->facets_vec.reserve(nb_classic_facets);
665  classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets);
666 
667  static locale _Locale_classic(classic);
668  _Stl_classic_locale = &_Locale_classic;
669 
670  static locale _Locale_global(classic);
671  _Stl_global_locale = &_Locale_global;
672 }
_STLP_TEMPLATE_NULL class ctype< wchar_t >
Definition: _iosfwd.h:109
_STLP_TEMPLATE_NULL class collate< wchar_t >
Definition: _iosfwd.h:111
_STLP_TEMPLATE_NULL class collate< char >
Definition: _iosfwd.h:105
Definition: _locale.h:75
static locale * _Stl_classic_locale
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
_STLP_TEMPLATE_NULL class ctype< char >
Definition: _iosfwd.h:103
_Locale_impl(const char *s)
Definition: locale_impl.cpp:74
void assign(size_type __n, const _Tp &__val)
Definition: _vector.h:315
static locale * _Stl_global_locale
void reserve(size_type __n)
Definition: _vector.c:62

Referenced by _S_initialize().

◆ operator !=()

bool _Locale_impl::operator != ( const locale __loc) const
inline

Definition at line 109 of file locale_impl.h.

109 { return __loc._M_impl != this; }
_Locale_impl * _M_impl
Definition: _locale.h:203

◆ operator=()

◆ size()

size_t _Locale_impl::size ( ) const
inline

Definition at line 70 of file locale_impl.h.

70 { return facets_vec.size(); }
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
size_type size() const
Definition: _vector.h:192

Referenced by locale::_M_get_facet(), and locale::_M_use_facet().

Friends And Related Function Documentation

◆ _copy_Nameless_Locale_impl

_Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl ( _Locale_impl locimpl)
friend

Definition at line 714 of file locale_impl.cpp.

715 {
716  _STLP_ASSERT( loc != 0 );
717  _Locale_impl *loc_new = new _Locale_impl(*loc);
718  loc_new->name = _Nameless;
719  return loc_new;
720 }
basic_string< char, char_traits< char >, allocator< char > > name
Definition: locale_impl.h:72
static _STLP_BEGIN_NAMESPACE const string _Nameless("*")
_Locale_impl(const char *s)
Definition: locale_impl.cpp:74
#define _STLP_ASSERT(expr)
Definition: _debug.h:165

◆ _release_Locale_impl

void _STLP_CALL _release_Locale_impl ( _Locale_impl *&  loc)
friend

Definition at line 702 of file locale_impl.cpp.

703 {
704  _STLP_ASSERT( loc != 0 );
705  if (loc->_M_decr() == 0) {
706  if (*loc != *_Stl_classic_locale)
707  delete loc;
708  else
709  loc->~_Locale_impl();
710  loc = 0;
711  }
712 }
static locale * _Stl_classic_locale
__stl_atomic_t _M_decr()
Definition: _threads.h:480
#define _STLP_ASSERT(expr)
Definition: _debug.h:165

◆ Init

friend class Init
friend

Definition at line 94 of file locale_impl.h.

Referenced by _Locale_impl(), and ~_Locale_impl().

◆ locale

friend class locale
friend

Definition at line 121 of file locale_impl.h.

Member Data Documentation

◆ facets_vec

vector<locale::facet*> _Locale_impl::facets_vec
private

◆ name

basic_string<char, char_traits<char>, allocator<char> > _Locale_impl::name

Definition at line 72 of file locale_impl.h.

Referenced by _copy_Nameless_Locale_impl(), locale::locale(), and locale::name().


The documentation for this class was generated from the following files: