36 #ifndef _LOCALE_CLASSES_H
37 #define _LOCALE_CLASSES_H 1
39 #pragma GCC system_header
45 namespace std _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
79 template<
typename _Facet>
83 template<typename _Facet>
87 template<typename _Cache>
88 friend struct __use_cache;
128 locale(const locale& __other) throw();
139 locale(const
char* __s);
166 locale(const locale& __base, const locale& __add,
category __cat);
179 template<typename _Facet>
180 locale(const locale& __other, _Facet* __f);
194 operator=(const locale& __other) throw();
208 template<typename _Facet>
210 combine(const locale& __other) const;
228 operator==(const locale& __other) const throw();
237 operator!=(const locale& __other) const throw()
255 template<
typename _Char,
typename _Traits,
typename _Alloc>
285 static _Impl* _S_classic;
288 static _Impl* _S_global;
294 static const char*
const*
const _S_categories;
306 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
309 static __gthread_once_t _S_once;
319 _S_initialize_once() throw();
344 friend class locale::_Impl;
346 mutable _Atomic_word _M_refcount;
349 static __c_locale _S_c_locale;
352 static const char _S_c_name[2];
355 static __gthread_once_t _S_once;
359 _S_initialize_once();
372 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
380 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
381 __c_locale __old = 0);
384 _S_clone_c_locale(__c_locale& __cloc)
throw();
387 _S_destroy_c_locale(__c_locale& __cloc);
390 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
397 _GLIBCXX_CONST
static const char*
398 _S_get_c_name() throw();
402 _M_add_reference() const throw()
403 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
406 _M_remove_reference()
const throw()
409 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
410 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
412 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
442 friend class locale::_Impl;
444 template<
typename _Facet>
448 template<
typename _Facet>
455 mutable size_t _M_index;
458 static _Atomic_word _S_refcount;
472 _M_id()
const throw();
484 template<
typename _Facet>
488 template<typename _Facet>
492 template<typename _Cache>
493 friend struct __use_cache;
497 _Atomic_word _M_refcount;
498 const facet** _M_facets;
499 size_t _M_facets_size;
500 const facet** _M_caches;
502 static const locale::
id* const _S_id_ctype[];
503 static const locale::
id* const _S_id_numeric[];
504 static const locale::
id* const _S_id_collate[];
505 static const locale::
id* const _S_id_time[];
506 static const locale::
id* const _S_id_monetary[];
507 static const locale::
id* const _S_id_messages[];
508 static const locale::
id* const* const _S_facet_categories[];
511 _M_add_reference() throw()
512 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
515 _M_remove_reference() throw()
518 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
519 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
521 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
529 _Impl(
const _Impl&,
size_t);
530 _Impl(
const char*,
size_t);
531 _Impl(
size_t) throw();
538 operator=(const _Impl&);
546 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
547 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
552 _M_replace_categories(
const _Impl*, category);
555 _M_replace_category(
const _Impl*,
const locale::id*
const*);
558 _M_replace_facet(
const _Impl*,
const locale::id*);
561 _M_install_facet(
const locale::id*,
const facet*);
563 template<
typename _Facet>
565 _M_init_facet(_Facet* __facet)
566 { _M_install_facet(&_Facet::id, __facet); }
569 _M_install_cache(
const facet*,
size_t);
585 template<
typename _CharT>
599 __c_locale _M_c_locale_collate;
614 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
628 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
644 compare(
const _CharT* __lo1,
const _CharT* __hi1,
645 const _CharT* __lo2,
const _CharT* __hi2)
const
646 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
664 {
return this->do_transform(__lo, __hi); }
677 hash(
const _CharT* __lo,
const _CharT* __hi)
const
678 {
return this->do_hash(__lo, __hi); }
682 _M_compare(
const _CharT*,
const _CharT*)
const throw();
685 _M_transform(_CharT*, const _CharT*,
size_t) const throw();
691 { _S_destroy_c_locale(_M_c_locale_collate); }
706 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
707 const _CharT* __lo2,
const _CharT* __hi2)
const;
720 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
733 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
736 template<
typename _CharT>
737 locale::id collate<_CharT>::id;
742 collate<char>::_M_compare(
const char*,
const char*)
const throw();
746 collate<
char>::_M_transform(
char*, const
char*,
size_t) const throw();
748 #ifdef _GLIBCXX_USE_WCHAR_T
751 collate<wchar_t>::_M_compare(
const wchar_t*,
const wchar_t*)
const throw();
755 collate<
wchar_t>::_M_transform(
wchar_t*, const
wchar_t*,
size_t) const throw();
759 template<
typename _CharT>
773 if (__builtin_strcmp(__s,
"C") != 0
774 && __builtin_strcmp(__s,
"POSIX") != 0)
776 this->_S_destroy_c_locale(this->_M_c_locale_collate);
777 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
786 _GLIBCXX_END_NAMESPACE_VERSION
static const category none
Category values.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
static const category collate
Category values.
const locale & operator=(const locale &__other)
Assignment operator.
Localization functionality base class.The facet class is the base class for a localization feature...
bool operator==(const locale &__other) const
Locale equality.
static const category numeric
Category values.
collate(size_t __refs=0)
Constructor performs initialization.
Primary class template messages.This facet encapsulates the code to retrieve messages from message ca...
Primary class template ctype facet.This template class defines classification and conversion function...
facet(size_t __refs=0)
Facet constructor.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.
int compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
basic_string< _CharT > string_type
Public typedefs.
static const locale & classic()
Return reference to the C locale.
string name() const
Return locale name.
_CharT char_type
Public typedefs.
collate(__c_locale __cloc, size_t __refs=0)
Internal constructor. Not for general use.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
class collate_byname [22.2.4.2].
string_type transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
static const category time
Category values.
int category
Definition of locale::category.
Managing sequences of characters and character-like objects.
static locale::id id
Numpunct facet id.
static const category all
Category values.
Facet ID class.The ID class provides facets with an index used to identify them. Every facet class mu...
friend const _Facet & use_facet(const locale &)
Return a facet.
static locale global(const locale &__loc)
Set global locale.
locale()
Default constructor.
friend bool has_facet(const locale &)
Test for the presence of a facet.
locale combine(const locale &__other) const
Construct locale with another facet.
long hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
static const category monetary
Category values.
Facet for localized string comparison.
_CharT char_type
Public typedefs.
basic_string< _CharT > string_type
Public typedefs.