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(),
101 template<
typename _Facet>
105 const size_t __i = _Facet::id._M_id();
107 return (__i < __loc._M_impl->_M_facets_size
109 && dynamic_cast<const _Facet*>(__facets[__i]));
111 &&
static_cast<const _Facet*
>(__facets[__i]));
128 template<
typename _Facet>
132 const size_t __i = _Facet::id._M_id();
134 if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
137 return dynamic_cast<const _Facet&
>(*__facets[__i]);
139 return static_cast<const _Facet&
>(*__facets[__i]);
145 template<
typename _CharT>
147 collate<_CharT>::_M_compare(
const _CharT*,
const _CharT*)
const throw ()
151 template<
typename _CharT>
153 collate<_CharT>::_M_transform(_CharT*,
const _CharT*,
size_t)
const throw ()
156 template<
typename _CharT>
160 const _CharT* __lo2,
const _CharT* __hi2)
const
167 const _CharT* __p = __one.
c_str();
168 const _CharT* __pend = __one.
data() + __one.
length();
169 const _CharT* __q = __two.
c_str();
170 const _CharT* __qend = __two.
data() + __two.
length();
177 const int __res = _M_compare(__p, __q);
183 if (__p == __pend && __q == __qend)
185 else if (__p == __pend)
187 else if (__q == __qend)
195 template<
typename _CharT>
205 const _CharT* __p = __str.
c_str();
206 const _CharT* __pend = __str.
data() + __str.
length();
208 size_t __len = (__hi - __lo) * 2;
210 _CharT* __c =
new _CharT[__len];
220 size_t __res = _M_transform(__c, __p, __len);
226 delete [] __c, __c = 0;
227 __c =
new _CharT[__len];
228 __res = _M_transform(__c, __p, __len);
243 __throw_exception_again;
251 template<
typename _CharT>
254 do_hash(
const _CharT* __lo,
const _CharT* __hi)
const
256 unsigned long __val = 0;
257 for (; __lo < __hi; ++__lo)
259 *__lo + ((__val << 7)
260 | (__val >> (__gnu_cxx::__numeric_traits<unsigned long>::
262 return static_cast<long>(__val);
267 #if _GLIBCXX_EXTERN_TEMPLATE
273 use_facet<collate<char> >(
const locale&);
277 has_facet<collate<char> >(
const locale&);
279 #ifdef _GLIBCXX_USE_WCHAR_T
285 use_facet<collate<wchar_t> >(
const locale&);
289 has_facet<collate<wchar_t> >(
const locale&);
293 _GLIBCXX_END_NAMESPACE_VERSION
Localization functionality base class.The facet class is the base class for a localization feature...
void push_back(_CharT __c)
Append a single character.
virtual long do_hash(const _CharT *__lo, const _CharT *__hi) const
Return hash of a string.
const _CharT * c_str() const _GLIBCXX_NOEXCEPT
Return const pointer to null-terminated contents.
bool operator()(const basic_string< _Char, _Traits, _Alloc > &__s1, const basic_string< _Char, _Traits, _Alloc > &__s2) const
Compare two strings according to collate.
basic_string & append(const basic_string &__str)
Append a string to this string.
const _CharT * data() const _GLIBCXX_NOEXCEPT
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.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
size_type length() const _GLIBCXX_NOEXCEPT
Returns the number of characters in the string, not including any null-termination.
class collate_byname [22.2.4.2].
virtual string_type do_transform(const _CharT *__lo, const _CharT *__hi) const
Transform string to comparable form.
Managing sequences of characters and character-like objects.
Basis for explicit traits specializations.
locale()
Default constructor.
const _Facet & use_facet(const locale &__loc)
Return a facet.
locale combine(const locale &__other) const
Construct locale with another facet.
Facet for localized string comparison.
bool has_facet(const locale &__loc)
Test for the presence of a facet.