34 #ifndef _LOCALE_CLASSES_H 35 #define _LOCALE_CLASSES_H 1 37 #pragma GCC system_header 43 #ifdef __glibcxx_text_encoding 47 namespace 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;
106 static const category
none = 0;
107 static const category
ctype = 1L << 0;
110 static const category
time = 1L << 3;
113 static const category
all = (ctype | numeric | collate |
161 #if __cplusplus >= 201103L 186 :
locale(__base, __s.c_str(), __cat) { }
213 template<
typename _Facet>
242 template<
typename _Facet>
252 _GLIBCXX_NODISCARD _GLIBCXX_DEFAULT_ABI_TAG
256 #ifdef __glibcxx_text_encoding 257 # if __CHAR_BIT__ == 8 262 encoding()
const =
delete;
277 #if __cpp_impl_three_way_comparison < 201907L 286 operator!=(
const locale& __other)
const throw()
305 template<
typename _Char,
typename _Traits,
typename _Alloc>
337 static _Impl* _S_classic;
340 static _Impl* _S_global;
346 static const char*
const*
const _S_categories;
358 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
361 static __gthread_once_t _S_once;
371 _S_initialize_once()
throw();
374 _S_normalize_category(category);
377 _M_coalesce(
const locale& __base,
const locale& __add, category __cat);
379 #if _GLIBCXX_USE_CXX11_ABI 380 static const id*
const _S_twinned_facets[];
400 friend class locale::_Impl;
402 mutable _Atomic_word _M_refcount;
405 static __c_locale _S_c_locale;
408 static const char _S_c_name[2];
411 static __gthread_once_t _S_once;
415 _S_initialize_once();
428 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
436 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
437 __c_locale __old = 0);
440 _S_clone_c_locale(__c_locale& __cloc)
throw();
443 _S_destroy_c_locale(__c_locale& __cloc);
446 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
453 _GLIBCXX_CONST
static const char*
454 _S_get_c_name()
throw();
456 #if __cplusplus < 201103L 471 _M_add_reference()
const throw()
472 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
475 _M_remove_reference()
const throw()
478 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
479 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
481 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
489 const facet* _M_sso_shim(
const id*)
const;
490 const facet* _M_cow_shim(
const id*)
const;
512 friend class locale::_Impl;
514 template<
typename _Facet>
518 template<
typename _Facet>
522 template<
typename _Facet>
524 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
529 mutable size_t _M_index;
532 static _Atomic_word _S_refcount;
546 _M_id()
const throw();
558 template<
typename _Facet>
562 template<
typename _Facet>
566 template<
typename _Facet>
568 __try_use_facet(
const locale&) _GLIBCXX_NOTHROW;
570 template<
typename _Cache>
571 friend struct __use_cache;
575 _Atomic_word _M_refcount;
576 const facet** _M_facets;
577 size_t _M_facets_size;
578 const facet** _M_caches;
581 static const locale::id*
const _S_id_numeric[];
582 static const locale::id*
const _S_id_collate[];
584 static const locale::id*
const _S_id_monetary[];
585 static const locale::id*
const _S_id_messages[];
586 static const locale::id*
const*
const _S_facet_categories[];
589 _M_add_reference()
throw()
590 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
593 _M_remove_reference()
throw()
596 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
597 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
599 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
607 _Impl(
const _Impl&,
size_t);
608 _Impl(
const char*,
size_t);
609 _Impl(
size_t)
throw();
624 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
625 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
630 _M_replace_categories(
const _Impl*, category);
633 _M_replace_category(
const _Impl*,
const locale::id*
const*);
636 _M_replace_facet(
const _Impl*,
const locale::id*);
641 template<
typename _Facet>
643 _M_init_facet(_Facet* __facet)
644 { _M_install_facet(&_Facet::id, __facet); }
646 template<
typename _Facet>
648 _M_init_facet_unchecked(_Facet* __facet)
650 __facet->_M_add_reference();
651 _M_facets[_Facet::id._M_id()] = __facet;
655 _M_install_cache(
const facet*,
size_t);
657 void _M_init_extra(
facet**);
658 void _M_init_extra(
void*,
void*,
const char*,
const char*);
660 #ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 661 void _M_init_extra_ldbl128(
bool);
678 template<
typename _CharT>
692 __c_locale _M_c_locale_collate;
707 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
721 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
737 compare(
const _CharT* __lo1,
const _CharT* __hi1,
738 const _CharT* __lo2,
const _CharT* __hi2)
const 739 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
757 {
return this->do_transform(__lo, __hi); }
770 hash(
const _CharT* __lo,
const _CharT* __hi)
const 771 {
return this->do_hash(__lo, __hi); }
775 _M_compare(
const _CharT*,
const _CharT*)
const throw();
778 _M_transform(_CharT*,
const _CharT*,
size_t)
const throw();
784 { _S_destroy_c_locale(_M_c_locale_collate); }
799 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
800 const _CharT* __lo2,
const _CharT* __hi2)
const;
813 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
826 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
829 template<
typename _CharT>
841 #ifdef _GLIBCXX_USE_WCHAR_T 852 template<
typename _CharT>
864 : collate<_CharT>(__refs)
866 if (__builtin_strcmp(__s,
"C") != 0
867 && __builtin_strcmp(__s,
"POSIX") != 0)
869 this->_S_destroy_c_locale(this->_M_c_locale_collate);
870 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
874 #if __cplusplus >= 201103L 885 _GLIBCXX_END_NAMESPACE_VERSION
Primary class template messages.This facet encapsulates the code to retrieve messages from message ca...
static locale global(const locale &__loc)
Set global locale.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.
virtual ~collate()
Destructor.
locale(const std::string &__s)
Named locale constructor.
friend const _Facet & use_facet(const locale &)
Return a facet.use_facet looks for and returns a reference to a facet of type Facet where Facet is th...
friend bool has_facet(const locale &)
Test for the presence of a facet.has_facet tests the locale argument for the presence of the facet ty...
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...
int compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
string name() const
Return locale name.
ISO C++ entities toplevel namespace is std.
basic_string< _CharT > string_type
Public typedefs.
bool operator==(const locale &__other) const
Locale equality.
long hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
static const category time
Category values.
Facet for localized string comparison.
Localization functionality base class.The facet class is the base class for a localization feature...
string_type transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
constexpr _Iterator __base(_Iterator __it)
collate(size_t __refs=0)
Constructor performs initialization.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
static locale::id id
Numpunct facet id.
static const category messages
Category values.
_CharT char_type
Public typedefs.
int category
Definition of locale::category.
static const locale & classic()
Return reference to the C locale.
static const category none
Category values.
const locale & operator=(const locale &__other)
Assignment operator.
locale()
Default constructor.
locale combine(const locale &__other) const
Construct locale with another facet.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string< _CharT > string_type
Public typedefs.
_CharT char_type
Public typedefs.
~locale()
Locale destructor.
Primary class template ctype facet.This template class defines classification and conversion function...
facet(size_t __refs=0)
Facet constructor.
static const category monetary
Category values.
class collate_byname [22.2.4.2].
locale(const locale &__base, const std::string &__s, category __cat)
Construct locale with facets from another locale.
static const category numeric
Category values.
collate(__c_locale __cloc, size_t __refs=0)
Internal constructor. Not for general use.