home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / c_locale.h < prev    next >
C/C++ Source or Header  |  2002-01-18  |  12KB  |  407 lines

  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.  
  19.  
  20. #ifndef _STLP_C_LOCALE_H
  21. # define _STLP_C_LOCALE_H
  22.  
  23. /*
  24.  * Implementation dependent definitions
  25.  */
  26. #ifdef __cplusplus
  27. #  include <stl/_config.h>
  28. #endif
  29.  
  30. #if defined(__sgi) 
  31. # if defined(ROOT_65) /* IRIX 6.5.x */
  32. #  include <sgidefs.h>
  33. #  include <standards.h>
  34. #  include <wchar.h>
  35. #  include <ctype.h>
  36.  
  37. # else
  38.                   /* IRIX pre-6.5 */
  39. #  include <sgidefs.h>
  40. #  include <standards.h>
  41.  
  42. #  if !defined(_SIZE_T) && !defined(_SIZE_T_)
  43. #   define _SIZE_T
  44. #    if (_MIPS_SZLONG == 32)
  45. typedef unsigned int    size_t;
  46. #    endif
  47. #    if (_MIPS_SZLONG == 64)
  48. typedef unsigned long   size_t;
  49. #    endif
  50. #   endif
  51.  
  52. #   ifndef _WCHAR_T
  53. #    define _WCHAR_T
  54. #     if (_MIPS_SZLONG == 32)
  55. typedef long wchar_t;
  56. #     endif
  57. #     if (_MIPS_SZLONG == 64)
  58. typedef __int32_t wchar_t;
  59. #     endif
  60. #    endif /* _WCHAR_T */
  61.  
  62. #    ifndef _WINT_T
  63. #     define _WINT_T
  64. #     if (_MIPS_SZLONG == 32)
  65.         typedef long    wint_t;
  66. #     endif
  67. #     if (_MIPS_SZLONG == 64)
  68.         typedef __int32_t wint_t;
  69. #     endif
  70. #    endif /* _WINT_T */
  71.  
  72. #    ifndef _MBSTATE_T
  73. #    define _MBSTATE_T
  74. #    ifdef _MSC_VER
  75.         typedef int        mbstate_t;
  76. #    else
  77.         typedef char    mbstate_t;
  78. #    endif
  79. #    endif /* _MBSTATE_T */
  80.  
  81. #   endif /* ROOT65 */ 
  82.  
  83. #  else /* __sgi */
  84.  
  85. # ifdef __cplusplus
  86. # ifndef _STLP_CSTDDEF
  87. #  include <cstddef>
  88. # endif
  89. # ifndef _STLP_CWCHAR
  90. #  include <cwchar>
  91. # endif
  92. # ifndef _STLP_CCTYPE
  93. #  include <cctype>
  94. # endif
  95. # else
  96. #  include <stddef.h>
  97. #  include <wchar.h>
  98. #  include <ctype.h>
  99. # endif
  100.  
  101. #endif /* __sgi */
  102.  
  103. /*
  104.  * GENERAL FRAMEWORK
  105.  */
  106.  
  107. struct _Locale_ctype;
  108. struct _Locale_numeric;
  109. struct _Locale_time;
  110. struct _Locale_collate;
  111. struct _Locale_monetary;
  112. struct _Locale_messages;
  113.  
  114. /*
  115.   Bitmask macros.  
  116. */
  117.  
  118. /*
  119.  * For narrow characters, we expose the lookup table interface.
  120.  */
  121.  
  122. /* Internal bitmask macros, os-specific. */
  123.  
  124. #if defined(__sgi)              /* IRIX */
  125.  
  126. #define _Locale_S      0x00000008      /* Spacing character */
  127. #define _Locale_A      0x00004000      /* Alphabetical characters only */
  128. #define _Locale_B      0x00000040      /* Obsolete: was space char only */
  129. #define _Locale_PR     0x00008000      /* Printable characters only */
  130. #define _Locale_G      0x40000000      /* Graphic characters only */
  131. #define _Locale_BL     0x80000000      /* The blank character class */
  132.  
  133. /* Public bitmask macros, must be defined for every OS. These values, of
  134.  * course, are specific to IRIX. */
  135.  
  136. #define _Locale_CNTRL  0x00000020      /* Control character */
  137. #define _Locale_UPPER  0x00000001      /* Upper case */
  138. #define _Locale_LOWER  0x00000002      /* Lower case */
  139. #define _Locale_DIGIT  0x00000004      /* Numeral (digit) */
  140. #define _Locale_XDIGIT 0x00000080      /* heXadecimal digit */
  141. #define _Locale_PUNCT  0x00000010      /* Punctuation */
  142. #define _Locale_SPACE  (_Locale_S | _Locale_BL)
  143. #define _Locale_PRINT  (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
  144.                         _Locale_DIGIT | _Locale_A | _Locale_XDIGIT | \
  145.                         _Locale_PR)
  146. #define _Locale_ALPHA  _Locale_A
  147.  
  148. /*
  149. * All of these except for graph and blank are from the C standard;
  150. * graph and blank are XPG4.  (graph in XPG4 doesn't mean quite the
  151. * same thing as graph in the C++ library)
  152. */
  153.  
  154. #endif /* IRIX */
  155.  
  156.  
  157. #if defined( __Lynx__ )
  158.  /* azov: On Lynx isalpha defined as (_U | _L), which gives us a mask 
  159.   * unusable in ctype_table. So we have to redefine it and use hard-coded 
  160.   * numbers (to avoid potential clashes if system headers change).
  161.   *
  162.   * P.S. Actually, I see no reason in using platform-specific masks - 
  163.   * having just one set of masks for all platforms should work just as
  164.   * well - we only use them internally and they don't have to be equal 
  165.   * to whatever defined in local ctype.h
  166.   *
  167.   */ 
  168. #   define _Locale_CNTRL  040     /* _C, Control character */
  169. #   define _Locale_UPPER  01      /* _U, Upper case */
  170. #   define _Locale_LOWER  02      /* _L, Lower case */
  171. #   define _Locale_DIGIT  04      /* _N, Numeral (digit) */
  172. #   define _Locale_XDIGIT 0200    /* _X, heXadecimal digit */
  173. #   define _Locale_PUNCT  020     /* _P, Punctuation */
  174. #   define _Locale_SPACE  010     /* _S, Spacing */
  175. #   define _Locale_ALPHA  040000  /* none, Alphanumerical */
  176. #   define _Locale_PRINT  (_Locale_PUNCT | _Locale_UPPER | _Locale_LOWER | \
  177.                            _Locale_DIGIT | _Locale_ALPHA | _Locale_XDIGIT |\
  178.                            _Locale_SPACE ) /* Printable */
  179. # endif /* __Lynx__ */
  180.  
  181. #if defined(__GNUC__) || defined (__BORLANDC__) || defined (__COMO__)
  182.  
  183. # if defined (__CYGWIN__)
  184.  
  185. #  define _Locale_CNTRL  040
  186. #  define _Locale_UPPER  02
  187. #  define _Locale_LOWER  01
  188. #  define _Locale_DIGIT  04
  189. #  define _Locale_XDIGIT ( 0100 | _Locale_DIGIT )
  190. #  define _Locale_PUNCT  020
  191. #  define _Locale_SPACE  010
  192. #  define _Locale_ALPHA  (_Locale_UPPER | _Locale_LOWER)
  193. #  define _Locale_PRINT  (_Locale_ALPHA | _Locale_DIGIT | _Locale_PUNCT | 0200 )
  194.  
  195. # elif defined (__FreeBSD__)
  196.  
  197. # define _Locale_CNTRL _CTYPE_C
  198. # define _Locale_UPPER _CTYPE_U
  199. # define _Locale_LOWER _CTYPE_L
  200. # define _Locale_DIGIT _CTYPE_D
  201. # define _Locale_XDIGIT _CTYPE_X
  202. # define _Locale_PUNCT _CTYPE_P
  203. # define _Locale_SPACE _CTYPE_S
  204. # define _Locale_PRINT _CTYPE_R
  205. # define _Locale_ALPHA _CTYPE_A
  206.  
  207. # elif defined (__NetBSD__) || defined (__amigaos__)
  208.  
  209. # define _Locale_CNTRL _C
  210. # define _Locale_UPPER _U
  211. # define _Locale_LOWER _L
  212. # define _Locale_DIGIT _N
  213. # define _Locale_XDIGIT (_N|_X)
  214. # define _Locale_PUNCT _P
  215. # define _Locale_SPACE _S
  216. # define _Locale_PRINT (_P|_U|_L|_N|_B)
  217. # define _Locale_ALPHA (_U|_L)
  218.  
  219. # elif defined(_STLP_USE_GLIBC) /* linux, using the gnu compiler */
  220.  
  221. /* This section uses macros defined in the gnu libc ctype.h header */
  222.  
  223. #  define _Locale_CNTRL  _IScntrl
  224. #  define _Locale_UPPER  _ISupper
  225. #  define _Locale_LOWER  _ISlower
  226. #  define _Locale_DIGIT  _ISdigit
  227. #  define _Locale_XDIGIT _ISxdigit
  228. #  define _Locale_PUNCT  _ISpunct
  229. #  define _Locale_SPACE  _ISspace
  230. #  define _Locale_PRINT  _ISprint
  231. #  define _Locale_ALPHA  _ISalpha
  232.  
  233. #  endif /* GLIBC */
  234.  
  235. #endif /* gnu */
  236.  
  237. #if ( defined(__sun) && defined (__SVR4) ) \
  238.     || (defined (__digital__) && defined (__unix__)) \
  239.     || defined(_AIX)
  240. /* fbp : condition from AT&T code*/
  241. #if !(defined(__XPG4_CHAR_CLASS__) || defined(_XPG4_2) || \
  242.     (defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4))) && ! defined (_ISCNTRL)
  243.   /* fbp : on 2.5.1, the defines are different ;( */
  244.   // # if ( defined (__sun) && defined (__SVR4) && ! defined (_ISCNTRL) )
  245. #   define _ISCNTRL _C
  246. #   define _ISUPPER _U
  247. #   define _ISLOWER _L
  248. #   define _ISDIGIT _N
  249. #   define _ISXDIGIT _X
  250. #   define _ISPUNCT _P
  251. #   define _ISSPACE _S
  252. #   define _ISPRINT (_P | _U | _L | _N | _B)
  253. #   define _ISALPHA (_U | _L)
  254. #  endif 
  255.  
  256. #  define _Locale_CNTRL  _ISCNTRL
  257. #  define _Locale_UPPER  _ISUPPER
  258. #  define _Locale_LOWER  _ISLOWER
  259. #  define _Locale_DIGIT  _ISDIGIT
  260. #  define _Locale_XDIGIT _ISXDIGIT
  261. #  define _Locale_PUNCT  _ISPUNCT
  262. #  define _Locale_SPACE  _ISSPACE
  263. #  define _Locale_PRINT  _ISPRINT
  264. #  define _Locale_ALPHA  _ISALPHA
  265. #elif defined (__MWERKS__)
  266. #  define _Locale_CNTRL  __control_char
  267. #  define _Locale_UPPER  __upper_case
  268. #  define _Locale_LOWER  __lower_case
  269. #  define _Locale_DIGIT  __digit
  270. #  define _Locale_XDIGIT __hex_digit
  271. #  define _Locale_PUNCT  __punctuation
  272. #  define _Locale_SPACE  __space_char
  273. #  define _Locale_PRINT  __printable
  274. #  define _Locale_ALPHA  __alphanumeric
  275. #elif defined (__BORLANDC__)
  276. #  define _Locale_CNTRL  _IS_CTL
  277. #  define _Locale_UPPER  _IS_UPP
  278. #  define _Locale_LOWER  _IS_LOW
  279. #  define _Locale_DIGIT  _IS_DIG
  280. #  define _Locale_XDIGIT _IS_HEX
  281. #  define _Locale_PUNCT  _IS_PUN
  282. #  define _Locale_SPACE  _IS_SP
  283. #  define _Locale_PRINT  (_IS_SP|_IS_PUN|_IS_UPP|_IS_LOW|_IS_DIG)
  284. #  define _Locale_ALPHA  _IS_ALPHA
  285. #elif defined (_MSC_VER) || defined (__MINGW32__)
  286. #  define _Locale_CNTRL  _CONTROL
  287. #  define _Locale_UPPER  _UPPER
  288. #  define _Locale_LOWER  _LOWER
  289. #  define _Locale_DIGIT  _DIGIT
  290. #  define _Locale_XDIGIT _HEX
  291. #  define _Locale_PUNCT  _PUNCT
  292. #  define _Locale_SPACE  _SPACE
  293. #  define _Locale_PRINT  (_ALPHA | _DIGIT | _BLANK | _PUNCT)
  294. // is this one has to be so complex ?  
  295. #  define _Locale_ALPHA  ( _ALPHA & ~ (_UPPER | _LOWER )) 
  296. #elif defined(__MRC__) || defined(__SC__)        //*TY 02/24/2000 - added support for MPW
  297. #  define _Locale_CNTRL  _CTL
  298. #  define _Locale_UPPER  _UPP
  299. #  define _Locale_LOWER  _LOW
  300. #  define _Locale_DIGIT  _DIG
  301. #  define _Locale_XDIGIT _HEX
  302. #  define _Locale_PUNCT  _PUN
  303. #  define _Locale_SPACE  _BLA
  304. #  define _Locale_PRINT  (_UPP | _LOW | _DIG | _PUN | _BLA)
  305. #  define _Locale_ALPHA  (_UPP | _LOW)
  306. #elif defined(__MLCCPP__)
  307. #  define _Locale_CNTRL    1
  308. #  define _Locale_UPPER    2
  309. #  define _Locale_LOWER    4
  310. #  define _Locale_DIGIT    8
  311. #  define _Locale_XDIGIT  16
  312. #  define _Locale_PUNCT   32
  313. #  define _Locale_SPACE   64
  314. #  define _Locale_PRINT  128
  315. #  define _Locale_ALPHA  256
  316.  
  317. # elif defined (__GNUC__) && defined (__APPLE__)
  318.  
  319. # define _Locale_CNTRL _C
  320. # define _Locale_UPPER _U
  321. # define _Locale_LOWER _L
  322. # define _Locale_DIGIT _D
  323. # define _Locale_XDIGIT _X
  324. # define _Locale_PUNCT _P
  325. # define _Locale_SPACE _S
  326. # define _Locale_PRINT _R
  327. # define _Locale_ALPHA _A
  328.  
  329. # elif defined (__hpux) || defined (__osf__)
  330.  
  331. #   if defined(__HP_aCC) && !defined(_INCLUDE_HPUX_SOURCE)
  332. #     define _ISALPHA      0x001
  333. #     define _ISALNUM      0x002
  334. #     define _ISBLANK      0x004
  335. #     define _ISCNTRL      0x008
  336. #     define _ISDIGIT      0x010
  337. #     define _ISGRAPH      0x020
  338. #     define _ISLOWER      0x040
  339. #     define _ISPRINT      0x080
  340. #     define _ISPUNCT      0x100
  341. #     define _ISSPACE      0x200
  342. #     define _ISUPPER      0x400
  343. #     define _ISXDIGIT     0x800
  344. #  endif
  345. #  define _Locale_CNTRL  _ISCNTRL
  346. #  define _Locale_UPPER  _ISUPPER
  347. #  define _Locale_LOWER  _ISLOWER
  348. #  define _Locale_DIGIT  _ISDIGIT
  349. #  define _Locale_XDIGIT _ISXDIGIT
  350. #  define _Locale_PUNCT  _ISPUNCT
  351. #  define _Locale_SPACE  _ISSPACE
  352. #  define _Locale_PRINT  _ISPRINT
  353. #  define _Locale_ALPHA  _ISALPHA
  354. # elif defined (__MVS__) || defined(__OS400__)
  355. #  define _Locale_CNTRL __ISCNTRL
  356. #  define _Locale_UPPER __ISUPPER
  357. #  define _Locale_LOWER __ISLOWER
  358. #  define _Locale_DIGIT __ISDIGIT
  359. #  define _Locale_XDIGIT __ISXDIGIT
  360. #  define _Locale_PUNCT __ISPUNCT
  361. #  define _Locale_SPACE __ISSPACE
  362. #  define _Locale_PRINT __ISPRINT
  363. #  define _Locale_ALPHA __ISALPHA
  364. # elif defined (__QNXNTO__)  || defined (__WATCOMC__)
  365. # define _Locale_CNTRL _CNTRL
  366. # define _Locale_UPPER _UPPER
  367. # define _Locale_LOWER _LOWER
  368. # define _Locale_DIGIT _DIGIT
  369. # define _Locale_XDIGIT _XDIGT
  370. # define _Locale_PUNCT _PUNCT
  371. # define _Locale_SPACE _SPACE
  372. # define _Locale_PRINT _PRINT
  373. # define _Locale_ALPHA (_UPPER | _LOWER)
  374. #elif defined (__DJGPP)
  375. #  define _Locale_CNTRL  __dj_ISCNTRL
  376. #  define _Locale_UPPER  __dj_ISUPPER
  377. #  define _Locale_LOWER  __dj_ISLOWER
  378. #  define _Locale_DIGIT  __dj_ISDIGIT
  379. #  define _Locale_XDIGIT __dj_ISXDIGIT
  380. #  define _Locale_PUNCT  __dj_ISPUNCT
  381. #  define _Locale_SPACE  __dj_ISSPACE
  382. #  define _Locale_PRINT  __dj_ISPRINT
  383. #  define _Locale_ALPHA  __dj_ISALPHA
  384. #elif defined (_STLP_SCO_OPENSERVER)
  385. #  define _Locale_CNTRL _C
  386. #  define _Locale_UPPER _U
  387. #  define _Locale_LOWER _L
  388. #  define _Locale_DIGIT _N
  389. #  define _Locale_XDIGIT _X
  390. #  define _Locale_PUNCT _P
  391. #  define _Locale_SPACE _S
  392. #  define _Locale_PRINT _R
  393. #  define _Locale_ALPHA _A
  394. #elif defined (__NCR_SVR)
  395. #  define _Locale_CNTRL _C
  396. #  define _Locale_UPPER _U
  397. #  define _Locale_LOWER _L
  398. #  define _Locale_DIGIT _N
  399. #  define _Locale_XDIGIT _X
  400. #  define _Locale_PUNCT _P
  401. #  define _Locale_SPACE _S
  402. #  define _Locale_PRINT (_P | _U | _L | _N | _B)
  403. #  define _Locale_ALPHA (_U | _L)
  404. #endif
  405.  
  406. # endif /* _STLP_C_LOCALE_H */
  407.