ReactOS 0.4.16-dev-340-g0540c21
locale Class Reference

#include <_locale.h>

Collaboration diagram for locale:

Classes

class  facet
 
class  id
 

Public Types

typedef int category
 

Public Member Functions

 _STLP_STATIC_CONSTANT (category, none=0x000)
 
 _STLP_STATIC_CONSTANT (category, collate=0x010)
 
 _STLP_STATIC_CONSTANT (category, ctype=0x020)
 
 _STLP_STATIC_CONSTANT (category, monetary=0x040)
 
 _STLP_STATIC_CONSTANT (category, numeric=0x100)
 
 _STLP_STATIC_CONSTANT (category, time=0x200)
 
 _STLP_STATIC_CONSTANT (category, messages=0x400)
 
 _STLP_STATIC_CONSTANT (category, all=collate|ctype|monetary|numeric|time|messages)
 
 locale () _STLP_NOTHROW
 
 locale (const locale &) _STLP_NOTHROW
 
 locale (const char *)
 
 locale (const locale &, const char *, category)
 
 locale (const locale &, const locale &, category)
 
const localeoperator= (const locale &) _STLP_NOTHROW
 
 ~locale () _STLP_NOTHROW
 
string name () const
 
bool operator== (const locale &) const
 
bool operator!= (const locale &) const
 
bool operator() (const string &__x, const string &__y) const
 
bool operator() (const wstring &__x, const wstring &__y) const
 
facet_M_get_facet (const id &) const
 
facet_M_use_facet (const id &) const
 
void _M_insert (facet *__f, id &__id)
 

Static Public Member Functions

static locale _STLP_CALL global (const locale &)
 
static const locale &_STLP_CALL classic ()
 
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_combine_error (const string &name)
 
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_null_name ()
 
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_creation_failure (int __err_code, const char *name, const char *facet)
 

Protected Member Functions

 locale (_Locale_impl *)
 
_Locale_impl_M_get_impl () const
 

Protected Attributes

_Locale_impl_M_impl
 

Friends

class _Locale_impl
 

Detailed Description

Definition at line 75 of file _locale.h.

Member Typedef Documentation

◆ category

Definition at line 107 of file _locale.h.

Constructor & Destructor Documentation

◆ locale() [1/6]

locale::locale ( )

Definition at line 118 of file locale.cpp.

120{}
_STLP_DECLSPEC _Locale_impl *_STLP_CALL _get_Locale_impl(_Locale_impl *locimpl)
_Locale_impl * _M_impl
Definition: _locale.h:203
locale * _Stl_get_global_locale()

◆ locale() [2/6]

locale::locale ( const locale L)

Definition at line 123 of file locale.cpp.

124 : _M_impl( _get_Locale_impl( L._M_impl ) )
125{}
#define L(x)
Definition: ntvdm.h:50

◆ locale() [3/6]

locale::locale ( const char name)
explicit

Definition at line 137 of file locale.cpp.

138 : _M_impl(0) {
139 if (!name)
141
142 if (is_C_locale_name(name)) {
144 return;
145 }
146
147 _Locale_impl* impl = 0;
148 _STLP_TRY {
149 impl = new _Locale_impl(locale::id::_S_max, name);
150
151 // Insert categories one at a time.
153 const char* ctype_name = name;
154 char ctype_buf[_Locale_MAX_SIMPLE_NAME];
155 const char* numeric_name = name;
156 char numeric_buf[_Locale_MAX_SIMPLE_NAME];
157 const char* time_name = name;
158 char time_buf[_Locale_MAX_SIMPLE_NAME];
159 const char* collate_name = name;
160 char collate_buf[_Locale_MAX_SIMPLE_NAME];
161 const char* monetary_name = name;
162 char monetary_buf[_Locale_MAX_SIMPLE_NAME];
163 const char* messages_name = name;
164 char messages_buf[_Locale_MAX_SIMPLE_NAME];
165 hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
166 hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
167 hint = impl->insert_time_facets(time_name, time_buf, hint);
168 hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
169 hint = impl->insert_monetary_facets(monetary_name, monetary_buf, hint);
170 impl->insert_messages_facets(messages_name, messages_buf, hint);
171
172 // Try to use a normalize locale name in order to have the == operator
173 // to behave correctly:
174 if (strcmp(ctype_name, numeric_name) == 0 &&
175 strcmp(ctype_name, time_name) == 0 &&
176 strcmp(ctype_name, collate_name) == 0 &&
177 strcmp(ctype_name, monetary_name) == 0 &&
178 strcmp(ctype_name, messages_name) == 0) {
179 impl->name = ctype_name;
180 }
181 // else we keep current name.
182
183 // reassign impl
184 _M_impl = _get_Locale_impl( impl );
185 }
186 _STLP_UNWIND(delete impl);
187}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
_Locale_name_hint * insert_numeric_facets(const char *&name, char *buf, _Locale_name_hint *hint)
_Locale_name_hint * insert_ctype_facets(const char *&name, char *buf, _Locale_name_hint *hint)
basic_string< char, char_traits< char >, allocator< char > > name
Definition: locale_impl.h:72
_Locale_name_hint * insert_messages_facets(const char *&name, char *buf, _Locale_name_hint *hint)
_Locale_name_hint * insert_collate_facets(const char *&name, char *buf, _Locale_name_hint *hint)
_Locale_name_hint * insert_monetary_facets(const char *&name, char *buf, _Locale_name_hint *hint)
_Locale_name_hint * insert_time_facets(const char *&name, char *buf, _Locale_name_hint *hint)
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_on_null_name()
Definition: locale.cpp:57
string name() const
Definition: locale.cpp:388
static const locale &_STLP_CALL classic()
Definition: locale.cpp:404
friend class _Locale_impl
Definition: _locale.h:200
#define _STLP_UNWIND(action)
Definition: features.h:824
#define _STLP_TRY
Definition: features.h:817
#define _Locale_MAX_SIMPLE_NAME
Definition: c_locale.h:54
static bool is_C_locale_name(const char *name)
Definition: locale.cpp:31
Definition: name.c:39
DWORD hint
Definition: vfdcmd.c:88

◆ locale() [4/6]

locale::locale ( const locale ,
const char ,
category   
)

◆ locale() [5/6]

locale::locale ( _Locale_impl impl)
protected

Definition at line 132 of file locale.cpp.

132 :
133 _M_impl( _get_Locale_impl( impl ) )
134{}

◆ locale() [6/6]

locale::locale ( const locale L1,
const locale L2,
category  c 
)

Definition at line 295 of file locale.cpp.

296 : _M_impl(0) {
297 _Locale_impl* impl = new _Locale_impl(*L1._M_impl);
298
299 _Locale_impl* i2 = L2._M_impl;
300
301 if (L1.name() != _Nameless && L2.name() != _Nameless)
303 else {
304 impl->name = _Nameless;
305 }
306
307 if (c & collate) {
308 impl->insert( i2, _STLP_STD::collate<char>::id);
309# ifndef _STLP_NO_WCHAR_T
310 impl->insert( i2, _STLP_STD::collate<wchar_t>::id);
311# endif
312 }
313 if (c & ctype) {
314 impl->insert( i2, _STLP_STD::ctype<char>::id);
315 impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::id);
316# ifndef _STLP_NO_WCHAR_T
317 impl->insert( i2, _STLP_STD::ctype<wchar_t>::id);
318 impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::id);
319# endif
320 }
321 if (c & monetary) {
322 impl->insert( i2, _STLP_STD::moneypunct<char, true>::id);
323 impl->insert( i2, _STLP_STD::moneypunct<char, false>::id);
324 impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
325 impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
326# ifndef _STLP_NO_WCHAR_T
327 impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::id);
328 impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::id);
329 impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
330 impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
331# endif
332 }
333 if (c & numeric) {
334 impl->insert( i2, _STLP_STD::numpunct<char>::id);
335 impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
336 impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
337# ifndef _STLP_NO_WCHAR_T
338 impl->insert( i2, _STLP_STD::numpunct<wchar_t>::id);
339 impl->insert( i2, _STLP_STD::num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
340 impl->insert( i2, _STLP_STD::num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
341# endif
342 }
343 if (c & time) {
344 impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
345 impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
346# ifndef _STLP_NO_WCHAR_T
347 impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
348 impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
349# endif
350 }
351 if (c & messages) {
352 impl->insert( i2, _STLP_STD::messages<char>::id);
353# ifndef _STLP_NO_WCHAR_T
354 impl->insert( i2, _STLP_STD::messages<wchar_t>::id);
355# endif
356 }
357 _M_impl = _get_Locale_impl( impl );
358}
locale::facet * insert(locale::facet *, const locale::id &n)
const _CharT * c_str() const
Definition: _string.h:949
Definition: _ctype.h:58
const GLubyte * c
Definition: glext.h:8905
GLuint id
Definition: glext.h:5910
__u16 time
Definition: mkdosfs.c:8
static void _Stl_loc_combine_names(_Locale_impl *L, const char *name1, const char *name2, locale::category c)
Definition: locale.cpp:208
static _STLP_BEGIN_NAMESPACE const string _Nameless("*")

◆ ~locale()

locale::~locale ( )

Definition at line 361 of file locale.cpp.

361 {
362 if (_M_impl)
364}
void _STLP_CALL _release_Locale_impl(_Locale_impl *&loc)

Member Function Documentation

◆ _M_get_facet()

locale::facet * locale::_M_get_facet ( const id n) const

Definition at line 377 of file locale.cpp.

377 {
378 return n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0;
379}
vector< locale::facet * > facets_vec
Definition: locale_impl.h:112
size_t size() const
Definition: locale_impl.h:70
GLdouble n
Definition: glext.h:7729

Referenced by _HasFacet().

◆ _M_get_impl()

_Locale_impl * locale::_M_get_impl ( ) const
inlineprotected

Definition at line 204 of file _locale.h.

204{ return _M_impl; }

◆ _M_insert()

void locale::_M_insert ( facet __f,
locale::id n 
)

Definition at line 127 of file locale.cpp.

127 {
128 if (f)
130}
GLfloat f
Definition: glext.h:7540
static const locale::id & _Stl_loc_get_index(locale::id &id)
Definition: locale.cpp:102

Referenced by _InsertFacet().

◆ _M_throw_on_combine_error()

void _STLP_CALL locale::_M_throw_on_combine_error ( const string name)
static

Definition at line 60 of file locale.cpp.

60 {
61 string what = "Unable to find facet";
62 what += " in ";
63 what += name.empty() ? "system" : name.c_str();
64 what += " locale";
66}
#define _STLP_THROW(x)
Definition: features.h:820

◆ _M_throw_on_creation_failure()

void _STLP_CALL locale::_M_throw_on_creation_failure ( int  __err_code,
const char name,
const char facet 
)
static

Definition at line 68 of file locale.cpp.

69 {
70 string what;
71 switch (__err_code) {
73 what = "No platform localization support for ";
74 what += facet;
75 what += " facet category, unable to create facet for ";
76 what += name[0] == 0 ? "system" : name;
77 what += " locale";
78 break;
80 what = "No platform localization support, unable to create ";
81 what += name[0] == 0 ? "system" : name;
82 what += " locale";
83 break;
84 default:
86 what = "Unable to create facet ";
87 what += facet;
88 what += " from name '";
89 what += name;
90 what += "'";
91 break;
94 break;
95 }
96
98}
#define _STLP_THROW_BAD_ALLOC
Definition: _new.h:116
#define _STLP_LOC_UNSUPPORTED_FACET_CATEGORY
Definition: c_locale.h:100
#define _STLP_LOC_NO_MEMORY
Definition: c_locale.h:103
#define _STLP_LOC_UNKNOWN_NAME
Definition: c_locale.h:101
#define _STLP_LOC_NO_PLATFORM_SUPPORT
Definition: c_locale.h:102

Referenced by _Messages::_Messages(), codecvt_byname< wchar_t, char, mbstate_t >::codecvt_byname(), collate_byname< char >::collate_byname(), collate_byname< wchar_t >::collate_byname(), ctype_byname< char >::ctype_byname(), ctype_byname< wchar_t >::ctype_byname(), _Locale_impl::insert_ctype_facets(), _Locale_impl::insert_numeric_facets(), moneypunct_byname< char, true >::moneypunct_byname(), moneypunct_byname< char, false >::moneypunct_byname(), moneypunct_byname< wchar_t, true >::moneypunct_byname(), moneypunct_byname< wchar_t, false >::moneypunct_byname(), numpunct_byname< char >::numpunct_byname(), numpunct_byname< wchar_t >::numpunct_byname(), time_init< char >::time_init(), and time_init< wchar_t >::time_init().

◆ _M_throw_on_null_name()

◆ _M_use_facet()

locale::facet * locale::_M_use_facet ( const id n) const

Definition at line 381 of file locale.cpp.

381 {
382 locale::facet* f = (n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0);
383 if (!f)
385 return f;
386}
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_bad_cast()
#define f
Definition: ke_i.h:83

Referenced by _UseFacet().

◆ _STLP_STATIC_CONSTANT() [1/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
all  = collate|ctype|monetary|numeric|time|messages 
)

◆ _STLP_STATIC_CONSTANT() [2/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
collate  = 0x010 
)

◆ _STLP_STATIC_CONSTANT() [3/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
ctype  = 0x020 
)

◆ _STLP_STATIC_CONSTANT() [4/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
messages  = 0x400 
)

◆ _STLP_STATIC_CONSTANT() [5/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
monetary  = 0x040 
)

◆ _STLP_STATIC_CONSTANT() [6/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
none  = 0x000 
)

◆ _STLP_STATIC_CONSTANT() [7/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
numeric  = 0x100 
)

◆ _STLP_STATIC_CONSTANT() [8/8]

locale::_STLP_STATIC_CONSTANT ( category  ,
time  = 0x200 
)

◆ classic()

◆ global()

locale _STLP_CALL locale::global ( const locale L)
static

Definition at line 409 of file locale.cpp.

409 {
410#else
412#endif
414 if (_Stl_get_global_locale()->_M_impl != L._M_impl) {
416 // this assign should be atomic, should be fixed here:
418
419 // Set the global C locale, if appropriate.
420#if !defined(_STLP_NO_LOCALE_SUPPORT)
421 if (L.name() != _Nameless)
422 setlocale(LC_ALL, L.name().c_str());
423#endif
424 }
425
426#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
427 return old;
428#else
429 return old._M_impl;
430#endif
431}
#define _STLP_CALL
Definition: _bc.h:131
Definition: _locale.h:75
static locale _STLP_CALL global(const locale &)
Definition: locale.cpp:409
#define LC_ALL
Definition: locale.h:17
char * name
Definition: compiler.c:66
#define setlocale(n, s)
Definition: locale.h:46

Referenced by LocaleTest::_locale_init_problem(), global(), and main().

◆ name()

string locale::name ( ) const

Definition at line 388 of file locale.cpp.

388 {
389 return _M_impl->name;
390}

Referenced by _M_throw_on_creation_failure(), LocaleTest::combine(), locale(), main(), operator==(), and test_supported_locale().

◆ operator!=()

bool locale::operator!= ( const locale L) const

Definition at line 398 of file locale.cpp.

398 {
399 return !(*this == L);
400}

◆ operator()() [1/2]

bool locale::operator() ( const string __x,
const string __y 
) const

Definition at line 46 of file locale.cpp.

48{ return __locale_do_operator_call(*this, __x, __y); }
bool __locale_do_operator_call(const locale &__loc, const basic_string< _CharT, _Traits, _Alloc > &__x, const basic_string< _CharT, _Traits, _Alloc > &__y)
Definition: _collate.h:162

◆ operator()() [2/2]

bool locale::operator() ( const wstring &  __x,
const wstring &  __y 
) const

Definition at line 51 of file locale.cpp.

53{ return __locale_do_operator_call(*this, __x, __y); }

◆ operator=()

const locale & locale::operator= ( const locale L)

Definition at line 368 of file locale.cpp.

368 {
369 if (this->_M_impl != L._M_impl) {
370 if (this->_M_impl)
373 }
374 return *this;
375}

◆ operator==()

bool locale::operator== ( const locale L) const

Definition at line 393 of file locale.cpp.

393 {
394 return this->_M_impl == L._M_impl ||
395 (this->name() == L.name() && this->name() != _Nameless);
396}

Friends And Related Function Documentation

◆ _Locale_impl

friend class _Locale_impl
friend

Definition at line 200 of file _locale.h.

Referenced by locale().

Member Data Documentation

◆ _M_impl


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