]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/ctype.cc
3 // Copyright (C) 2000, 1999 Free Software Foundation
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 22.2.1 The ctype category
25 // 1: Test that the locale headers are picking up the correct declaration
26 // of the internal type `ctype_base::mask'.
31 // 2: Should be able to instantiate this for other types besides char, wchar_t
32 typedef std::ctype
<char> cctype
;
34 class gnu_ctype
: public std::ctype
<unsigned char>
37 const cctype
& _M_cctype
;
41 gnu_ctype(size_t __refs
= 0)
42 : std::ctype
<unsigned char>(__refs
),
43 _M_cctype(std::use_facet
<cctype
>(std::locale::classic()))
50 do_is(mask __m
, char_type __c
) const
51 { return _M_cctype
.is(__m
, __c
); }
53 virtual const char_type
*
54 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const
56 const char* __c
= _M_cctype
.is(reinterpret_cast<const char*>(__lo
),
57 reinterpret_cast<const char*>(__hi
), __vec
);
58 return reinterpret_cast<const char_type
*>(__c
);
61 virtual const char_type
*
62 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
64 const char* __c
= _M_cctype
.scan_is(__m
,
65 reinterpret_cast<const char*>(__lo
),
66 reinterpret_cast<const char*>(__hi
));
67 return reinterpret_cast<const char_type
*>(__c
);
70 virtual const char_type
*
71 do_scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
73 const char* __c
= _M_cctype
.scan_is(__m
,
74 reinterpret_cast<const char*>(__lo
),
75 reinterpret_cast<const char*>(__hi
));
76 return reinterpret_cast<const char_type
*>(__c
);
80 do_toupper(char_type __c
) const
81 { return _M_cctype
.toupper(__c
); }
83 virtual const char_type
*
84 do_toupper(char_type
* __lo
, const char_type
* __hi
) const
86 const char* __c
= _M_cctype
.toupper(reinterpret_cast<char*>(__lo
),
87 reinterpret_cast<const char*>(__hi
));
88 return reinterpret_cast<const char_type
*>(__c
);
92 do_tolower(char_type __c
) const
93 { return _M_cctype
.tolower(__c
); }
95 virtual const char_type
*
96 do_tolower(char_type
* __lo
, const char_type
* __hi
) const
98 const char* __c
= _M_cctype
.toupper(reinterpret_cast<char*>(__lo
),
99 reinterpret_cast<const char*>(__hi
));
100 return reinterpret_cast<const char_type
*>(__c
);
104 do_widen(char __c
) const
105 { return _M_cctype
.widen(__c
); }
108 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const
110 const char* __c
= _M_cctype
.widen(reinterpret_cast<const char*>(__lo
),
111 reinterpret_cast<const char*>(__hi
),
112 reinterpret_cast<char*>(__dest
));
117 do_narrow(char_type __c
, char __dfault
) const
118 { return _M_cctype
.narrow(__c
, __dfault
); }
120 virtual const char_type
*
121 do_narrow(const char_type
* __lo
, const char_type
* __hi
, char __dfault
,
124 const char* __c
= _M_cctype
.narrow(reinterpret_cast<const char*>(__lo
),
125 reinterpret_cast<const char*>(__hi
),
127 reinterpret_cast<char*>(__dest
));
128 return reinterpret_cast<const char_type
*>(__c
);
133 gnu_ctype::~gnu_ctype() { }
137 // 3: Sanity check ctype_base::mask bitmask requirements
143 ctype_base::mask m01
;
144 ctype_base::mask m02
;
146 m01
= ctype_base::space
;
147 m02
= ctype_base::xdigit
;
161 class gnu_ctype2
: public std::ctype
<gnu_obj
>