home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / wctype.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  6KB  |  220 lines

  1. /***
  2. *wctype.h - declarations for wide character functions
  3. *
  4. *       Copyright (c) 1992-1997, Microsoft Corporation. All rights reserved.
  5. *       Created from wchar.h January 1996 by P.J. Plauger
  6. *
  7. *Purpose:
  8. *       This file contains the types, macros and function declarations for
  9. *       all ctype-style wide-character functions.  They may also be declared in
  10. *       wchar.h.
  11. *       [ISO]
  12. *
  13. *       Note: keep in sync with ctype.h and wchar.h.
  14. *
  15. *       [Public]
  16. *
  17. ****/
  18.  
  19.  
  20. #if     _MSC_VER > 1000 /*IFSTRIP=IGN*/
  21. #pragma once
  22. #endif
  23.  
  24. #ifndef _MAC
  25.  
  26. #ifndef _INC_WCTYPE
  27. #define _INC_WCTYPE
  28.  
  29. #if     !defined(_WIN32) && !defined(_MAC)
  30. #error ERROR: Only Mac or Win32 targets supported!
  31. #endif
  32.  
  33.  
  34. #ifdef  _MSC_VER
  35. #pragma pack(push,8)
  36. #endif  /* _MSC_VER */
  37.  
  38. #ifdef  __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42.  
  43. /* Define _CRTIMP */
  44.  
  45. #ifndef _CRTIMP
  46. #ifdef  _DLL
  47. #define _CRTIMP __declspec(dllimport)
  48. #else   /* ndef _DLL */
  49. #define _CRTIMP
  50. #endif  /* _DLL */
  51. #endif  /* _CRTIMP */
  52.  
  53. /* Define _CRTIMP2 */
  54. #ifndef _CRTIMP2
  55. #ifdef  CRTDLL2
  56. #define _CRTIMP2 __declspec(dllexport)
  57. #else   /* ndef CRTDLL2 */
  58. #ifdef  _DLL
  59. #define _CRTIMP2 __declspec(dllimport)
  60. #else   /* ndef _DLL */
  61. #define _CRTIMP2
  62. #endif  /* _DLL */
  63. #endif  /* CRTDLL2 */
  64. #endif  /* _CRTIMP2 */
  65.  
  66. /* Define __cdecl for non-Microsoft compilers */
  67.  
  68. #if     ( !defined(_MSC_VER) && !defined(__cdecl) )
  69. #define __cdecl
  70. #endif
  71.  
  72. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  73.  
  74. #ifndef _CRTAPI1
  75. #if    _MSC_VER >= 800 && _M_IX86 >= 300 /*IFSTRIP=IGN*/
  76. #define _CRTAPI1 __cdecl
  77. #else
  78. #define _CRTAPI1
  79. #endif
  80. #endif
  81.  
  82.  
  83. #ifndef _WCHAR_T_DEFINED
  84. typedef unsigned short wchar_t;
  85. #define _WCHAR_T_DEFINED
  86. #endif
  87.  
  88. #ifndef _WCTYPE_T_DEFINED
  89. typedef wchar_t wint_t;
  90. typedef wchar_t wctype_t;
  91. #define _WCTYPE_T_DEFINED
  92. #endif
  93.  
  94.  
  95. #ifndef WEOF
  96. #define WEOF (wint_t)(0xFFFF)
  97. #endif
  98.  
  99. /*
  100.  * This declaration allows the user access to the ctype look-up
  101.  * array _ctype defined in ctype.obj by simply including ctype.h
  102.  */
  103.  
  104. _CRTIMP extern unsigned short _ctype[];
  105.  
  106. #if     defined(_DLL) && defined(_M_IX86)
  107. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  108. _CRTIMP unsigned short ** __cdecl __p__pctype(void);
  109. _CRTIMP wctype_t ** __cdecl ___p__pwctype(void);
  110. #endif
  111. _CRTIMP extern unsigned short *_pctype;
  112. _CRTIMP extern wctype_t *_pwctype;
  113.  
  114.  
  115. /* set bit masks for the possible character types */
  116.  
  117. #define _UPPER          0x1     /* upper case letter */
  118. #define _LOWER          0x2     /* lower case letter */
  119. #define _DIGIT          0x4     /* digit[0-9] */
  120. #define _SPACE          0x8     /* tab, carriage return, newline, */
  121.                                 /* vertical tab or form feed */
  122. #define _PUNCT          0x10    /* punctuation character */
  123. #define _CONTROL        0x20    /* control character */
  124. #define _BLANK          0x40    /* space char */
  125. #define _HEX            0x80    /* hexadecimal digit */
  126.  
  127. #define _LEADBYTE       0x8000                  /* multibyte leadbyte */
  128. #define _ALPHA          (0x0100|_UPPER|_LOWER)  /* alphabetic character */
  129.  
  130.  
  131. /* Function prototypes */
  132.  
  133. #ifndef _WCTYPE_DEFINED
  134.  
  135. /* Character classification function prototypes */
  136. /* also declared in ctype.h */
  137.  
  138. _CRTIMP int __cdecl iswalpha(wint_t);
  139. _CRTIMP int __cdecl iswupper(wint_t);
  140. _CRTIMP int __cdecl iswlower(wint_t);
  141. _CRTIMP int __cdecl iswdigit(wint_t);
  142. _CRTIMP int __cdecl iswxdigit(wint_t);
  143. _CRTIMP int __cdecl iswspace(wint_t);
  144. _CRTIMP int __cdecl iswpunct(wint_t);
  145. _CRTIMP int __cdecl iswalnum(wint_t);
  146. _CRTIMP int __cdecl iswprint(wint_t);
  147. _CRTIMP int __cdecl iswgraph(wint_t);
  148. _CRTIMP int __cdecl iswcntrl(wint_t);
  149. _CRTIMP int __cdecl iswascii(wint_t);
  150. _CRTIMP int __cdecl isleadbyte(int);
  151.  
  152. _CRTIMP wchar_t __cdecl towupper(wchar_t);
  153. _CRTIMP wchar_t __cdecl towlower(wchar_t);
  154.  
  155. _CRTIMP int __cdecl iswctype(wint_t, wctype_t);
  156.  
  157. /* --------- The following functions are OBSOLETE --------- */
  158. _CRTIMP int __cdecl is_wctype(wint_t, wctype_t);
  159. /*  --------- The preceding functions are OBSOLETE --------- */
  160.  
  161. #define _WCTYPE_DEFINED
  162. #endif
  163.  
  164. #ifndef _WCTYPE_INLINE_DEFINED
  165. #ifndef __cplusplus
  166. #define iswalpha(_c)    ( iswctype(_c,_ALPHA) )
  167. #define iswupper(_c)    ( iswctype(_c,_UPPER) )
  168. #define iswlower(_c)    ( iswctype(_c,_LOWER) )
  169. #define iswdigit(_c)    ( iswctype(_c,_DIGIT) )
  170. #define iswxdigit(_c)   ( iswctype(_c,_HEX) )
  171. #define iswspace(_c)    ( iswctype(_c,_SPACE) )
  172. #define iswpunct(_c)    ( iswctype(_c,_PUNCT) )
  173. #define iswalnum(_c)    ( iswctype(_c,_ALPHA|_DIGIT) )
  174. #define iswprint(_c)    ( iswctype(_c,_BLANK|_PUNCT|_ALPHA|_DIGIT) )
  175. #define iswgraph(_c)    ( iswctype(_c,_PUNCT|_ALPHA|_DIGIT) )
  176. #define iswcntrl(_c)    ( iswctype(_c,_CONTROL) )
  177. #define iswascii(_c)    ( (unsigned)(_c) < 0x80 )
  178.  
  179. #define isleadbyte(_c)  (_pctype[(unsigned char)(_c)] & _LEADBYTE)
  180. #else   /* __cplusplus */
  181. inline int __cdecl iswalpha(wint_t _C) {return (iswctype(_C,_ALPHA)); }
  182. inline int __cdecl iswupper(wint_t _C) {return (iswctype(_C,_UPPER)); }
  183. inline int __cdecl iswlower(wint_t _C) {return (iswctype(_C,_LOWER)); }
  184. inline int __cdecl iswdigit(wint_t _C) {return (iswctype(_C,_DIGIT)); }
  185. inline int __cdecl iswxdigit(wint_t _C) {return (iswctype(_C,_HEX)); }
  186. inline int __cdecl iswspace(wint_t _C) {return (iswctype(_C,_SPACE)); }
  187. inline int __cdecl iswpunct(wint_t _C) {return (iswctype(_C,_PUNCT)); }
  188. inline int __cdecl iswalnum(wint_t _C) {return (iswctype(_C,_ALPHA|_DIGIT)); }
  189. inline int __cdecl iswprint(wint_t _C)
  190.         {return (iswctype(_C,_BLANK|_PUNCT|_ALPHA|_DIGIT)); }
  191. inline int __cdecl iswgraph(wint_t _C)
  192.         {return (iswctype(_C,_PUNCT|_ALPHA|_DIGIT)); }
  193. inline int __cdecl iswcntrl(wint_t _C) {return (iswctype(_C,_CONTROL)); }
  194. inline int __cdecl iswascii(wint_t _C) {return ((unsigned)(_C) < 0x80); }
  195.  
  196. inline int __cdecl isleadbyte(int _C)
  197.         {return (_pctype[(unsigned char)(_C)] & _LEADBYTE); }
  198. #endif  /* __cplusplus */
  199. #define _WCTYPE_INLINE_DEFINED
  200. #endif  /* _WCTYPE_INLINE_DEFINED */
  201.  
  202. typedef wchar_t wctrans_t;
  203. _CRTIMP2 wint_t __cdecl towctrans(wint_t, wctrans_t);
  204. _CRTIMP2 wctrans_t __cdecl wctrans(const char *);
  205. _CRTIMP2 wctype_t __cdecl wctype(const char *);
  206.  
  207.  
  208. #ifdef  __cplusplus
  209. }
  210. #endif
  211.  
  212. #ifdef  _MSC_VER
  213. #pragma pack(pop)
  214. #endif  /* _MSC_VER */
  215.  
  216. #endif  /* _INC_WCTYPE */
  217.  
  218. #endif  /* ndef _MAC */
  219.  
  220.