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(),
102 template<
typename _Facet>
106 const size_t __i = _Facet::id._M_id();
108 return (__i < __loc._M_impl->_M_facets_size
110 && dynamic_cast<const _Facet*>(__facets[__i]));
112 &&
static_cast<const _Facet*
>(__facets[__i]));
130 template<
typename _Facet>
134 const size_t __i = _Facet::id._M_id();
136 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
139 return dynamic_cast<const _Facet&
>(*__facets[__i]);
141 return static_cast<const _Facet&
>(*__facets[__i]);
147 template<
typename _CharT>
149 collate<_CharT>::_M_compare(
const _CharT*,
const _CharT*)
const throw ()
153 template<
typename _CharT>
155 collate<_CharT>::_M_transform(_CharT*,
const _CharT*,
size_t)
const throw ()
158 template<
typename _CharT>
162 const _CharT* __lo2,
const _CharT* __hi2)
const
169 const _CharT* __p = __one.
c_str();
170 const _CharT* __pend = __one.
data() + __one.
length();
171 const _CharT* __q = __two.
c_str();
172 const _CharT* __qend = __two.
data() + __two.
length();
179 const int __res = _M_compare(__p, __q);
185 if (__p == __pend && __q == __qend)
187 else if (__p == __pend)
189 else if (__q == __qend)
197 template<
typename _CharT>
207 const _CharT* __p = __str.
c_str();
208 const _CharT* __pend = __str.
data() + __str.
length();
210 size_t __len = (__hi - __lo) * 2;
212 _CharT* __c =
new _CharT[__len];
222 size_t __res = _M_transform(__c, __p, __len);
228 delete [] __c, __c = 0;
229 __c =
new _CharT[__len];
230 __res = _M_transform(__c, __p, __len);
245 __throw_exception_again;
253 template<
typename _CharT>
256 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const
258 unsigned long __val = 0;
259 for (; __lo < __hi; ++__lo)
261 *__lo + ((__val << 7)
262 | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
264 return static_cast<long>(__val);
269 #if _GLIBCXX_EXTERN_TEMPLATE
275 use_facet<collate<char> >(
const locale&);
279 has_facet<collate<char> >(
const locale&);
281 #ifdef _GLIBCXX_USE_WCHAR_T
287 use_facet<collate<wchar_t> >(
const locale&);
291 has_facet<collate<wchar_t> >(
const locale&);
295 _GLIBCXX_END_NAMESPACE_VERSION
const _CharT * data() const noexcept
Return const pointer to contents.
locale()
Default constructor.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
class collate_byname [22.2.4.2].
void push_back(_CharT __c)
Append a single character.
Localization functionality base class.The facet class is the base class for a localization feature...
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...
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...
Facet for localized string comparison.
virtual long do_hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
virtual string_type do_transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
virtual int do_compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
Basis for explicit traits specializations.
basic_string & append(const basic_string &__str)
Append a string to this string.
Managing sequences of characters and character-like objects.
locale combine(const locale &__other) const
Construct locale with another facet.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.