williamr@2
|
1 |
/*
|
williamr@4
|
2 |
* Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
williamr@2
|
3 |
*
|
williamr@2
|
4 |
* Copyright (c) 1999
|
williamr@2
|
5 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@2
|
6 |
*
|
williamr@4
|
7 |
* Copyright (c) 1999
|
williamr@2
|
8 |
* Boris Fomitchev
|
williamr@2
|
9 |
*
|
williamr@2
|
10 |
* This material is provided "as is", with absolutely no warranty expressed
|
williamr@2
|
11 |
* or implied. Any use is at your own risk.
|
williamr@2
|
12 |
*
|
williamr@4
|
13 |
* Permission to use or copy this software for any purpose is hereby granted
|
williamr@2
|
14 |
* without fee, provided the above notices are retained on all copies.
|
williamr@2
|
15 |
* Permission to modify the code and to distribute modified code is granted,
|
williamr@2
|
16 |
* provided the above notices are retained, and a notice that the code was
|
williamr@2
|
17 |
* modified is included with the above copyright notice.
|
williamr@2
|
18 |
*
|
williamr@4
|
19 |
*/
|
williamr@2
|
20 |
// WARNING: This is an internal header file, included by other C++
|
williamr@2
|
21 |
// standard library headers. You should not attempt to use this header
|
williamr@2
|
22 |
// file directly.
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#ifndef _STLP_INTERNAL_COLLATE_H
|
williamr@2
|
25 |
#define _STLP_INTERNAL_COLLATE_H
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#ifndef _STLP_C_LOCALE_H
|
williamr@2
|
28 |
# include <stl/c_locale.h>
|
williamr@2
|
29 |
#endif
|
williamr@2
|
30 |
|
williamr@2
|
31 |
#ifndef _STLP_INTERNAL_LOCALE_H
|
williamr@2
|
32 |
# include <stl/_locale.h>
|
williamr@2
|
33 |
#endif
|
williamr@2
|
34 |
|
williamr@4
|
35 |
#ifndef _STLP_INTERNAL_STRING_H
|
williamr@2
|
36 |
# include <stl/_string.h>
|
williamr@2
|
37 |
#endif
|
williamr@2
|
38 |
|
williamr@2
|
39 |
_STLP_BEGIN_NAMESPACE
|
williamr@2
|
40 |
|
williamr@2
|
41 |
template <class _CharT> class collate {};
|
williamr@2
|
42 |
template <class _CharT> class collate_byname {};
|
williamr@2
|
43 |
|
williamr@2
|
44 |
_STLP_TEMPLATE_NULL
|
williamr@2
|
45 |
class _STLP_CLASS_DECLSPEC collate<char> : public locale::facet
|
williamr@2
|
46 |
{
|
williamr@4
|
47 |
friend class _Locale_impl;
|
williamr@4
|
48 |
|
williamr@2
|
49 |
public:
|
williamr@2
|
50 |
typedef char char_type;
|
williamr@2
|
51 |
typedef string string_type;
|
williamr@2
|
52 |
|
williamr@4
|
53 |
explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
|
williamr@2
|
54 |
|
williamr@2
|
55 |
int compare(const char* __low1, const char* __high1,
|
williamr@2
|
56 |
const char* __low2, const char* __high2) const {
|
williamr@2
|
57 |
return do_compare( __low1, __high1, __low2, __high2);
|
williamr@2
|
58 |
}
|
williamr@2
|
59 |
|
williamr@2
|
60 |
string_type transform(const char* __low, const char* __high) const {
|
williamr@2
|
61 |
return do_transform(__low, __high);
|
williamr@2
|
62 |
}
|
williamr@2
|
63 |
|
williamr@2
|
64 |
long hash(const char* __low, const char* __high) const
|
williamr@2
|
65 |
{ return do_hash(__low, __high); }
|
williamr@2
|
66 |
|
williamr@4
|
67 |
#if defined(__SYMBIAN32__WSD__)
|
williamr@4
|
68 |
static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
|
williamr@4
|
69 |
#elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
|
williamr@4
|
70 |
static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
|
williamr@4
|
71 |
static locale::id id;
|
williamr@2
|
72 |
#else
|
williamr@4
|
73 |
// NOTE: Symbian doesn't support exporting static data.
|
williamr@4
|
74 |
// Users of this class should use GetFacetLocaleId() to access the data member id
|
williamr@4
|
75 |
static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
|
williamr@2
|
76 |
#endif
|
williamr@2
|
77 |
|
williamr@2
|
78 |
protected:
|
williamr@4
|
79 |
_STLP_DECLSPEC ~collate();
|
williamr@2
|
80 |
|
williamr@4
|
81 |
_STLP_DECLSPEC virtual int do_compare(const char*, const char*,
|
williamr@2
|
82 |
const char*, const char*) const;
|
williamr@4
|
83 |
_STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
|
williamr@4
|
84 |
_STLP_DECLSPEC virtual long do_hash(const char*, const char*) const;
|
williamr@2
|
85 |
private:
|
williamr@2
|
86 |
collate(const collate<char>&);
|
williamr@4
|
87 |
collate<char>& operator =(const collate<char>&);
|
williamr@2
|
88 |
};
|
williamr@2
|
89 |
|
williamr@2
|
90 |
# ifndef _STLP_NO_WCHAR_T
|
williamr@2
|
91 |
|
williamr@2
|
92 |
_STLP_TEMPLATE_NULL
|
williamr@2
|
93 |
class _STLP_CLASS_DECLSPEC collate<wchar_t> : public locale::facet
|
williamr@2
|
94 |
{
|
williamr@4
|
95 |
friend class _Locale_impl;
|
williamr@4
|
96 |
|
williamr@2
|
97 |
public:
|
williamr@2
|
98 |
typedef wchar_t char_type;
|
williamr@2
|
99 |
typedef wstring string_type;
|
williamr@2
|
100 |
|
williamr@4
|
101 |
explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
|
williamr@2
|
102 |
|
williamr@2
|
103 |
int compare(const wchar_t* __low1, const wchar_t* __high1,
|
williamr@2
|
104 |
const wchar_t* __low2, const wchar_t* __high2) const {
|
williamr@2
|
105 |
return do_compare( __low1, __high1, __low2, __high2);
|
williamr@2
|
106 |
}
|
williamr@2
|
107 |
|
williamr@2
|
108 |
string_type transform(const wchar_t* __low, const wchar_t* __high) const {
|
williamr@2
|
109 |
return do_transform(__low, __high);
|
williamr@2
|
110 |
}
|
williamr@2
|
111 |
|
williamr@2
|
112 |
long hash(const wchar_t* __low, const wchar_t* __high) const
|
williamr@2
|
113 |
{ return do_hash(__low, __high); }
|
williamr@2
|
114 |
|
williamr@4
|
115 |
#if defined(__SYMBIAN32__WSD__)
|
williamr@4
|
116 |
static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
|
williamr@4
|
117 |
#elif defined (__SYMBIAN32__NO_STATIC_IMPORTS__)
|
williamr@4
|
118 |
static _STLP_STATIC_MEMBER_DECLSPEC locale::id& GetFacetLocaleId();
|
williamr@4
|
119 |
static locale::id id;
|
williamr@2
|
120 |
#else
|
williamr@4
|
121 |
// NOTE: Symbian doesn't support exporting static data.
|
williamr@4
|
122 |
// Users of this class should use GetFacetLocaleId() to access the data member id
|
williamr@4
|
123 |
static _STLP_STATIC_MEMBER_DECLSPEC locale::id id;
|
williamr@2
|
124 |
#endif
|
williamr@2
|
125 |
|
williamr@2
|
126 |
protected:
|
williamr@4
|
127 |
_STLP_DECLSPEC ~collate();
|
williamr@2
|
128 |
|
williamr@4
|
129 |
_STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
|
williamr@2
|
130 |
const wchar_t*, const wchar_t*) const;
|
williamr@4
|
131 |
_STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
|
williamr@4
|
132 |
_STLP_DECLSPEC virtual long do_hash(const wchar_t* __low, const wchar_t* __high) const;
|
williamr@2
|
133 |
private:
|
williamr@2
|
134 |
collate(const collate<wchar_t>&);
|
williamr@4
|
135 |
collate<wchar_t>& operator = (const collate<wchar_t>&);
|
williamr@2
|
136 |
};
|
williamr@2
|
137 |
|
williamr@2
|
138 |
# endif /* NO_WCHAR_T */
|
williamr@2
|
139 |
|
williamr@2
|
140 |
_STLP_TEMPLATE_NULL
|
williamr@4
|
141 |
class _STLP_CLASS_DECLSPEC collate_byname<char>: public collate<char>
|
williamr@2
|
142 |
{
|
williamr@2
|
143 |
public:
|
williamr@4
|
144 |
_STLP_DECLSPEC explicit collate_byname(const char* __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
|
williamr@2
|
145 |
|
williamr@2
|
146 |
protected:
|
williamr@4
|
147 |
_STLP_DECLSPEC ~collate_byname();
|
williamr@2
|
148 |
|
williamr@4
|
149 |
_STLP_DECLSPEC virtual int do_compare(const char*, const char*,
|
williamr@2
|
150 |
const char*, const char*) const;
|
williamr@4
|
151 |
_STLP_DECLSPEC virtual string_type do_transform(const char*, const char*) const;
|
williamr@2
|
152 |
|
williamr@2
|
153 |
private:
|
williamr@2
|
154 |
_Locale_collate* _M_collate;
|
williamr@2
|
155 |
collate_byname(const collate_byname<char>&);
|
williamr@4
|
156 |
collate_byname<char>& operator =(const collate_byname<char>&);
|
williamr@4
|
157 |
friend _Locale_name_hint* _Locale_extract_hint(collate_byname<char>*);
|
williamr@2
|
158 |
};
|
williamr@2
|
159 |
|
williamr@2
|
160 |
# ifndef _STLP_NO_WCHAR_T
|
williamr@2
|
161 |
|
williamr@2
|
162 |
_STLP_TEMPLATE_NULL
|
williamr@4
|
163 |
class _STLP_CLASS_DECLSPEC collate_byname<wchar_t>: public collate<wchar_t>
|
williamr@2
|
164 |
{
|
williamr@2
|
165 |
public:
|
williamr@4
|
166 |
_STLP_DECLSPEC explicit collate_byname(const char * __name, size_t __refs = 0, _Locale_name_hint* __hint = 0);
|
williamr@2
|
167 |
|
williamr@2
|
168 |
protected:
|
williamr@4
|
169 |
_STLP_DECLSPEC ~collate_byname();
|
williamr@2
|
170 |
|
williamr@4
|
171 |
_STLP_DECLSPEC virtual int do_compare(const wchar_t*, const wchar_t*,
|
williamr@2
|
172 |
const wchar_t*, const wchar_t*) const;
|
williamr@4
|
173 |
_STLP_DECLSPEC virtual string_type do_transform(const wchar_t*, const wchar_t*) const;
|
williamr@2
|
174 |
|
williamr@2
|
175 |
private:
|
williamr@2
|
176 |
_Locale_collate* _M_collate;
|
williamr@2
|
177 |
collate_byname(const collate_byname<wchar_t>&);
|
williamr@4
|
178 |
collate_byname<wchar_t>& operator =(const collate_byname<wchar_t>&);
|
williamr@2
|
179 |
};
|
williamr@2
|
180 |
|
williamr@2
|
181 |
# endif /* NO_WCHAR_T */
|
williamr@2
|
182 |
|
williamr@2
|
183 |
template <class _CharT, class _Traits, class _Alloc>
|
williamr@4
|
184 |
bool
|
williamr@4
|
185 |
__locale_do_operator_call (const locale& __loc,
|
williamr@4
|
186 |
const basic_string<_CharT, _Traits, _Alloc>& __x,
|
williamr@4
|
187 |
const basic_string<_CharT, _Traits, _Alloc>& __y) {
|
williamr@4
|
188 |
collate<_CharT> const& __coll = use_facet<collate<_CharT> >(__loc);
|
williamr@4
|
189 |
return __coll.compare(__x.data(), __x.data() + __x.size(),
|
williamr@4
|
190 |
__y.data(), __y.data() + __y.size()) < 0;
|
williamr@2
|
191 |
}
|
williamr@2
|
192 |
|
williamr@2
|
193 |
_STLP_END_NAMESPACE
|
williamr@2
|
194 |
|
williamr@2
|
195 |
#endif /* _STLP_INTERNAL_COLLATE_H */
|
williamr@2
|
196 |
|
williamr@2
|
197 |
// Local Variables:
|
williamr@2
|
198 |
// mode:C++
|
williamr@2
|
199 |
// End:
|