34 #ifndef _LOCALE_CLASSES_TCC
35 #define _LOCALE_CLASSES_TCC 1
37 #pragma GCC system_header
39 _GLIBCXX_BEGIN_NAMESPACE(std)
41 template<typename _Facet>
45 _M_impl =
new _Impl(*__other._M_impl, 1);
48 { _M_impl->_M_install_facet(&_Facet::id, __f); }
51 _M_impl->_M_remove_reference();
52 __throw_exception_again;
54 delete [] _M_impl->_M_names[0];
55 _M_impl->_M_names[0] = 0;
58 template<
typename _Facet>
63 _Impl* __tmp =
new _Impl(*_M_impl, 1);
66 __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
70 __tmp->_M_remove_reference();
71 __throw_exception_again;
76 template<
typename _CharT,
typename _Traits,
typename _Alloc>
83 const __collate_type& __collate = use_facet<__collate_type>(*this);
84 return (__collate.compare(__s1.
data(), __s1.
data() + __s1.
length(),
89 template<
typename _Facet>
93 const size_t __i = _Facet::id._M_id();
95 return (__i < __loc._M_impl->_M_facets_size
97 && dynamic_cast<const _Facet*>(__facets[__i]));
99 &&
static_cast<const _Facet*
>(__facets[__i]));
103 template<
typename _Facet>
107 const size_t __i = _Facet::id._M_id();
109 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
112 return dynamic_cast<const _Facet&
>(*__facets[__i]);
114 return static_cast<const _Facet&
>(*__facets[__i]);
120 template<
typename _CharT>
122 collate<_CharT>::_M_compare(
const _CharT*,
const _CharT*)
const
126 template<
typename _CharT>
128 collate<_CharT>::_M_transform(_CharT*,
const _CharT*,
size_t)
const
131 template<
typename _CharT>
134 do_compare(
const _CharT* __lo1,
const _CharT* __hi1,
135 const _CharT* __lo2,
const _CharT* __hi2)
const
142 const _CharT* __p = __one.
c_str();
143 const _CharT* __pend = __one.
data() + __one.
length();
144 const _CharT* __q = __two.
c_str();
145 const _CharT* __qend = __two.
data() + __two.
length();
152 const int __res = _M_compare(__p, __q);
158 if (__p == __pend && __q == __qend)
160 else if (__p == __pend)
162 else if (__q == __qend)
170 template<
typename _CharT>
180 const _CharT* __p = __str.
c_str();
181 const _CharT* __pend = __str.
data() + __str.
length();
183 size_t __len = (__hi - __lo) * 2;
185 _CharT* __c =
new _CharT[__len];
195 size_t __res = _M_transform(__c, __p, __len);
201 delete [] __c, __c = 0;
202 __c =
new _CharT[__len];
203 __res = _M_transform(__c, __p, __len);
218 __throw_exception_again;
226 template<
typename _CharT>
229 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const
231 unsigned long __val = 0;
232 for (; __lo < __hi; ++__lo)
234 *__lo + ((__val << 7)
235 | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
237 return static_cast<long>(__val);
243 #if _GLIBCXX_EXTERN_TEMPLATE
249 use_facet<collate<char> >(
const locale&);
253 has_facet<collate<char> >(
const locale&);
255 #ifdef _GLIBCXX_USE_WCHAR_T
260 const collate<wchar_t>&
261 use_facet<collate<wchar_t> >(
const locale&);
265 has_facet<collate<wchar_t> >(
const locale&);
269 _GLIBCXX_END_NAMESPACE
const _CharT * c_str() const
Return const pointer to null-terminated contents.
size_type length() const
Returns the number of characters in the string, not including any null-termination.
Localization functionality base class.
const _CharT * data() const
Return const pointer to contents.
bool has_facet(const locale &__loc)
Test for the presence of a facet.
const _Facet & use_facet(const locale &__loc)
Return a facet.
void push_back(_CharT __c)
Append a single character.
class collate_byname [22.2.4.2].
Container class for localization functionality.
basic_string & append(const basic_string &__str)
Append a string to this string.
Facet for localized string comparison.
Managing sequences of characters and character-like objects.
Basis for explicit traits specializations.