36 #ifndef _LOCALE_CLASSES_H
37 #define _LOCALE_CLASSES_H 1
39 #pragma GCC system_header
45 _GLIBCXX_BEGIN_NAMESPACE(
std)
76 template<
typename _Facet>
80 template<typename _Facet>
84 template<typename _Cache>
85 friend struct __use_cache;
97 static const category none = 0;
98 static const category
ctype = 1L << 0;
99 static const category numeric = 1L << 1;
101 static const category time = 1L << 3;
102 static const category monetary = 1L << 4;
125 locale(const locale& __other) throw();
136 locale(const
char* __s);
150 locale(const locale& __base, const
char* __s, category __cat);
163 locale(const locale& __base, const locale& __add, category __cat);
175 template<typename _Facet>
176 locale(const locale& __other, _Facet* __f);
190 operator=(const locale& __other) throw();
204 template<typename _Facet>
206 combine(const locale& __other) const;
224 operator==(const locale& __other) const throw ();
233 operator!=(const locale& __other) const throw ()
234 {
return !(this->operator==(__other)); }
251 template<
typename _Char,
typename _Traits,
typename _Alloc>
268 global(
const locale&);
281 static _Impl* _S_classic;
284 static _Impl* _S_global;
290 static const char*
const*
const _S_categories;
302 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
305 static __gthread_once_t _S_once;
309 locale(_Impl*) throw();
315 _S_initialize_once();
318 _S_normalize_category(category);
321 _M_coalesce(const locale& __base, const locale& __add, category __cat);
339 friend class locale::_Impl;
341 mutable _Atomic_word _M_refcount;
344 static __c_locale _S_c_locale;
347 static const char _S_c_name[2];
350 static __gthread_once_t _S_once;
354 _S_initialize_once();
367 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
375 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
376 __c_locale __old = 0);
379 _S_clone_c_locale(__c_locale& __cloc);
382 _S_destroy_c_locale(__c_locale& __cloc);
394 _M_add_reference()
const throw()
395 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
398 _M_remove_reference()
const throw()
400 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
412 operator=(
const facet&);
430 friend class locale::_Impl;
432 template<
typename _Facet>
436 template<
typename _Facet>
443 mutable size_t _M_index;
446 static _Atomic_word _S_refcount;
449 operator=(
const id&);
472 template<
typename _Facet>
476 template<typename _Facet>
480 template<typename _Cache>
481 friend struct __use_cache;
485 _Atomic_word _M_refcount;
486 const facet** _M_facets;
487 size_t _M_facets_size;
488 const facet** _M_caches;
490 static const locale::
id* const _S_id_ctype[];
491 static const locale::
id* const _S_id_numeric[];
492 static const locale::
id* const _S_id_collate[];
493 static const locale::
id* const _S_id_time[];
494 static const locale::
id* const _S_id_monetary[];
495 static const locale::
id* const _S_id_messages[];
496 static const locale::
id* const* const _S_facet_categories[];
499 _M_add_reference() throw()
500 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
503 _M_remove_reference() throw()
505 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
514 _Impl(
const _Impl&,
size_t);
515 _Impl(
const char*,
size_t);
516 _Impl(
size_t) throw();
523 operator=(const _Impl&);
531 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
532 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
537 _M_replace_categories(
const _Impl*, category);
540 _M_replace_category(
const _Impl*,
const locale::id*
const*);
543 _M_replace_facet(
const _Impl*,
const locale::id*);
546 _M_install_facet(
const locale::id*,
const facet*);
548 template<
typename _Facet>
550 _M_init_facet(_Facet* __facet)
551 { _M_install_facet(&_Facet::id, __facet); }
554 _M_install_cache(
const facet*,
size_t);
569 template<
typename _Facet>
586 template<
typename _Facet>
603 template<
typename _CharT>
617 __c_locale _M_c_locale_collate;
632 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
646 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
662 compare(
const _CharT* __lo1,
const _CharT* __hi1,
663 const _CharT* __lo2,
const _CharT* __hi2)
const
664 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
682 {
return this->do_transform(__lo, __hi); }
695 hash(
const _CharT* __lo,
const _CharT* __hi)
const
696 {
return this->do_hash(__lo, __hi); }
700 _M_compare(
const _CharT*,
const _CharT*)
const;
703 _M_transform(_CharT*,
const _CharT*,
size_t)
const;
709 { _S_destroy_c_locale(_M_c_locale_collate); }
724 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
725 const _CharT* __lo2,
const _CharT* __hi2)
const;
740 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
753 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
756 template<
typename _CharT>
757 locale::id collate<_CharT>::id;
762 collate<char>::_M_compare(
const char*,
const char*)
const;
766 collate<char>::_M_transform(
char*,
const char*,
size_t)
const;
768 #ifdef _GLIBCXX_USE_WCHAR_T
771 collate<wchar_t>::_M_compare(
const wchar_t*,
const wchar_t*)
const;
775 collate<wchar_t>::_M_transform(
wchar_t*,
const wchar_t*,
size_t)
const;
779 template<
typename _CharT>
793 if (__builtin_strcmp(__s,
"C") != 0
794 && __builtin_strcmp(__s,
"POSIX") != 0)
796 this->_S_destroy_c_locale(this->_M_c_locale_collate);
797 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
806 _GLIBCXX_END_NAMESPACE
808 #ifndef _GLIBCXX_EXPORT_TEMPLATE
809 # include <bits/locale_classes.tcc>
class collate_byname [22.2.4.2].
int category
Definition of locale::category.
long hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
bool has_facet(const locale &__loc)
Test for the presence of a facet.
virtual ~collate()
Destructor.
Localization functionality base class.
ISO C++ entities toplevel namespace is std.
Facet for localized string comparison.
const _Facet & use_facet(const locale &__loc)
Return a facet.
Facet for handling message catalogs.
collate(__c_locale __cloc, size_t __refs=0)
Internal constructor. Not for general use.
_CharT char_type
Public typedefs.
Managing sequences of characters and character-like objects.
Container class for localization functionality.
collate(size_t __refs=0)
Constructor performs initialization.
static locale::id id
Numpunct facet id.
basic_string< _CharT > string_type
Public typedefs.
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.
facet(size_t __refs=0)
Facet constructor.
_CharT char_type
Public typedefs.
basic_string< _CharT > string_type
Public typedefs.