2 * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
5 * Silicon Graphics Computer Systems, Inc.
10 * This material is provided "as is", with absolutely no warranty expressed
11 * or implied. Any use is at your own risk.
13 * Permission to use or copy this software for any purpose is hereby granted
14 * without fee, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
22 #ifndef _STLP_C_LOCALE_H
23 #define _STLP_C_LOCALE_H
26 * Implementation dependent definitions.
27 * Beware: This header is not a purely internal header, it is also included
28 * from the outside world when building the STLport library. So this header
29 * should not reference internal headers (stlport/stl/_*.h) directly.
32 # if defined (ROOT_65) /* IRIX 6.5.x */
34 # include <standards.h>
37 # else /* IRIX pre-6.5 */
39 # include <standards.h>
40 # if !defined(_SIZE_T) && !defined(_SIZE_T_)
42 # if (_MIPS_SZLONG == 32)
43 typedef unsigned int size_t;
45 # if (_MIPS_SZLONG == 64)
46 typedef unsigned long size_t;
49 # if !defined (_WCHAR_T)
51 # if (_MIPS_SZLONG == 32)
54 # if (_MIPS_SZLONG == 64)
55 typedef __int32_t wchar_t;
57 # endif /* _WCHAR_T */
58 # if !defined (_WINT_T)
60 # if (_MIPS_SZLONG == 32)
63 # if (_MIPS_SZLONG == 64)
64 typedef __int32_t wint_t;
67 # if !defined (_MBSTATE_T)
69 /* _MSC_VER check is here for historical reason and seems wrong as it is the macro defined
70 * by Microsoft compilers to give their version and we are currently in a SGI platform scope.
71 * However _MSC_VER might also be a SGI compiler macro so we keep it this way.*/
72 # if defined (_MSC_VER)
73 typedef int mbstate_t;
75 typedef char mbstate_t;
77 # endif /* _MBSTATE_T */
90 * Opaque types, implementation (if there is one) depends
91 * on platform locale API.
94 struct _Locale_numeric;
96 struct _Locale_collate;
97 struct _Locale_monetary;
98 struct _Locale_messages;
99 struct _Locale_name_hint;
106 * For narrow characters, we expose the lookup table interface.
109 /* Internal bitmask macros, os-specific. */
111 #if defined (__sgi) /* IRIX */
113 # define _Locale_S 0x00000008 /* Spacing character */
114 # define _Locale_A 0x00004000 /* Alphabetical characters only */
115 # define _Locale_B 0x00000040 /* Obsolete: was space char only */
116 # define _Locale_PR 0x00008000 /* Printable characters only */
117 # define _Locale_G 0x40000000 /* Graphic characters only */
118 # define _Locale_BL 0x80000000 /* The blank character class */
120 /* Public bitmask macros, must be defined for every OS. These values, of
121 * course, are specific to IRIX. */
123 # define _Locale_CNTRL 0x00000020 /* Control character */
124 # define _Locale_UPPER 0x00000001 /* Upper case */
125 # define _Locale_LOWER 0x00000002 /* Lower case */
126 # define _Locale_DIGIT 0x00000004 /* Numeral (digit) */
127 # define _Locale_XDIGIT 0x00000080 /* heXadecimal digit */
128 # define _Locale_PUNCT 0x00000010 /* Punctuation */
129 # define _Locale_SPACE (_Locale_S | _Locale_BL)
130 # define _Locale_PRINT (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
131 _Locale_DIGIT | _Locale_A | _Locale_XDIGIT | \
133 # define _Locale_ALPHA _Locale_A
136 * All of these except for graph and blank are from the C standard;
137 * graph and blank are XPG4. (graph in XPG4 doesn't mean quite the
138 * same thing as graph in the C++ library)
144 #if defined (__Lynx__)
145 /* azov: On Lynx isalpha defined as (_U | _L), which gives us a mask
146 * unusable in ctype_table. So we have to redefine it and use hard-coded
147 * numbers (to avoid potential clashes if system headers change).
149 * P.S. Actually, I see no reason in using platform-specific masks -
150 * having just one set of masks for all platforms should work just as
151 * well - we only use them internally and they don't have to be equal
152 * to whatever defined in local ctype.h
155 # define _Locale_CNTRL 040 /* _C, Control character */
156 # define _Locale_UPPER 01 /* _U, Upper case */
157 # define _Locale_LOWER 02 /* _L, Lower case */
158 # define _Locale_DIGIT 04 /* _N, Numeral (digit) */
159 # define _Locale_XDIGIT 0200 /* _X, heXadecimal digit */
160 # define _Locale_PUNCT 020 /* _P, Punctuation */
161 # define _Locale_SPACE 010 /* _S, Spacing */
162 # define _Locale_ALPHA 040000 /* none, Alphanumerical */
163 # define _Locale_PRINT (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
164 _Locale_DIGIT | _Locale_ALPHA | _Locale_XDIGIT |\
165 _Locale_SPACE ) /* Printable */
166 #endif /* __Lynx__ */
168 #if defined (__GNUC__) || defined (__BORLANDC__) || defined (__COMO__)
170 # if defined (__CYGWIN__)
172 # define _Locale_CNTRL 040
173 # define _Locale_UPPER 02
174 # define _Locale_LOWER 01
175 # define _Locale_DIGIT 04
176 # define _Locale_XDIGIT ( 0100 | _Locale_DIGIT )
177 # define _Locale_PUNCT 020
178 # define _Locale_SPACE 010
179 # define _Locale_ALPHA 0200
180 # define _Locale_PRINT (_Locale_ALPHA | _Locale_DIGIT | _Locale_PUNCT | 0400 )
182 # elif defined (__FreeBSD__) || ( defined (__APPLE__) && defined (__GNUC__) && (__GNUC__ > 3) )
184 # define _Locale_CNTRL _CTYPE_C
185 # define _Locale_UPPER _CTYPE_U
186 # define _Locale_LOWER _CTYPE_L
187 # define _Locale_DIGIT _CTYPE_D
188 # define _Locale_XDIGIT _CTYPE_X
189 # define _Locale_PUNCT _CTYPE_P
190 # define _Locale_SPACE _CTYPE_S
191 # define _Locale_PRINT _CTYPE_R
192 # define _Locale_ALPHA _CTYPE_A
194 # elif defined (__NetBSD__) || defined (__OpenBSD__) || defined (__amigaos__)
196 # define _Locale_CNTRL _C
197 # define _Locale_UPPER _U
198 # define _Locale_LOWER _L
199 # define _Locale_DIGIT _N
200 # define _Locale_XDIGIT (_N|_X)
201 # define _Locale_PUNCT _P
202 # define _Locale_SPACE _S
203 # define _Locale_PRINT (_P|_U|_L|_N|_B)
204 # define _Locale_ALPHA (_U|_L)
205 # elif defined (__EMX__) /* OS/2 with emx runtime */
206 # define _Locale_CNTRL _CNTRL
207 # define _Locale_UPPER _UPPER
208 # define _Locale_LOWER _LOWER
209 # define _Locale_DIGIT _DIGIT
210 # define _Locale_XDIGIT _XDIGIT
211 # define _Locale_PUNCT _PUNCT
212 # define _Locale_SPACE _SPACE
213 # define _Locale_PRINT _PRINT
214 # define _Locale_ALPHA (_UPPER|_LOWER)
216 # elif defined (_STLP_USE_GLIBC) /* linux, using the gnu compiler */
218 /* This section uses macros defined in the gnu libc ctype.h header */
220 # define _Locale_CNTRL _IScntrl
221 # define _Locale_UPPER _ISupper
222 # define _Locale_LOWER _ISlower
223 # define _Locale_DIGIT _ISdigit
224 # define _Locale_XDIGIT _ISxdigit
225 # define _Locale_PUNCT _ISpunct
226 # define _Locale_SPACE _ISspace
227 # define _Locale_PRINT _ISprint
228 # define _Locale_ALPHA _ISalpha
234 #if (defined (__sun) && defined (__SVR4)) || \
235 (defined (__digital__) && defined (__unix__)) || \
237 /* fbp : condition from AT&T code*/
238 # if !(defined (__XPG4_CHAR_CLASS__) || defined (_XPG4_2) || \
239 (defined (_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4))) && ! defined (_ISCNTRL)
240 /* fbp : on 2.5.1, the defines are different ;( */
241 /* # if ( defined (__sun) && defined (__SVR4) && ! defined (_ISCNTRL) ) */
246 # define _ISXDIGIT _X
249 # define _ISPRINT (_P | _U | _L | _N | _B)
250 # define _ISALPHA (_U | _L)
253 # define _Locale_CNTRL _ISCNTRL
254 # define _Locale_UPPER _ISUPPER
255 # define _Locale_LOWER _ISLOWER
256 # define _Locale_DIGIT _ISDIGIT
257 # define _Locale_XDIGIT _ISXDIGIT
258 # define _Locale_PUNCT _ISPUNCT
259 # define _Locale_SPACE _ISSPACE
260 # define _Locale_PRINT _ISPRINT
261 # define _Locale_ALPHA _ISALPHA
262 # elif defined(__SYMBIAN32__)
263 # define _Locale_CNTRL _CTYPE_C
264 # define _Locale_UPPER _CTYPE_U
265 # define _Locale_LOWER _CTYPE_L
266 # define _Locale_DIGIT _CTYPE_D
267 # define _Locale_XDIGIT _CTYPE_X
268 # define _Locale_PUNCT _CTYPE_P
269 # define _Locale_SPACE _CTYPE_S
270 # define _Locale_PRINT _CTYPE_R
271 # define _Locale_ALPHA _CTYPE_A
272 #elif defined (__MWERKS__) && defined (N_PLAT_NLM)
273 # define _Locale_CNTRL _CNTRL_
274 # define _Locale_UPPER _UPPER_
275 # define _Locale_LOWER _LOWER_
276 # define _Locale_DIGIT _DIGIT_
277 # define _Locale_XDIGIT _XDIGIT_
278 # define _Locale_PUNCT _PUNCT_
279 # define _Locale_SPACE _SPACE_
280 # define _Locale_PRINT (_PUNCT_|_UPPER_|_LOWER_|_DIGIT_|_BLANK_)
281 # define _Locale_ALPHA (_UPPER_|_LOWER_)
282 #elif defined (__MWERKS__)
283 # define _Locale_CNTRL __control_char
284 # define _Locale_UPPER __upper_case
285 # define _Locale_LOWER __lower_case
286 # define _Locale_DIGIT __digit
287 # define _Locale_XDIGIT __hex_digit
288 # define _Locale_PUNCT __punctuation
289 # define _Locale_SPACE __space_char
290 # define _Locale_PRINT __printable
291 # define _Locale_ALPHA __alphanumeric
292 #elif defined (__BORLANDC__)
293 # define _Locale_CNTRL _IS_CTL
294 # define _Locale_UPPER _IS_UPP
295 # define _Locale_LOWER _IS_LOW
296 # define _Locale_DIGIT _IS_DIG
297 # define _Locale_XDIGIT _IS_HEX
298 # define _Locale_PUNCT _IS_PUN
299 # define _Locale_SPACE _IS_SP
300 # define _Locale_PRINT (_IS_SP|_IS_PUN|_IS_UPP|_IS_LOW|_IS_DIG)
301 # define _Locale_ALPHA _IS_ALPHA
302 #elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__)
303 # define _Locale_CNTRL _CONTROL
304 # define _Locale_UPPER _UPPER
305 # define _Locale_LOWER _LOWER
306 # define _Locale_DIGIT _DIGIT
307 # define _Locale_XDIGIT _HEX
308 # define _Locale_PUNCT _PUNCT
309 # define _Locale_SPACE _SPACE
310 # define _Locale_PRINT (_ALPHA | _DIGIT | _BLANK | _PUNCT)
311 # define _Locale_ALPHA ( _ALPHA & ~ (_UPPER | _LOWER ))
312 #elif defined (__DMC__)
313 # define _Locale_CNTRL _CONTROL
314 # define _Locale_UPPER _UPPER
315 # define _Locale_LOWER _LOWER
316 # define _Locale_DIGIT _DIGIT
317 # define _Locale_XDIGIT _HEX
318 # define _Locale_PUNCT _PUNCT
319 # define _Locale_SPACE _SPACE
320 # define _Locale_PRINT (_UPPER | _LOWER | _DIGIT | _PUNCT | _SPACE)
321 # define _Locale_ALPHA _ALPHA & ~(_UPPER | _LOWER)
322 #elif defined (__MRC__) || defined (__SC__) /* *TY 02/24/2000 - added support for MPW */
323 # define _Locale_CNTRL _CTL
324 # define _Locale_UPPER _UPP
325 # define _Locale_LOWER _LOW
326 # define _Locale_DIGIT _DIG
327 # define _Locale_XDIGIT _HEX
328 # define _Locale_PUNCT _PUN
329 # define _Locale_SPACE _BLA
330 # define _Locale_PRINT (_UPP | _LOW | _DIG | _PUN | _BLA)
331 # define _Locale_ALPHA (_UPP | _LOW)
332 #elif defined (__MLCCPP__)
333 # define _Locale_CNTRL 1
334 # define _Locale_UPPER 2
335 # define _Locale_LOWER 4
336 # define _Locale_DIGIT 8
337 # define _Locale_XDIGIT 16
338 # define _Locale_PUNCT 32
339 # define _Locale_SPACE 64
340 # define _Locale_PRINT 128
341 # define _Locale_ALPHA 256
342 #elif defined (__GNUC__) && (__GNUC__ == 3) && defined (__APPLE__)
343 # define _Locale_CNTRL _C
344 # define _Locale_UPPER _U
345 # define _Locale_LOWER _L
346 # define _Locale_DIGIT _D
347 # define _Locale_XDIGIT _X
348 # define _Locale_PUNCT _P
349 # define _Locale_SPACE _S
350 # define _Locale_PRINT _R
351 # define _Locale_ALPHA _A
352 #elif defined (__hpux) || defined (__osf__)
353 # if defined (__HP_aCC) && !defined (_INCLUDE_HPUX_SOURCE)
354 # define _ISALPHA 0x001
355 # define _ISALNUM 0x002
356 # define _ISBLANK 0x004
357 # define _ISCNTRL 0x008
358 # define _ISDIGIT 0x010
359 # define _ISGRAPH 0x020
360 # define _ISLOWER 0x040
361 # define _ISPRINT 0x080
362 # define _ISPUNCT 0x100
363 # define _ISSPACE 0x200
364 # define _ISUPPER 0x400
365 # define _ISXDIGIT 0x800
367 # define _Locale_CNTRL _ISCNTRL
368 # define _Locale_UPPER _ISUPPER
369 # define _Locale_LOWER _ISLOWER
370 # define _Locale_DIGIT _ISDIGIT
371 # define _Locale_XDIGIT _ISXDIGIT
372 # define _Locale_PUNCT _ISPUNCT
373 # define _Locale_SPACE _ISSPACE
374 # define _Locale_PRINT _ISPRINT
375 # define _Locale_ALPHA _ISALPHA
376 #elif defined (__MVS__) || defined (__OS400__)
377 # define _Locale_CNTRL __ISCNTRL
378 # define _Locale_UPPER __ISUPPER
379 # define _Locale_LOWER __ISLOWER
380 # define _Locale_DIGIT __ISDIGIT
381 # define _Locale_XDIGIT __ISXDIGIT
382 # define _Locale_PUNCT __ISPUNCT
383 # define _Locale_SPACE __ISSPACE
384 # define _Locale_PRINT __ISPRINT
385 # define _Locale_ALPHA __ISALPHA
386 #elif defined (__QNXNTO__) || defined (__WATCOMC__)
387 # define _Locale_CNTRL _CNTRL
388 # define _Locale_UPPER _UPPER
389 # define _Locale_LOWER _LOWER
390 # define _Locale_DIGIT _DIGIT
391 # define _Locale_XDIGIT _XDIGT
392 # define _Locale_PUNCT _PUNCT
393 # define _Locale_SPACE _SPACE
394 # define _Locale_PRINT _PRINT
395 # define _Locale_ALPHA (_UPPER | _LOWER)
396 #elif defined (__DJGPP)
397 # define _Locale_CNTRL __dj_ISCNTRL
398 # define _Locale_UPPER __dj_ISUPPER
399 # define _Locale_LOWER __dj_ISLOWER
400 # define _Locale_DIGIT __dj_ISDIGIT
401 # define _Locale_XDIGIT __dj_ISXDIGIT
402 # define _Locale_PUNCT __dj_ISPUNCT
403 # define _Locale_SPACE __dj_ISSPACE
404 # define _Locale_PRINT __dj_ISPRINT
405 # define _Locale_ALPHA __dj_ISALPHA
406 #elif defined (_STLP_SCO_OPENSERVER)
407 # define _Locale_CNTRL _C
408 # define _Locale_UPPER _U
409 # define _Locale_LOWER _L
410 # define _Locale_DIGIT _N
411 # define _Locale_XDIGIT _X
412 # define _Locale_PUNCT _P
413 # define _Locale_SPACE _S
414 # define _Locale_PRINT _R
415 # define _Locale_ALPHA _A
416 #elif defined (__NCR_SVR)
417 # define _Locale_CNTRL _C
418 # define _Locale_UPPER _U
419 # define _Locale_LOWER _L
420 # define _Locale_DIGIT _N
421 # define _Locale_XDIGIT _X
422 # define _Locale_PUNCT _P
423 # define _Locale_SPACE _S
424 # define _Locale_PRINT (_P | _U | _L | _N | _B)
425 # define _Locale_ALPHA (_U | _L)
426 #elif defined (_CRAY)
427 # define _Locale_CNTRL _CNTRL
428 # define _Locale_UPPER _UPPER
429 # define _Locale_LOWER _LOWER
430 # define _Locale_DIGIT _DIGIT
431 # define _Locale_XDIGIT _XDIGIT
432 # define _Locale_PUNCT _PUNCT
433 # define _Locale_SPACE _SPACE
434 # define _Locale_PRINT _PRINT
435 # define _Locale_ALPHA _ALPHA
438 /* We arbitrarily consider _Locale_CNTRL macro to check locale facet numeric
439 * identifier has been defined for the platform/compiler:
441 #if !defined (_Locale_CNTRL)
442 # error Unable to find your platform locale facets definitions, please grant them.
445 #endif /* _STLP_C_LOCALE_H */