34 #ifndef _LOCALE_CLASSES_H
35 #define _LOCALE_CLASSES_H 1
37 #pragma GCC system_header
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 template<
typename _Facet>
81 template<
typename _Facet>
85 template<
typename _Cache>
86 friend struct __use_cache;
153 #if __cplusplus >= 201103L
205 template<
typename _Facet>
220 operator=(const
locale& __other) throw();
234 template<typename _Facet>
243 _GLIBCXX_DEFAULT_ABI_TAG
255 operator==(const
locale& __other) const throw();
257 #if __cpp_impl_three_way_comparison < 201907L
284 template<
typename _Char,
typename _Traits,
typename _Alloc>
314 static _Impl* _S_classic;
317 static _Impl* _S_global;
323 static const char*
const*
const _S_categories;
335 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
338 static __gthread_once_t _S_once;
348 _S_initialize_once() throw();
356 #if _GLIBCXX_USE_CXX11_ABI
357 static const id*
const _S_twinned_facets[];
377 friend class locale::_Impl;
379 mutable _Atomic_word _M_refcount;
382 static __c_locale _S_c_locale;
385 static const char _S_c_name[2];
388 static __gthread_once_t _S_once;
392 _S_initialize_once();
405 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
413 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
414 __c_locale __old = 0);
417 _S_clone_c_locale(__c_locale& __cloc)
throw();
420 _S_destroy_c_locale(__c_locale& __cloc);
423 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
430 _GLIBCXX_CONST
static const char*
431 _S_get_c_name() throw();
433 #if __cplusplus < 201103L
438 operator=(
const facet&);
443 operator=(
const facet&) =
delete;
448 _M_add_reference()
const throw()
449 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
452 _M_remove_reference()
const throw()
455 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
456 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
458 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
466 const facet* _M_sso_shim(
const id*)
const;
467 const facet* _M_cow_shim(
const id*)
const;
489 friend class locale::_Impl;
491 template<
typename _Facet>
495 template<
typename _Facet>
502 mutable size_t _M_index;
505 static _Atomic_word _S_refcount;
508 operator=(
const id&);
519 _M_id()
const throw();
531 template<
typename _Facet>
535 template<
typename _Facet>
539 template<
typename _Cache>
540 friend struct __use_cache;
544 _Atomic_word _M_refcount;
545 const facet** _M_facets;
546 size_t _M_facets_size;
547 const facet** _M_caches;
550 static const locale::id*
const _S_id_numeric[];
551 static const locale::id*
const _S_id_collate[];
553 static const locale::id*
const _S_id_monetary[];
554 static const locale::id*
const _S_id_messages[];
555 static const locale::id*
const*
const _S_facet_categories[];
558 _M_add_reference() throw()
559 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
562 _M_remove_reference() throw()
565 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
566 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
568 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
576 _Impl(
const _Impl&,
size_t);
577 _Impl(
const char*,
size_t);
578 _Impl(
size_t)
throw();
585 operator=(const _Impl&);
593 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
594 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
599 _M_replace_categories(
const _Impl*,
category);
602 _M_replace_category(
const _Impl*,
const locale::id*
const*);
605 _M_replace_facet(
const _Impl*,
const locale::id*);
608 _M_install_facet(
const locale::id*,
const facet*);
610 template<
typename _Facet>
612 _M_init_facet(_Facet* __facet)
613 { _M_install_facet(&_Facet::id, __facet); }
615 template<
typename _Facet>
617 _M_init_facet_unchecked(_Facet* __facet)
619 __facet->_M_add_reference();
620 _M_facets[_Facet::id._M_id()] = __facet;
624 _M_install_cache(
const facet*,
size_t);
626 void _M_init_extra(facet**);
627 void _M_init_extra(
void*,
void*,
const char*,
const char*);
643 template<
typename _CharT>
657 __c_locale _M_c_locale_collate;
672 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
686 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
702 compare(
const _CharT* __lo1,
const _CharT* __hi1,
703 const _CharT* __lo2,
const _CharT* __hi2)
const
704 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
722 {
return this->do_transform(__lo, __hi); }
735 hash(
const _CharT* __lo,
const _CharT* __hi)
const
736 {
return this->do_hash(__lo, __hi); }
740 _M_compare(
const _CharT*,
const _CharT*)
const throw();
743 _M_transform(_CharT*,
const _CharT*,
size_t)
const throw();
749 { _S_destroy_c_locale(_M_c_locale_collate); }
764 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
765 const _CharT* __lo2,
const _CharT* __hi2)
const;
778 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
791 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
794 template<
typename _CharT>
800 collate<char>::_M_compare(
const char*,
const char*)
const throw();
804 collate<char>::_M_transform(
char*,
const char*,
size_t)
const throw();
806 #ifdef _GLIBCXX_USE_WCHAR_T
809 collate<wchar_t>::_M_compare(
const wchar_t*,
const wchar_t*)
const throw();
813 collate<wchar_t>::_M_transform(
wchar_t*,
const wchar_t*,
size_t)
const throw();
817 template<
typename _CharT>
831 if (__builtin_strcmp(__s,
"C") != 0
832 && __builtin_strcmp(__s,
"POSIX") != 0)
834 this->_S_destroy_c_locale(this->_M_c_locale_collate);
835 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
839 #if __cplusplus >= 201103L
847 ~collate_byname() { }
850 _GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
Container class for localization functionality.
bool operator==(const locale &__other) const
Locale equality.
static locale global(const locale &__loc)
Set global locale.
static const category time
Category values.
static const category monetary
Category values.
~locale()
Locale destructor.
static const category numeric
Category values.
static const category none
Category values.
static const category messages
Category values.
locale(const std::string &__s)
Named locale constructor.
locale(const locale &__base, const std::string &__s, category __cat)
Construct locale with facets from another locale.
int category
Definition of locale::category.
locale combine(const locale &__other) const
Construct locale with another facet.
static const locale & classic()
Return reference to the C locale.
_GLIBCXX_DEFAULT_ABI_TAG string name() const
Return locale name.
friend const _Facet & use_facet(const locale &)
Return a facet.
static const category all
Category values.
friend bool has_facet(const locale &)
Test for the presence of a facet.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.
bool operator!=(const locale &__other) const
Locale inequality.
locale(const locale &__base, const locale &__add, category __cat)
Construct locale with facets from another locale.
locale()
Default constructor.
Localization functionality base class.
facet(size_t __refs=0)
Facet constructor.
virtual ~facet()
Facet destructor.
friend const _Facet & use_facet(const locale &)
Return a facet.
friend bool has_facet(const locale &)
Test for the presence of a facet.
Facet for localized string comparison.
virtual ~collate()
Destructor.
collate(__c_locale __cloc, size_t __refs=0)
Internal constructor. Not for general use.
_CharT char_type
Public typedefs.
static locale::id id
Numpunct facet id.
long hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
int compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
string_type transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
basic_string< _CharT > string_type
Public typedefs.
collate(size_t __refs=0)
Constructor performs initialization.
class collate_byname [22.2.4.2].
basic_string< _CharT > string_type
Public typedefs.
_CharT char_type
Public typedefs.
Primary class template ctype facet.
Primary class template messages.