34#ifndef _LOCALE_CLASSES_H
35#define _LOCALE_CLASSES_H 1
37#pragma GCC system_header
43#ifdef __glibcxx_text_encoding
44#include <text_encoding>
47namespace std _GLIBCXX_VISIBILITY(default)
49_GLIBCXX_BEGIN_NAMESPACE_VERSION
81 template<
typename _Facet>
85 template<
typename _Facet>
89 template<
typename _Facet>
91 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
93 template<
typename _Cache>
94 friend struct __use_cache;
161#if __cplusplus >= 201103L
186 :
locale(__base, __s.c_str(), __cat) { }
213 template<
typename _Facet>
228 operator=(const
locale& __other) throw();
242 template<typename _Facet>
251 _GLIBCXX_DEFAULT_ABI_TAG
255#ifdef __glibcxx_text_encoding
256# if __CHAR_BIT__ == 8
261 encoding()
const =
delete;
275#if __cpp_impl_three_way_comparison < 201907L
283 operator!=(
const locale& __other)
const throw()
302 template<
typename _Char,
typename _Traits,
typename _Alloc>
332 static _Impl* _S_classic;
335 static _Impl* _S_global;
341 static const char*
const*
const _S_categories;
353 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
356 static __gthread_once_t _S_once;
366 _S_initialize_once() throw();
374#if _GLIBCXX_USE_CXX11_ABI
375 static const id*
const _S_twinned_facets[];
395 friend class locale::_Impl;
397 mutable _Atomic_word _M_refcount;
400 static __c_locale _S_c_locale;
403 static const char _S_c_name[2];
406 static __gthread_once_t _S_once;
410 _S_initialize_once();
423 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
431 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
432 __c_locale __old = 0);
435 _S_clone_c_locale(__c_locale& __cloc)
throw();
438 _S_destroy_c_locale(__c_locale& __cloc);
441 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
448 _GLIBCXX_CONST
static const char*
449 _S_get_c_name() throw();
451#if __cplusplus < 201103L
456 operator=(
const facet&);
461 operator=(
const facet&) =
delete;
466 _M_add_reference()
const throw()
467 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
470 _M_remove_reference()
const throw()
473 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
474 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
476 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
484 const facet* _M_sso_shim(
const id*)
const;
485 const facet* _M_cow_shim(
const id*)
const;
507 friend class locale::_Impl;
509 template<
typename _Facet>
513 template<
typename _Facet>
517 template<
typename _Facet>
519 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
524 mutable size_t _M_index;
527 static _Atomic_word _S_refcount;
530 operator=(
const id&);
541 _M_id()
const throw();
553 template<
typename _Facet>
557 template<
typename _Facet>
561 template<
typename _Facet>
563 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
565 template<
typename _Cache>
566 friend struct __use_cache;
570 _Atomic_word _M_refcount;
571 const facet** _M_facets;
572 size_t _M_facets_size;
573 const facet** _M_caches;
576 static const locale::id*
const _S_id_numeric[];
577 static const locale::id*
const _S_id_collate[];
579 static const locale::id*
const _S_id_monetary[];
580 static const locale::id*
const _S_id_messages[];
581 static const locale::id*
const*
const _S_facet_categories[];
584 _M_add_reference() throw()
585 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
588 _M_remove_reference() throw()
591 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
592 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
594 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
602 _Impl(
const _Impl&,
size_t);
603 _Impl(
const char*,
size_t);
604 _Impl(
size_t)
throw();
611 operator=(const _Impl&);
619 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
620 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
625 _M_replace_categories(
const _Impl*,
category);
628 _M_replace_category(
const _Impl*,
const locale::id*
const*);
631 _M_replace_facet(
const _Impl*,
const locale::id*);
634 _M_install_facet(
const locale::id*,
const facet*);
636 template<
typename _Facet>
638 _M_init_facet(_Facet* __facet)
639 { _M_install_facet(&_Facet::id, __facet); }
641 template<
typename _Facet>
643 _M_init_facet_unchecked(_Facet* __facet)
645 __facet->_M_add_reference();
646 _M_facets[_Facet::id._M_id()] = __facet;
650 _M_install_cache(
const facet*,
size_t);
652 void _M_init_extra(facet**);
653 void _M_init_extra(
void*,
void*,
const char*,
const char*);
655#ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT
656 void _M_init_extra_ldbl128(
bool);
673 template<
typename _CharT>
687 __c_locale _M_c_locale_collate;
702 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
716 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
732 compare(
const _CharT* __lo1,
const _CharT* __hi1,
733 const _CharT* __lo2,
const _CharT* __hi2)
const
734 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
752 {
return this->do_transform(__lo, __hi); }
765 hash(
const _CharT* __lo,
const _CharT* __hi)
const
766 {
return this->do_hash(__lo, __hi); }
770 _M_compare(
const _CharT*,
const _CharT*)
const throw();
773 _M_transform(_CharT*,
const _CharT*,
size_t)
const throw();
779 { _S_destroy_c_locale(_M_c_locale_collate); }
794 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
795 const _CharT* __lo2,
const _CharT* __hi2)
const;
808 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
821 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
824 template<
typename _CharT>
830 collate<char>::_M_compare(
const char*,
const char*)
const throw();
834 collate<char>::_M_transform(
char*,
const char*,
size_t)
const throw();
836#ifdef _GLIBCXX_USE_WCHAR_T
839 collate<wchar_t>::_M_compare(
const wchar_t*,
const wchar_t*)
const throw();
843 collate<wchar_t>::_M_transform(
wchar_t*,
const wchar_t*,
size_t)
const throw();
847 template<
typename _CharT>
861 if (__builtin_strcmp(__s,
"C") != 0
862 && __builtin_strcmp(__s,
"POSIX") != 0)
864 this->_S_destroy_c_locale(this->_M_c_locale_collate);
865 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
869#if __cplusplus >= 201103L
877 ~collate_byname() { }
880_GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
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.
string name() const
Return locale name.
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 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.
static const locale & classic()
Return reference to the C locale.
locale(const locale &__base, const locale &__add, category __cat)
Construct locale with facets from another locale.
friend const _Facet & use_facet(const locale &)
Return a facet.
locale()
Default constructor.
Localization functionality base class.
facet(size_t __refs=0)
Facet constructor.
virtual ~facet()
Facet destructor.
friend bool has_facet(const locale &)
Test for the presence of a facet.
friend const _Facet & use_facet(const locale &)
Return 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.