32#ifndef _RWSTD_LOC_CTYPE_H_INCLUDED
33#define _RWSTD_LOC_CTYPE_H_INCLUDED
55 __rw_alnum = __rw_alpha | __rw_digit,
91template <
class _CharT>
95#ifndef _RWSTD_NO_EXT_CTYPE_PRIMARY
98template <
class _CharT>
99class ctype:
public _RW::__rw_facet,
public ctype_base
103 typedef _CharT char_type;
105 explicit ctype (_RWSTD_SIZE_T __ref = 0)
106 : _RW::__rw_facet (__ref) { }
110 bool is (mask __m, char_type __c)
const {
111 return do_is ( __m, __c);
115 is (
const char_type* __lo,
const char_type *__hi, mask *__vec)
const {
116 return do_is (__lo, __hi, __vec);
121 scan_is (mask __m,
const char_type *__lo,
const char_type *__hi)
const {
122 return do_scan_is ( __m, __lo, __hi);
127 scan_not (mask __m,
const char_type *__lo,
const char_type *__hi)
const {
128 return do_scan_not ( __m, __lo, __hi);
132 char_type (toupper)(char_type __c)
const {
133 return do_toupper (__c);
136 const char_type* (toupper)(char_type *__lo,
const char_type *__hi)
const {
137 return do_toupper (__lo, __hi);
141 char_type (tolower)(char_type __c)
const {
142 return do_tolower (__c);
145 const char_type* (tolower)(char_type *__lo,
const char_type *__hi)
const {
146 return do_tolower (__lo, __hi);
150 char_type
widen (
char __c)
const {
151 return do_widen (__c);
155 widen (
const char *__lo,
const char *__hi, char_type *__to)
const {
156 return do_widen (__lo, __hi, __to);
160 char narrow (char_type __c,
char __dfault)
const {
161 return do_narrow (__c, __dfault);
165 narrow (
const char_type *__lo,
const char_type *__hi,
166 char __dfault,
char *__to)
const {
167 return do_narrow (__lo, __hi, __dfault, __to);
170 static _RW::__rw_facet_id id;
175 virtual bool do_is (mask, char_type)
const {
179 virtual const char_type*
180 do_is (
const char_type*,
const char_type*, mask*)
const;
183 virtual const char_type*
184 do_scan_is (mask,
const char_type*,
const char_type*)
const;
187 virtual const char_type*
188 do_scan_not (mask,
const char_type*,
const char_type*)
const;
191 virtual char_type do_toupper (char_type __c)
const {
195 virtual const char_type*
196 do_toupper (char_type*,
const char_type*)
const;
199 virtual char_type do_tolower (char_type __c)
const {
203 virtual const char_type*
204 do_tolower (char_type*,
const char_type*)
const;
207 virtual char_type do_widen (
char)
const {
212 do_widen (
const char*,
const char*, char_type*)
const;
215 virtual char do_narrow (char_type,
char __dfault)
const {
219 virtual const char_type*
220 do_narrow (
const char_type*,
const char_type*,
char,
char*)
const;
227class _RWSTD_EXPORT ctype<char>:
public _RW::__rw_facet,
public ctype_base
229 typedef unsigned char _UChar;
233 typedef char char_type;
235 bool is (mask __m, char_type __c)
const {
236#if _RWSTD_UCHAR_MAX <= 255
237 return (_C_mask_tab [_UChar (__c)] & __m) != 0;
239 return __c < table_size && (_C_mask_tab [_UChar (__c)] & __m) != 0;
245 explicit ctype (
const mask* = 0,
bool =
false, _RWSTD_SIZE_T = 0);
247 const char_type* is (
const char_type*,
const char_type*, mask*)
const;
249 const char_type* scan_is (mask,
const char_type*,
const char_type*)
const;
251 const char_type* scan_not (mask,
const char_type*,
const char_type*)
const;
253 char_type (toupper)(char_type __c)
const {
254 return do_toupper (__c);
257 char_type (tolower)(char_type __c)
const {
258 return do_tolower (__c);
262 char_type
widen (
char)
const;
264 char narrow (char_type,
char)
const;
266 const char_type* (toupper)(char_type *__lo,
const char_type *__hi)
const {
267 return do_toupper (__lo, __hi);
270 const char_type* (tolower)(char_type *__lo,
const char_type *__hi)
const {
271 return do_tolower (__lo, __hi);
275 widen (
const char *__lo,
const char *__hi, char_type *__to)
const {
276 return do_widen (__lo, __hi, __to);
280 narrow (
const char_type *__lo,
const char_type *__hi,
281 char_type __dfault, char_type *__to)
const {
282 return do_narrow (__lo, __hi, __dfault, __to);
285 static _RW::__rw_facet_id id;
293 static const mask* classic_table ()
_THROWS (());
297 virtual const char_type*
298 do_toupper (char_type*,
const char_type*)
const;
300 virtual const char_type*
301 do_tolower (char_type*,
const char_type*)
const;
303 virtual char_type do_toupper (char_type)
const;
305 virtual char_type do_tolower (char_type)
const;
307 virtual char_type do_widen (
char)
const;
309 virtual const char_type*
310 do_widen (
const char_type*,
const char_type*, char_type*)
const;
312 virtual char_type do_narrow (char_type, char_type)
const;
314 virtual const char_type*
315 do_narrow (
const char_type*,
const char_type*, char_type, char_type*)
const;
319 const mask *_C_mask_tab;
320 unsigned char *_C_upper_tab;
321 unsigned char *_C_lower_tab;
322 char _C_narrow_tab [256];
323 char _C_wide_tab [256];
328inline ctype<char>::char_type
329ctype<char>::narrow (char_type __c,
char __dfault)
const
337#
if _RWSTD_CHAR_BIT > 8
339 __inx <
sizeof _C_narrow_tab /
sizeof *_C_narrow_tab &&
343 _C_narrow_tab [__inx])
344 return _C_narrow_tab [__inx];
349 __c = do_narrow (__c, __dfault);
352 __self->_C_narrow_tab [__inx] = __c;
358inline ctype<char>::char_type
359ctype<char>::widen (
char __ch)
const
365#if _RWSTD_CHAR_BIT <= 8
366 const bool __fits =
true;
368 const bool __fits = __inx <
sizeof _C_wide_tab /
sizeof *_C_wide_tab;
372 if (_C_wide_tab [__inx])
373 return _C_wide_tab [__inx];
378 return __self->_C_wide_tab [__inx] = do_widen (__ch);
381 return do_widen (__ch);
386template <
class _CharT>
387class ctype_byname:
public ctype<_CharT>
389 char _C_namebuf [32];
393 explicit ctype_byname (
const char *__name, _RWSTD_SIZE_T __ref = 0)
394 : ctype<_CharT>(__ref) {
395 this->_C_set_name (__name, _C_namebuf,
sizeof _C_namebuf);
403 char _C_namebuf [32];
407 explicit ctype_byname (
const char*, _RWSTD_SIZE_T = 0);
411#ifndef _RWSTD_NO_WCHAR_T
416 typedef unsigned char _UChar;
418 enum { _C_tab_size = 256 };
422 typedef wchar_t char_type;
424 explicit ctype (_RWSTD_SIZE_T = 0);
427 bool is (mask __m, char_type __c)
const {
428 return do_is ( __m, __c);
432 is (
const char_type *__lo,
const char_type *__hi, mask *__vec)
const {
433 return do_is (__lo, __hi, __vec);
438 scan_is (mask __m,
const char_type *__lo,
const char_type *__hi)
const {
439 return do_scan_is ( __m, __lo, __hi);
444 scan_not (mask __m,
const char_type *__lo,
const char_type *__hi)
const {
445 return do_scan_not ( __m, __lo, __hi);
449 char_type (toupper)(char_type __c)
const {
450 return do_toupper (__c);
453 const char_type* (toupper)(char_type *__lo,
const char_type *__hi)
const {
454 return do_toupper (__lo, __hi);
458 char_type (tolower)(char_type __c)
const {
459 return do_tolower (__c);
462 const char_type* (tolower)(char_type *__lo,
const char_type *__hi)
const {
463 return do_tolower (__lo, __hi);
467 char_type
widen (
char)
const;
470 widen (
const char* __lo,
const char *__hi, char_type *__to)
const {
471 return do_widen (__lo, __hi, __to);
475 char narrow (char_type,
char)
const;
478 narrow (
const char_type *__lo,
const char_type *__hi,
479 char __dfault,
char *__to)
const {
480 return do_narrow (__lo, __hi, __dfault, __to);
483 static _RW::__rw_facet_id id;
490 virtual bool do_is (mask, char_type)
const;
492 virtual const char_type*
493 do_is (
const char_type*,
const char_type*, mask*)
const;
496 virtual char_type do_toupper (char_type)
const;
499 virtual char_type do_tolower (char_type)
const;
502 virtual char_type do_widen (
char)
const;
505 do_widen (
const char*,
const char*, char_type*)
const;
509 do_narrow (char_type,
char)
const;
511 virtual const char_type*
512 do_toupper (char_type*,
const char_type*)
const;
514 virtual const char_type*
515 do_tolower (char_type*,
const char_type*)
const;
518 virtual const char_type*
519 do_scan_is (mask,
const char_type*,
const char_type*)
const;
522 virtual const char_type*
523 do_scan_not (mask,
const char_type*,
const char_type*)
const;
525 virtual const char_type*
526 do_narrow (
const char_type*,
const char_type*,
char,
char*)
const;
530 friend class ctype_byname<
wchar_t>;
532 const mask *_C_mask_tab;
533 unsigned char *_C_upper_tab;
534 unsigned char *_C_lower_tab;
535 char _C_narrow_tab [256];
536 char_type _C_wide_tab [256];
542ctype<wchar_t>::narrow (char_type __c,
char __dfault)
const
551 if ( __inx <
sizeof _C_narrow_tab /
sizeof *_C_narrow_tab
552 && _C_narrow_tab [__inx])
553 return _C_narrow_tab [__inx];
558 const char __ch = do_narrow (__c, __dfault);
560 if (__inx <
sizeof _C_narrow_tab /
sizeof *_C_narrow_tab && __ch != __dfault)
561 __self->_C_narrow_tab [__inx] = __ch;
567inline ctype<wchar_t>::char_type
568ctype<wchar_t>::widen (
char __ch)
const
574#if _RWSTD_CHAR_BIT <= 8
575 const bool __fits =
true;
577 const bool __fits = __inx <
sizeof _C_wide_tab /
sizeof *_C_wide_tab;
581 if (_C_wide_tab [__inx])
582 return _C_wide_tab [__inx];
587 return __self->_C_wide_tab [__inx] = do_widen (__ch);
590 return do_widen (__ch);
600 explicit ctype_byname (
const char*, _RWSTD_SIZE_T = 0);
604 virtual ~ctype_byname ();
607 do_is (mask, char_type)
const;
609 virtual const char_type*
610 do_is (
const char_type*,
const char_type*, mask*)
const;
613 do_toupper (char_type)
const;
615 virtual const char_type*
616 do_toupper (char_type*,
const char_type*)
const;
619 do_tolower (char_type)
const;
621 virtual const char_type*
622 do_tolower (char_type*,
const char_type*)
const;
624 virtual const char_type*
625 do_scan_is (mask,
const char_type*,
const char_type*)
const;
627 virtual const char_type*
628 do_scan_not (mask,
const char_type*,
const char_type*)
const;
631 do_narrow(char_type,
char)
const;
633 virtual const char_type*
634 do_narrow (
const char_type*,
const char_type*,
char,
char*)
const;
636 virtual char_type do_widen (
char)
const;
639 do_widen (
const char*,
const char*, char_type*)
const;
643 char _C_namebuf [32];
644 const void *_C_cvtimpl;
645 _RWSTD_SIZE_T _C_cvtsize;
654#if _RWSTD_DEFINE_TEMPLATE (CTYPE)
const char * widen(char *dst, const char *src)
const char * narrow(char *dst, const char *src)
#define _RWSTD_SPECIALIZED_CLASS
#define _RWSTD_BITMASK_ENUM(Bitmask)
#define _RWSTD_DEFINE_BITMASK_OPERATORS(Bitmask)
#define _RWSTD_CLASS_EXPORT
#define _RWSTD_STATIC_CAST(T, x)
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_UWCHAR_INT_T
#define _RWSTD_STATIC_CONST(type, init)
#define _RWSTD_CONST_CAST(T, x)