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