34 #ifndef _LOCALE_CLASSES_TCC 35 #define _LOCALE_CLASSES_TCC 1 37 #pragma GCC system_header 39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 template<
typename _Facet>
47 _M_impl =
new _Impl(*__other._M_impl, 1);
50 { _M_impl->_M_install_facet(&_Facet::id, __f); }
53 _M_impl->_M_remove_reference();
54 __throw_exception_again;
56 delete [] _M_impl->_M_names[0];
57 _M_impl->_M_names[0] = 0;
60 template<
typename _Facet>
65 _Impl* __tmp =
new _Impl(*_M_impl, 1);
68 __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
72 __tmp->_M_remove_reference();
73 __throw_exception_again;
78 template<
typename _CharT,
typename _Traits,
typename _Alloc>
85 const __collate_type& __collate = use_facet<__collate_type>(*this);
86 return (__collate.compare(__s1.
data(), __s1.
data() + __s1.
length(),
90 #pragma GCC diagnostic push 91 #pragma GCC diagnostic ignored "-Wc++17-extensions" 92 template<
typename _Facet>
94 __try_use_facet(
const locale& __loc) _GLIBCXX_NOTHROW
96 const size_t __i = _Facet::id._M_id();
97 const locale::facet** __facets = __loc._M_impl->_M_facets;
101 #define _GLIBCXX_STD_FACET(...) \ 102 if _GLIBCXX_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \ 103 return static_cast<const _Facet*>(__facets[__i]) 105 _GLIBCXX_STD_FACET(ctype<char>);
106 _GLIBCXX_STD_FACET(num_get<char>);
107 _GLIBCXX_STD_FACET(num_put<char>);
108 _GLIBCXX_STD_FACET(codecvt<char, char, mbstate_t>);
109 _GLIBCXX_STD_FACET(collate<char>);
110 _GLIBCXX_STD_FACET(moneypunct<char>);
111 _GLIBCXX_STD_FACET(moneypunct<char, true>);
112 _GLIBCXX_STD_FACET(money_get<char>);
113 _GLIBCXX_STD_FACET(money_put<char>);
114 _GLIBCXX_STD_FACET(numpunct<char>);
115 _GLIBCXX_STD_FACET(time_get<char>);
116 _GLIBCXX_STD_FACET(time_put<char>);
117 _GLIBCXX_STD_FACET(messages<char>);
119 #ifdef _GLIBCXX_USE_WCHAR_T 120 _GLIBCXX_STD_FACET(ctype<wchar_t>);
121 _GLIBCXX_STD_FACET(num_get<wchar_t>);
122 _GLIBCXX_STD_FACET(num_put<wchar_t>);
123 _GLIBCXX_STD_FACET(codecvt<wchar_t, char, mbstate_t>);
124 _GLIBCXX_STD_FACET(collate<wchar_t>);
125 _GLIBCXX_STD_FACET(moneypunct<wchar_t>);
126 _GLIBCXX_STD_FACET(moneypunct<wchar_t, true>);
127 _GLIBCXX_STD_FACET(money_get<wchar_t>);
128 _GLIBCXX_STD_FACET(money_put<wchar_t>);
129 _GLIBCXX_STD_FACET(numpunct<wchar_t>);
130 _GLIBCXX_STD_FACET(time_get<wchar_t>);
131 _GLIBCXX_STD_FACET(time_put<wchar_t>);
132 _GLIBCXX_STD_FACET(messages<wchar_t>);
134 #if __cplusplus >= 201103L 135 _GLIBCXX_STD_FACET(codecvt<char16_t, char, mbstate_t>);
136 _GLIBCXX_STD_FACET(codecvt<char32_t, char, mbstate_t>);
139 #undef _GLIBCXX_STD_FACET 141 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
145 return dynamic_cast<const _Facet*
>(__facets[__i]);
147 return static_cast<const _Facet*
>(__facets[__i]);
150 #pragma GCC diagnostic pop 164 template<
typename _Facet>
169 #if __cplusplus >= 201103L 171 "template argument must be derived from locale::facet");
173 (void) static_cast<const _Facet*>(static_cast<const locale::facet*>(0));
175 return std::__try_use_facet<_Facet>(__loc) != 0;
192 #pragma GCC diagnostic push 193 #pragma GCC diagnostic ignored "-Wdangling-reference" 194 template<
typename _Facet>
199 #if __cplusplus >= 201103L 201 "template argument must be derived from locale::facet");
203 (void) static_cast<const _Facet*>(static_cast<const locale::facet*>(0));
205 if (
const _Facet* __f = std::__try_use_facet<_Facet>(__loc))
209 #pragma GCC diagnostic pop 213 template<
typename _CharT>
215 collate<_CharT>::_M_compare(
const _CharT*,
const _CharT*)
const throw ()
219 template<
typename _CharT>
221 collate<_CharT>::_M_transform(_CharT*,
const _CharT*,
size_t)
const throw ()
224 template<
typename _CharT>
228 const _CharT* __lo2,
const _CharT* __hi2)
const 235 const _CharT* __p = __one.
c_str();
236 const _CharT* __pend = __one.
data() + __one.
length();
237 const _CharT* __q = __two.
c_str();
238 const _CharT* __qend = __two.
data() + __two.
length();
245 const int __res = _M_compare(__p, __q);
251 if (__p == __pend && __q == __qend)
253 else if (__p == __pend)
255 else if (__q == __qend)
263 template<
typename _CharT>
273 const _CharT* __p = __str.
c_str();
274 const _CharT* __pend = __str.
data() + __str.
length();
276 size_t __len = (__hi - __lo) * 2;
278 _CharT* __c =
new _CharT[__len];
288 size_t __res = _M_transform(__c, __p, __len);
294 delete [] __c, __c = 0;
295 __c =
new _CharT[__len];
296 __res = _M_transform(__c, __p, __len);
311 __throw_exception_again;
319 template<
typename _CharT>
322 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const 324 unsigned long __val = 0;
325 for (; __lo < __hi; ++__lo)
327 *__lo + ((__val << 7)
328 | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
330 return static_cast<long>(__val);
335 #if _GLIBCXX_EXTERN_TEMPLATE 341 __try_use_facet<collate<char> >(
const locale&) _GLIBCXX_NOTHROW;
345 use_facet<collate<char> >(
const locale&);
349 has_facet<collate<char> >(
const locale&);
351 #ifdef _GLIBCXX_USE_WCHAR_T 357 __try_use_facet<collate<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
361 use_facet<collate<wchar_t> >(
const locale&);
365 has_facet<collate<wchar_t> >(
const locale&);
369 _GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
virtual long do_hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
void push_back(_CharT __c)
Append a single character.
Localization functionality base class.The facet class is the base class for a localization feature...
Managing sequences of characters and character-like objects.
virtual string_type do_transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
class collate_byname [22.2.4.2].
const _CharT * data() const noexcept
Return const pointer to contents.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.
locale()
Default constructor.
bool has_facet(const locale &__loc)
Test for the presence of a facet.has_facet tests the locale argument for the presence of the facet ty...
const _Facet & use_facet(const locale &__loc)
Return a facet.use_facet looks for and returns a reference to a facet of type Facet where Facet is th...
Basis for explicit traits specializations.
basic_string & append(const basic_string &__str)
Append a string to this string.
virtual int do_compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
Facet for localized string comparison.
locale combine(const locale &__other) const
Construct locale with another facet.