4 // Copyright (C) 1999, 2000, 2003 Free Software Foundation
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // 22.2.1 The ctype category
24 // 1: Test that the locale headers are picking up the correct declaration
25 // of the internal type `ctype_base::mask'.
30 // 2: Should be able to instantiate this for other types besides char, wchar_t
31 typedef std::ctype<char> cctype;
33 class gnu_ctype: public std::ctype<unsigned char>
36 const cctype& _M_cctype;
40 gnu_ctype(size_t __refs = 0)
41 : std::ctype<unsigned char>(__refs),
42 _M_cctype(std::use_facet<cctype>(std::locale::classic()))
49 do_is(mask __m, char_type __c) const
50 { return _M_cctype.is(__m, __c); }
52 virtual const char_type*
53 do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const
55 const char* __c = _M_cctype.is(reinterpret_cast<const char*>(__lo),
56 reinterpret_cast<const char*>(__hi), __vec);
57 return reinterpret_cast<const char_type*>(__c);
60 virtual const char_type*
61 do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
63 const char* __c = _M_cctype.scan_is(__m,
64 reinterpret_cast<const char*>(__lo),
65 reinterpret_cast<const char*>(__hi));
66 return reinterpret_cast<const char_type*>(__c);
69 virtual const char_type*
70 do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
72 const char* __c = _M_cctype.scan_is(__m,
73 reinterpret_cast<const char*>(__lo),
74 reinterpret_cast<const char*>(__hi));
75 return reinterpret_cast<const char_type*>(__c);
79 do_toupper(char_type __c) const
80 { return _M_cctype.toupper(__c); }
82 virtual const char_type*
83 do_toupper(char_type* __lo, const char_type* __hi) const
85 const char* __c = _M_cctype.toupper(reinterpret_cast<char*>(__lo),
86 reinterpret_cast<const char*>(__hi));
87 return reinterpret_cast<const char_type*>(__c);
91 do_tolower(char_type __c) const
92 { return _M_cctype.tolower(__c); }
94 virtual const char_type*
95 do_tolower(char_type* __lo, const char_type* __hi) const
97 const char* __c = _M_cctype.toupper(reinterpret_cast<char*>(__lo),
98 reinterpret_cast<const char*>(__hi));
99 return reinterpret_cast<const char_type*>(__c);
103 do_widen(char __c) const
104 { return _M_cctype.widen(__c); }
107 do_widen(const char* __lo, const char* __hi, char_type* __dest) const
109 const char* __c = _M_cctype.widen(reinterpret_cast<const char*>(__lo),
110 reinterpret_cast<const char*>(__hi),
111 reinterpret_cast<char*>(__dest));
116 do_narrow(char_type __c, char __dfault) const
117 { return _M_cctype.narrow(__c, __dfault); }
119 virtual const char_type*
120 do_narrow(const char_type* __lo, const char_type* __hi, char __dfault,
123 const char* __c = _M_cctype.narrow(reinterpret_cast<const char*>(__lo),
124 reinterpret_cast<const char*>(__hi),
126 reinterpret_cast<char*>(__dest));
127 return reinterpret_cast<const char_type*>(__c);
132 gnu_ctype::~gnu_ctype() { }
136 // 3: Sanity check ctype_base::mask bitmask requirements
142 ctype_base::mask m01;
143 ctype_base::mask m02;
145 m01 = ctype_base::space;
146 m02 = ctype_base::xdigit;