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(),
91 template<
typename _Facet>
95 const size_t __i = _Facet::id._M_id();
97 return (__i < __loc._M_impl->_M_facets_size
99 && dynamic_cast<const _Facet*>(__facets[__i]));
101 &&
static_cast<const _Facet*
>(__facets[__i]));
105 template<
typename _Facet>
109 const size_t __i = _Facet::id._M_id();
111 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
114 return dynamic_cast<const _Facet&
>(*__facets[__i]);
116 return static_cast<const _Facet&
>(*__facets[__i]);
122 template<
typename _CharT>
124 collate<_CharT>::_M_compare(
const _CharT*,
const _CharT*)
const throw ()
128 template<
typename _CharT>
130 collate<_CharT>::_M_transform(_CharT*,
const _CharT*,
size_t)
const throw ()
133 template<
typename _CharT>
137 const _CharT* __lo2,
const _CharT* __hi2)
const
144 const _CharT* __p = __one.
c_str();
145 const _CharT* __pend = __one.
data() + __one.
length();
146 const _CharT* __q = __two.
c_str();
147 const _CharT* __qend = __two.
data() + __two.
length();
154 const int __res = _M_compare(__p, __q);
160 if (__p == __pend && __q == __qend)
162 else if (__p == __pend)
164 else if (__q == __qend)
172 template<
typename _CharT>
182 const _CharT* __p = __str.
c_str();
183 const _CharT* __pend = __str.
data() + __str.
length();
185 size_t __len = (__hi - __lo) * 2;
187 _CharT* __c =
new _CharT[__len];
197 size_t __res = _M_transform(__c, __p, __len);
203 delete [] __c, __c = 0;
204 __c =
new _CharT[__len];
205 __res = _M_transform(__c, __p, __len);
220 __throw_exception_again;
228 template<
typename _CharT>
231 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const
233 unsigned long __val = 0;
234 for (; __lo < __hi; ++__lo)
236 *__lo + ((__val << 7)
237 | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
239 return static_cast<long>(__val);
244 #if _GLIBCXX_EXTERN_TEMPLATE
250 use_facet<collate<char> >(
const locale&);
254 has_facet<collate<char> >(
const locale&);
256 #ifdef _GLIBCXX_USE_WCHAR_T
262 use_facet<collate<wchar_t> >(
const locale&);
266 has_facet<collate<wchar_t> >(
const locale&);
270 _GLIBCXX_END_NAMESPACE_VERSION
Basis for explicit traits specializations.
void push_back(_CharT __c)
Append a single character.
Facet for localized string comparison.
Localization functionality base class.The facet class is the base class for a localization feature...
const _CharT * data() const
Return const pointer to contents.
virtual int do_compare(const _CharT *__lo1, const _CharT *__hi1, const _CharT *__lo2, const _CharT *__hi2) const
Compare two strings.
locale()
Default constructor.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
Managing sequences of characters and character-like objects.
bool has_facet(const locale &__loc)
Test for the presence of a facet.
locale combine(const locale &__other) const
Construct locale with another facet.
virtual string_type do_transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
class collate_byname [22.2.4.2].
const _Facet & use_facet(const locale &__loc)
Return a facet.
basic_string & append(const basic_string &__str)
Append a string to this string.
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.
virtual long do_hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.