36 #ifndef _LOCALE_CLASSES_H
37 #define _LOCALE_CLASSES_H 1
39 #pragma GCC system_header
45 namespace std _GLIBCXX_VISIBILITY(default)
47 _GLIBCXX_BEGIN_NAMESPACE_VERSION
79 template<
typename _Facet>
83 template<typename _Facet>
87 template<typename _Cache>
88 friend struct __use_cache;
128 locale(const locale& __other) throw();
139 locale(const
char* __s);
166 locale(const locale& __base, const locale& __add,
category __cat);
178 template<typename _Facet>
179 locale(const locale& __other, _Facet* __f);
193 operator=(const locale& __other) throw();
207 template<typename _Facet>
209 combine(const locale& __other) const;
227 operator==(const locale& __other) const throw();
236 operator!=(const locale& __other) const throw()
254 template<
typename _Char,
typename _Traits,
typename _Alloc>
284 static _Impl* _S_classic;
287 static _Impl* _S_global;
293 static const char*
const*
const _S_categories;
305 enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES };
308 static __gthread_once_t _S_once;
318 _S_initialize_once() throw();
343 friend class locale::_Impl;
345 mutable _Atomic_word _M_refcount;
348 static __c_locale _S_c_locale;
351 static const char _S_c_name[2];
354 static __gthread_once_t _S_once;
358 _S_initialize_once();
371 facet(
size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
379 _S_create_c_locale(__c_locale& __cloc,
const char* __s,
380 __c_locale __old = 0);
383 _S_clone_c_locale(__c_locale& __cloc)
throw();
386 _S_destroy_c_locale(__c_locale& __cloc);
389 _S_lc_ctype_c_locale(__c_locale __cloc,
const char* __s);
396 _GLIBCXX_CONST
static const char*
397 _S_get_c_name() throw();
401 _M_add_reference() const throw()
402 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
405 _M_remove_reference()
const throw()
408 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
409 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
411 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
441 friend class locale::_Impl;
443 template<
typename _Facet>
447 template<
typename _Facet>
454 mutable size_t _M_index;
457 static _Atomic_word _S_refcount;
471 _M_id()
const throw();
483 template<
typename _Facet>
487 template<typename _Facet>
491 template<typename _Cache>
492 friend struct __use_cache;
496 _Atomic_word _M_refcount;
497 const facet** _M_facets;
498 size_t _M_facets_size;
499 const facet** _M_caches;
501 static const locale::
id* const _S_id_ctype[];
502 static const locale::
id* const _S_id_numeric[];
503 static const locale::
id* const _S_id_collate[];
504 static const locale::
id* const _S_id_time[];
505 static const locale::
id* const _S_id_monetary[];
506 static const locale::
id* const _S_id_messages[];
507 static const locale::
id* const* const _S_facet_categories[];
510 _M_add_reference() throw()
511 { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
514 _M_remove_reference() throw()
517 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
518 if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1)
520 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
528 _Impl(
const _Impl&,
size_t);
529 _Impl(
const char*,
size_t);
530 _Impl(
size_t) throw();
537 operator=(const _Impl&);
545 for (
size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
546 __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
551 _M_replace_categories(
const _Impl*, category);
554 _M_replace_category(
const _Impl*,
const locale::id*
const*);
557 _M_replace_facet(
const _Impl*,
const locale::id*);
560 _M_install_facet(
const locale::id*,
const facet*);
562 template<
typename _Facet>
564 _M_init_facet(_Facet* __facet)
565 { _M_install_facet(&_Facet::id, __facet); }
568 _M_install_cache(
const facet*,
size_t);
583 template<
typename _Facet>
600 template<
typename _Facet>
617 template<
typename _CharT>
631 __c_locale _M_c_locale_collate;
646 : facet(__refs), _M_c_locale_collate(_S_get_c_locale())
660 : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc))
676 compare(
const _CharT* __lo1,
const _CharT* __hi1,
677 const _CharT* __lo2,
const _CharT* __hi2)
const
678 {
return this->do_compare(__lo1, __hi1, __lo2, __hi2); }
695 transform(
const _CharT* __lo,
const _CharT* __hi)
const
696 {
return this->do_transform(__lo, __hi); }
709 hash(
const _CharT* __lo,
const _CharT* __hi)
const
710 {
return this->do_hash(__lo, __hi); }
714 _M_compare(
const _CharT*,
const _CharT*)
const throw();
717 _M_transform(_CharT*, const _CharT*,
size_t) const throw();
723 { _S_destroy_c_locale(_M_c_locale_collate); }
738 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
739 const _CharT* __lo2,
const _CharT* __hi2)
const;
754 do_transform(
const _CharT* __lo,
const _CharT* __hi)
const;
767 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const;
770 template<
typename _CharT>
771 locale::id collate<_CharT>::id;
776 collate<char>::_M_compare(
const char*,
const char*)
const throw();
780 collate<
char>::_M_transform(
char*, const
char*,
size_t) const throw();
782 #ifdef _GLIBCXX_USE_WCHAR_T
785 collate<wchar_t>::_M_compare(
const wchar_t*,
const wchar_t*)
const throw();
789 collate<
wchar_t>::_M_transform(
wchar_t*, const
wchar_t*,
size_t) const throw();
793 template<
typename _CharT>
807 if (__builtin_strcmp(__s,
"C") != 0
808 && __builtin_strcmp(__s,
"POSIX") != 0)
810 this->_S_destroy_c_locale(this->_M_c_locale_collate);
811 this->_S_create_c_locale(this->_M_c_locale_collate, __s);
820 _GLIBCXX_END_NAMESPACE_VERSION