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;
98 static const category
none = 0;
99 static const category
ctype = 1L << 0;
102 static const category
time = 1L << 3;
105 static const category
all = (ctype | numeric | collate |
153 #if __cplusplus >= 201103L 178 :
locale(__base, __s.c_str(), __cat) { }
205 template<
typename _Facet>
234 template<
typename _Facet>
243 _GLIBCXX_DEFAULT_ABI_TAG
282 template<
typename _Char,
typename _Traits,
typename _Alloc>
312 static _Impl* _S_classic;
315 static _Impl* _S_global;
321 static const char*
const*
const _S_categories;
333 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
336 static __gthread_once_t _S_once;
346 _S_initialize_once()
throw();
349 _S_normalize_category(category);
352 _M_coalesce(
const locale& __base,
const locale& __add, category __cat);
354 #if _GLIBCXX_USE_CXX11_ABI 355 static const id*
const _S_twinned_facets[];
375 friend class locale::_Impl;
377 mutable _Atomic_word _M_refcount;
380 static __c_locale _S_c_locale;
383 static const char _S_c_name[2];
386 static __gthread_once_t _S_once;
390 _S_initialize_once();
403 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
411 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
412 __c_locale __old = 0);
415 _S_clone_c_locale(__c_locale& __cloc)
throw();
418 _S_destroy_c_locale(__c_locale& __cloc);
421 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
428 _GLIBCXX_CONST
static const char*
429 _S_get_c_name()
throw();
433 _M_add_reference()
const throw()
434 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
437 _M_remove_reference()
const throw()
440 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
441 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
443 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
456 const facet* _M_sso_shim(
const id*)
const;
457 const facet* _M_cow_shim(
const id*)
const;
479 friend class locale::_Impl;
481 template<
typename _Facet>
485 template<
typename _Facet>
492 mutable size_t _M_index;
495 static _Atomic_word _S_refcount;
509 _M_id()
const throw();
521 template<
typename _Facet>
525 template<
typename _Facet>
529 template<
typename _Cache>
530 friend struct __use_cache;
534 _Atomic_word _M_refcount;
535 const facet** _M_facets;
536 size_t _M_facets_size;
537 const facet** _M_caches;
540 static const locale::id*
const _S_id_numeric[];
541 static const locale::id*
const _S_id_collate[];
543 static const locale::id*
const _S_id_monetary[];
544 static const locale::id*
const _S_id_messages[];
545 static const locale::id*
const*
const _S_facet_categories[];
548 _M_add_reference()
throw()
549 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
552 _M_remove_reference()
throw()
555 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
556 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
558 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
566 _Impl(
const _Impl&,
size_t);
567 _Impl(
const char*,
size_t);
568 _Impl(
size_t)
throw();
583 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
584 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
589 _M_replace_categories(
const _Impl*, category);
592 _M_replace_category(
const _Impl*,
const locale::id*
const*);
595 _M_replace_facet(
const _Impl*,
const locale::id*);
600 template<
typename _Facet>
602 _M_init_facet(_Facet* __facet)
603 { _M_install_facet(&_Facet::id, __facet); }
605 template<
typename _Facet>
607 _M_init_facet_unchecked(_Facet* __facet)
609 __facet->_M_add_reference();
610 _M_facets[_Facet::id._M_id()] = __facet;
614 _M_install_cache(
const facet*,
size_t);
616 void _M_init_extra(
facet**);
617 void _M_init_extra(
void*,
void*,
const char*,
const char*);
633 template<
typename _CharT>
647 __c_locale _M_c_locale_collate;
662 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
676 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
692 compare(
const _CharT* __lo1,
const _CharT* __hi1,
693 const _CharT* __lo2,
const _CharT* __hi2)
const 694 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
712 {
return this->do_transform(__lo, __hi); }
725 hash(
const _CharT* __lo,
const _CharT* __hi)
const 726 {
return this->do_hash(__lo, __hi); }
730 _M_compare(
const _CharT*,
const _CharT*)
const throw();
733 _M_transform(_CharT*,
const _CharT*,
size_t)
const throw();
739 { _S_destroy_c_locale(_M_c_locale_collate); }
754 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
755 const _CharT* __lo2,
const _CharT* __hi2)
const;
768 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
781 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
784 template<
typename _CharT>
796 #ifdef _GLIBCXX_USE_WCHAR_T 807 template<
typename _CharT>
819 : collate<_CharT>(__refs)
821 if (__builtin_strcmp(__s,
"C") != 0
822 && __builtin_strcmp(__s,
"POSIX") != 0)
824 this->_S_destroy_c_locale(this->_M_c_locale_collate);
825 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
829 #if __cplusplus >= 201103L 840 _GLIBCXX_END_NAMESPACE_VERSION
locale(const std::string &__s)
Named locale constructor.
facet(size_t __refs=0)
Facet constructor.
basic_string< _CharT > string_type
Public typedefs.
static const category messages
Category values.
_CharT char_type
Public typedefs.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
static locale global(const locale &__loc)
Set global locale.
const locale & operator=(const locale &__other)
Assignment operator.
basic_string< _CharT > string_type
Public typedefs.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
static const category all
Category values.
bool operator!=(const locale &__other) const
Locale inequality.
class collate_byname [22.2.4.2].
static const category time
Category values.
bool operator==(const locale &__other) const
Locale equality.
Facet ID class.The ID class provides facets with an index used to identify them. Every facet class mu...
static const locale & classic()
Return reference to the C locale.
_CharT char_type
Public typedefs.
ISO C++ entities toplevel namespace is std.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
int category
Definition of locale::category.
_GLIBCXX_DEFAULT_ABI_TAG string name() const
Return locale name.
Primary class template ctype facet.This template class defines classification and conversion function...
long hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
Facet for localized string comparison.
Localization functionality base class.The facet class is the base class for a localization feature...
locale()
Default constructor.
static const category numeric
Category values.
collate(size_t __refs=0)
Constructor performs initialization.
~locale()
Locale destructor.
Primary class template messages.This facet encapsulates the code to retrieve messages from message ca...
locale(const locale &__base, const std::string &__s, category __cat)
Construct locale with facets from another locale.
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...
collate(__c_locale __cloc, size_t __refs=0)
Internal constructor. Not for general use.
static locale::id id
Numpunct facet id.
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.
static const category none
Category values.
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.
static const category monetary
Category values.
locale combine(const locale &__other) const
Construct locale with another facet.
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...