Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
rw_ctype.h
Go to the documentation of this file.
1
27#ifndef RW_CTYPE_H_INCLUDED
28#define RW_CTYPE_H_INCLUDED
29
30
31#include <locale> // for ctype, locale
32
33#include <rw_char.h> // for UserChar
34#include <rw_testdefs.h>
35
36
37struct _TEST_EXPORT UserCtypeBase: std::ctype_base
38{
39 enum MemFunc {
52 n_funs
53 };
54
55 struct Exception {
56 virtual ~Exception ();
57 virtual const char* what () const = 0;
58 };
59
60 // name of the character type ("char", "wchar_t", "UserChar")
61 const char* const cname_;
62
63 // array of masks corresponding to each of the characters in chars
64 // the first negative element in chars denotes the last element
65 const unsigned* masks_;
66 const unsigned* chars_;
67
68 // arrays of correspondning uppercase and lowercase characters
69 const unsigned* upper_;
70 const unsigned* lower_;
71
72 // arrays of corresponding narrow and wide characters
73 const unsigned* narrow_;
74 const unsigned* wide_;
75
76 // counter of the number of calls to all member functions
77 // made throughout the lifetime of this object
78 _RWSTD_SIZE_T n_all_calls_;
79
80 // counter of the number of calls to each member function
81 // made throughout the lifetime of this object
82 _RWSTD_SIZE_T n_calls_ [n_funs];
83
84 // counter of the number of exceptions thrown by each member
85 // function throughout the lifetime of this object
86 _RWSTD_SIZE_T n_throws_ [n_funs];
87
88 // member function counter value that, when reached, will
89 // cause an exception to be thrown
90 _RWSTD_SIZE_T throw_at_calls_ [n_funs];
91
92 // value of a character that, when encountered, will cause
93 // an exception to be thrown
95
96 // when true the facet throws an exception when it encounters
97 // an invalid character (unless otherwise specified)
99
100protected:
101
102 UserCtypeBase (const char*);
103
104private:
105
106 UserCtypeBase (const UserCtypeBase&); // not CopyConstructible
107 void operator= (const UserCtypeBase&); // not Assignable
108};
109
110
111template <class _CharT>
113
114
117 : public std::ctype<char>, public UserCtypeBase
118{
119 typedef std::ctype<char_type> Base;
120
121public:
122
123 explicit
124 UserCtype (_RWSTD_SIZE_T = 0);
125
126 explicit
127 UserCtype (const unsigned* a, const unsigned* b, _RWSTD_SIZE_T c = 0);
128
129protected:
130
131 virtual char_type
132 do_toupper (char_type) const;
133
134 virtual const char_type*
135 do_toupper (char_type*, const char_type*) const;
136
137 virtual char_type
138 do_tolower (char_type) const;
139
140 virtual const char_type*
141 do_tolower (char_type*, const char_type*) const;
142
143 virtual char_type
144 do_widen (char) const;
145
146 virtual const char*
147 do_widen (const char*, const char*, char_type*) const;
148
149 virtual char
150 do_narrow (char_type, char) const;
151
152 virtual const char_type*
153 do_narrow (const char_type*, const char_type*, char, char*) const;
154};
155
156
157#ifndef _RWSTD_NO_WCHAR_T
158
161 : public std::ctype<wchar_t>, public UserCtypeBase
162{
163 typedef std::ctype<char_type> Base;
164
165public:
166
167 explicit
168 UserCtype (_RWSTD_SIZE_T = 0);
169
170 explicit
171 UserCtype (const unsigned*, const unsigned*, _RWSTD_SIZE_T = 0);
172
173protected:
174
175 virtual bool
176 do_is (mask, char_type) const;
177
178 virtual const char_type*
179 do_is (const char_type*, const char_type*, mask*) const;
180
181 virtual const char_type*
182 do_scan_is (mask, const char_type*, const char_type*) const;
183
184 virtual const char_type*
185 do_scan_not (mask, const char_type*, const char_type*) const;
186
187 virtual char_type
188 do_toupper (char_type) const;
189
190 virtual const char_type*
191 do_toupper (char_type*, const char_type*) const;
192
193 virtual char_type
194 do_tolower (char_type) const;
195
196 virtual const char_type*
197 do_tolower (char_type*, const char_type*) const;
198
199 virtual char_type
200 do_widen (char) const;
201
202 virtual const char*
203 do_widen (const char*, const char*, char_type*) const;
204
205 virtual char
206 do_narrow (char_type, char) const;
207
208 virtual const char_type*
209 do_narrow (const char_type*, const char_type*, char, char*) const;
210};
211
212
213#endif // _RWSTD_NO_WCHAR_T
214
215
217
219class _TEST_EXPORT ctype<UserChar>
220 : public std::locale::facet, public UserCtypeBase
221{
222 typedef std::locale::facet Base;
223public:
224
225 typedef UserChar char_type;
226
227 explicit
228 ctype (_RWSTD_SIZE_T = 0);
229
230 explicit
231 ctype (const unsigned*, const unsigned*, _RWSTD_SIZE_T = 0);
232
233 bool
234 is (mask m, char_type c) const {
235 return do_is (m, c);
236 }
237
238 const char_type*
239 is (const char_type* lo, const char_type *hi, mask *vec) const {
240 return do_is (lo, hi, vec);
241 }
242
243 const char_type*
244 scan_is (mask m, const char_type *lo, const char_type *hi) const {
245 return do_scan_is ( m, lo, hi);
246 }
247
248 const char_type*
249 scan_not (mask m, const char_type *lo, const char_type *hi) const {
250 return do_scan_not (m, lo, hi);
251 }
252
253 char_type
254 (toupper)(char_type c) const {
255 return do_toupper (c);
256 }
257
258 const char_type*
259 (toupper)(char_type *lo, const char_type *hi) const {
260 return do_toupper (lo, hi);
261 }
262
263 char_type
264 (tolower)(char_type c) const {
265 return do_tolower (c);
266 }
267
268 const char_type*
269 (tolower)(char_type *lo, const char_type *hi) const {
270 return do_tolower (lo, hi);
271 }
272
273 char_type
274 widen (char c) const {
275 return do_widen (c);
276 }
277
278 const char*
279 widen (const char *lo, const char *hi, char_type *to) const {
280 return do_widen (lo, hi, to);
281 }
282
283 char
284 narrow (char_type c, char dfault) const {
285 return do_narrow (c, dfault);
286 }
287
288 const char_type*
289 narrow (const char_type *lo, const char_type *hi,
290 char dfault, char *to) const {
291 return do_narrow (lo, hi, dfault, to);
292 }
293
294 static std::locale::id id;
295
296protected:
297
298 virtual bool
299 do_is (mask, char_type) const;
300
301 virtual const char_type*
302 do_is (const char_type*, const char_type*, mask*) const;
303
304 virtual const char_type*
305 do_scan_is (mask, const char_type*, const char_type*) const;
306
307 virtual const char_type*
308 do_scan_not (mask, const char_type*, const char_type*) const;
309
310 virtual char_type
311 do_toupper (char_type) const;
312
313 virtual const char_type*
314 do_toupper (char_type*, const char_type*) const;
315
316 virtual char_type
317 do_tolower (char_type c) const;
318
319 virtual const char_type*
320 do_tolower (char_type*, const char_type*) const;
321
322 virtual char_type
323 do_widen (char) const;
324
325 virtual const char*
326 do_widen (const char*, const char*, char_type*) const;
327
328 virtual char
329 do_narrow (char_type, char dfault) const;
330
331 virtual const char_type*
332 do_narrow (const char_type*, const char_type*, char, char*) const;
333};
334
335} // namespace std
336
337
340 : public std::ctype<UserChar>
341{
342 typedef std::ctype<UserChar> Base;
343public:
344
346
347 explicit
348 UserCtype (_RWSTD_SIZE_T = 0);
349
350 explicit
351 UserCtype (const unsigned*, const unsigned*, _RWSTD_SIZE_T = 0);
352};
353
354
355#endif // RW_CTYPE_H_INCLUDED
#define m
Definition 17.names.cpp:129
#define a
Definition 17.names.cpp:109
#define c
Definition 17.names.cpp:111
#define b
Definition 17.names.cpp:110
const char * widen(char *dst, const char *src)
const char * narrow(char *dst, const char *src)
#define _RWSTD_SPECIALIZED_CLASS
unsigned short wchar_t
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
UserCtype(const unsigned *, const unsigned *, _RWSTD_SIZE_T=0)
UserCtype(_RWSTD_SIZE_T=0)
UserCtype(const unsigned *a, const unsigned *b, _RWSTD_SIZE_T c=0)
UserCtype(_RWSTD_SIZE_T=0)
UserCtype(_RWSTD_SIZE_T=0)
UserCtype(const unsigned *, const unsigned *, _RWSTD_SIZE_T=0)
Definition json.h:5363
#define _TEST_EXPORT
Definition rw_testdefs.h:55
virtual const char * what() const =0
int throw_char_
Definition rw_ctype.h:94
const unsigned * chars_
Definition rw_ctype.h:66
const unsigned * upper_
Definition rw_ctype.h:69
_RWSTD_SIZE_T n_all_calls_
Definition rw_ctype.h:78
const char *const cname_
Definition rw_ctype.h:61
const unsigned * masks_
Definition rw_ctype.h:65
const unsigned * lower_
Definition rw_ctype.h:70
const unsigned * narrow_
Definition rw_ctype.h:73
bool throw_on_invalid_
Definition rw_ctype.h:98
const unsigned * wide_
Definition rw_ctype.h:74