ReactOS 0.4.16-dev-336-gb667d82
_ctype.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18// WARNING: This is an internal header file, included by other C++
19// standard library headers. You should not attempt to use this header
20// file directly.
21
22#ifndef _STLP_INTERNAL_CTYPE_H
23#define _STLP_INTERNAL_CTYPE_H
24
25#ifndef _STLP_C_LOCALE_H
26# include <stl/c_locale.h>
27#endif
28
29#ifndef _STLP_INTERNAL_LOCALE_H
30# include <stl/_locale.h>
31#endif
32
33#ifndef _STLP_INTERNAL_ALGOBASE_H
34# include <stl/_algobase.h>
35#endif
36
38
40public:
41 enum mask {
51 alnum = alpha | digit,
52 graph = alnum | punct
53 };
54};
55
56// ctype<> template
57
58template <class charT> class ctype {};
59template <class charT> class ctype_byname {};
60
61//ctype specializations
62
65#ifndef _STLP_NO_WCHAR_T
66# ifdef _STLP_MSVC
67 typedef ctype<wchar_t> _Wctype;
68 friend _Wctype;
69# else
70 friend class ctype<wchar_t>;
71# endif
72#endif
73public:
74
75 typedef char char_type;
76
77 explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
78 bool is(mask __m, char __c) const
79 { return ((*(_M_ctype_table+(unsigned char)__c)) & __m) != 0; }
80
81 const char* is(const char* __low, const char* __high, mask* __vec) const {
82 for (const char* __p = __low;__p != __high; ++__p, ++__vec) {
83 *__vec = _M_ctype_table[(unsigned char)*__p];
84 }
85 return __high;
86 }
87
88 const char* scan_is(mask __m, const char* __low, const char* __high) const;
89 const char* scan_not(mask __m, const char* __low, const char* __high) const;
90
91 char (toupper)(char __c) const { return do_toupper(__c); }
92 const char* (toupper)(char* __low, const char* __high) const {
93 return do_toupper(__low, __high);
94 }
95
96 char (tolower)(char __c) const { return do_tolower(__c); }
97 const char* (tolower)(char* __low, const char* __high) const {
98 return do_tolower(__low, __high);
99 }
100
101 char widen(char __c) const { return do_widen(__c); }
102 const char* widen(const char* __low, const char* __high, char* __to) const {
103 return do_widen(__low, __high, __to);
104 }
105
106 char narrow(char __c, char __dfault) const {
107 return do_narrow(__c, __dfault);
108 }
109 const char* narrow(const char* __low, const char* __high,
110 char __dfault, char* __to) const {
111 return do_narrow(__low, __high, __dfault, __to);
112 }
113
116
117protected:
118 const mask* table() const _STLP_NOTHROW { return _M_ctype_table; }
119 static const mask* _STLP_CALL classic_table() _STLP_NOTHROW;
120
122
123 virtual char do_toupper(char __c) const;
124 virtual char do_tolower(char __c) const;
125 virtual const char* do_toupper(char* __low, const char* __high) const;
126 virtual const char* do_tolower(char* __low, const char* __high) const;
127 virtual char do_widen(char __c) const;
128 virtual const char* do_widen(const char* __low, const char* __high,
129 char* __to) const;
130 virtual char do_narrow(char __c, char /* dfault */ ) const;
131 virtual const char* do_narrow(const char* __low, const char* __high,
132 char /* dfault */, char* __to) const;
133private:
134 struct _Is_mask {
136 _Is_mask(mask __x): __m(__x) {}
137 bool operator()(char __c) {return (__m & (unsigned char) __c) != 0;}
138 };
139
140protected:
142private:
144};
145
148 friend class _Locale_impl;
149public:
150 explicit ctype_byname(const char*, size_t = 0);
152
153 virtual char do_toupper(char __c) const;
154 virtual char do_tolower(char __c) const;
155
156 virtual const char* do_toupper(char*, const char*) const;
157 virtual const char* do_tolower(char*, const char*) const;
158
159private:
161 : _M_ctype(__ctype)
162 { _M_init(); }
163
164 void _M_init();
165
166 //explicitely defined as private to avoid warnings:
169 _Self& operator = (_Self const&);
170
171 mask _M_byname_table[table_size];
173};
174
175# ifndef _STLP_NO_WCHAR_T
178public:
179 typedef wchar_t char_type;
180
181 explicit ctype(size_t __refs = 0) : locale::facet(__refs) {}
182
183 bool is(mask __m, wchar_t __c) const
184 { return do_is(__m, __c); }
185
186 const wchar_t* is(const wchar_t* __low, const wchar_t* __high,
187 mask* __vec) const
188 { return do_is(__low, __high, __vec); }
189
190 const wchar_t* scan_is(mask __m,
191 const wchar_t* __low, const wchar_t* __high) const
192 { return do_scan_is(__m, __low, __high); }
193
194 const wchar_t* scan_not (mask __m,
195 const wchar_t* __low, const wchar_t* __high) const
196 { return do_scan_not(__m, __low, __high); }
197
198 wchar_t (toupper)(wchar_t __c) const { return do_toupper(__c); }
199 const wchar_t* (toupper)(wchar_t* __low, const wchar_t* __high) const
200 { return do_toupper(__low, __high); }
201
202 wchar_t (tolower)(wchar_t __c) const { return do_tolower(__c); }
203 const wchar_t* (tolower)(wchar_t* __low, const wchar_t* __high) const
204 { return do_tolower(__low, __high); }
205
206 wchar_t widen(char __c) const { return do_widen(__c); }
207 const char* widen(const char* __low, const char* __high,
208 wchar_t* __to) const
209 { return do_widen(__low, __high, __to); }
210
211 char narrow(wchar_t __c, char __dfault) const
212 { return do_narrow(__c, __dfault); }
213 const wchar_t* narrow(const wchar_t* __low, const wchar_t* __high,
214 char __dfault, char* __to) const
215 { return do_narrow(__low, __high, __dfault, __to); }
216
218
219protected:
221
222 virtual bool do_is(mask __m, wchar_t __c) const;
223 virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const;
224 virtual const wchar_t* do_scan_is(mask,
225 const wchar_t*, const wchar_t*) const;
226 virtual const wchar_t* do_scan_not(mask,
227 const wchar_t*, const wchar_t*) const;
228 virtual wchar_t do_toupper(wchar_t __c) const;
229 virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const;
230 virtual wchar_t do_tolower(wchar_t c) const;
231 virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const;
232 virtual wchar_t do_widen(char c) const;
233 virtual const char* do_widen(const char*, const char*, wchar_t*) const;
234 virtual char do_narrow(wchar_t __c, char __dfault) const;
235 virtual const wchar_t* do_narrow(const wchar_t*, const wchar_t*,
236 char, char*) const;
237};
238
241 friend class _Locale_impl;
242public:
243 explicit ctype_byname(const char* __name, size_t __refs = 0);
244
245protected:
247
248 virtual bool do_is(mask __m, wchar_t __c) const;
249 virtual const wchar_t* do_is(const wchar_t*, const wchar_t*, mask*) const;
250 virtual const wchar_t* do_scan_is(mask,
251 const wchar_t*, const wchar_t*) const;
252 virtual const wchar_t* do_scan_not(mask,
253 const wchar_t*, const wchar_t*) const;
254 virtual wchar_t do_toupper(wchar_t __c) const;
255 virtual const wchar_t* do_toupper(wchar_t*, const wchar_t*) const;
256 virtual wchar_t do_tolower(wchar_t c) const;
257 virtual const wchar_t* do_tolower(wchar_t*, const wchar_t*) const;
258
259private:
261 : _M_ctype(__ctype) {}
262
263 //explicitely defined as private to avoid warnings:
266 _Self& operator = (_Self const&);
267
269};
270
271# endif /* WCHAR_T */
272
274
275#endif /* _STLP_INTERNAL_CTYPE_H */
276
277// Local Variables:
278// mode:C++
279// End:
280
#define _STLP_CALL
Definition: _bc.h:131
#define _STLP_NOTHROW
Definition: _intel.h:35
int toupper(int c)
Definition: utclib.c:881
int tolower(int c)
Definition: utclib.c:902
static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
Definition: print.c:438
bool _M_delete
Definition: _ctype.h:143
const mask * table() const _STLP_NOTHROW
Definition: _ctype.h:118
char char_type
Definition: _ctype.h:75
const char * widen(const char *__low, const char *__high, char *__to) const
Definition: _ctype.h:102
bool is(mask __m, char __c) const
Definition: _ctype.h:78
const char * is(const char *__low, const char *__high, mask *__vec) const
Definition: _ctype.h:81
const mask * _M_ctype_table
Definition: _ctype.h:141
const char * narrow(const char *__low, const char *__high, char __dfault, char *__to) const
Definition: _ctype.h:109
const char * scan_not(mask __m, const char *__low, const char *__high) const
char narrow(char __c, char __dfault) const
Definition: _ctype.h:106
ctype(const mask *__tab=0, bool __del=false, size_t __refs=0)
_STLP_STATIC_CONSTANT(size_t, table_size=256)
static _STLP_STATIC_DECLSPEC locale::id id
Definition: _ctype.h:114
const char *() tolower(char *__low, const char *__high) const
Definition: _ctype.h:97
char widen(char __c) const
Definition: _ctype.h:101
const char *() toupper(char *__low, const char *__high) const
Definition: _ctype.h:92
const char * scan_is(mask __m, const char *__low, const char *__high) const
virtual const wchar_t * do_narrow(const wchar_t *, const wchar_t *, char, char *) const
virtual char do_narrow(wchar_t __c, char __dfault) const
const wchar_t *() toupper(wchar_t *__low, const wchar_t *__high) const
Definition: _ctype.h:199
const char * widen(const char *__low, const char *__high, wchar_t *__to) const
Definition: _ctype.h:207
virtual const wchar_t * do_tolower(wchar_t *, const wchar_t *) const
const wchar_t *() tolower(wchar_t *__low, const wchar_t *__high) const
Definition: _ctype.h:203
virtual const char * do_widen(const char *, const char *, wchar_t *) const
wchar_t char_type
Definition: _ctype.h:179
virtual const wchar_t * do_scan_not(mask, const wchar_t *, const wchar_t *) const
virtual wchar_t do_tolower(wchar_t c) const
const wchar_t * is(const wchar_t *__low, const wchar_t *__high, mask *__vec) const
Definition: _ctype.h:186
ctype(size_t __refs=0)
Definition: _ctype.h:181
const wchar_t * narrow(const wchar_t *__low, const wchar_t *__high, char __dfault, char *__to) const
Definition: _ctype.h:213
char narrow(wchar_t __c, char __dfault) const
Definition: _ctype.h:211
virtual const wchar_t * do_scan_is(mask, const wchar_t *, const wchar_t *) const
wchar_t widen(char __c) const
Definition: _ctype.h:206
static _STLP_STATIC_DECLSPEC locale::id id
Definition: _ctype.h:217
const wchar_t * scan_is(mask __m, const wchar_t *__low, const wchar_t *__high) const
Definition: _ctype.h:190
bool is(mask __m, wchar_t __c) const
Definition: _ctype.h:183
virtual wchar_t do_widen(char c) const
virtual const wchar_t * do_is(const wchar_t *, const wchar_t *, mask *) const
const wchar_t * scan_not(mask __m, const wchar_t *__low, const wchar_t *__high) const
Definition: _ctype.h:194
virtual bool do_is(mask __m, wchar_t __c) const
virtual wchar_t do_toupper(wchar_t __c) const
virtual const wchar_t * do_toupper(wchar_t *, const wchar_t *) const
_Locale_ctype * _M_ctype
Definition: _ctype.h:172
ctype_byname(_Locale_ctype *__ctype)
Definition: _ctype.h:160
ctype_byname(_Self const &)
ctype_byname< char > _Self
Definition: _ctype.h:167
ctype_byname(_Self const &)
ctype_byname(_Locale_ctype *__ctype)
Definition: _ctype.h:260
ctype_byname< wchar_t > _Self
Definition: _ctype.h:264
_Locale_ctype * _M_ctype
Definition: _ctype.h:268
Definition: _ctype.h:58
Definition: _locale.h:75
unsigned char
Definition: typeof.h:29
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
#define _STLP_STATIC_DECLSPEC
Definition: features.h:992
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
const GLubyte * c
Definition: glext.h:8905
GLenum GLint GLuint mask
Definition: glext.h:6028
#define _Locale_CNTRL
Definition: c_locale.h:122
#define _Locale_LOWER
Definition: c_locale.h:124
#define _Locale_XDIGIT
Definition: c_locale.h:128
#define _Locale_SPACE
Definition: c_locale.h:120
#define _Locale_PUNCT
Definition: c_locale.h:127
#define _Locale_ALPHA
Definition: c_locale.h:125
#define _Locale_UPPER
Definition: c_locale.h:123
#define _Locale_DIGIT
Definition: c_locale.h:126
#define _Locale_PRINT
Definition: c_locale.h:121
#define __c
Definition: schilyio.h:209
__WCHAR_TYPE__ wchar_t
Definition: stddef.h:311
LOCAL int table_size
Definition: write.c:65
_Is_mask(mask __x)
Definition: _ctype.h:136
bool operator()(char __c)
Definition: _ctype.h:137
#define wchar_t
Definition: wchar.h:102
#define const
Definition: zconf.h:233