home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / stlport / cwchar < prev    next >
Text File  |  2002-04-29  |  9KB  |  314 lines

  1. /*
  2.  * Copyright (c) 1999 
  3.  * Boris Fomitchev
  4.  *
  5.  * This material is provided "as is", with absolutely no warranty expressed
  6.  * or implied. Any use is at your own risk.
  7.  *
  8.  * Permission to use or copy this software for any purpose is hereby granted 
  9.  * without fee, provided the above notices are retained on all copies.
  10.  * Permission to modify the code and to distribute modified code is granted,
  11.  * provided the above notices are retained, and a notice that the code was
  12.  * modified is included with the above copyright notice.
  13.  *
  14.  */
  15.  
  16. #ifndef _STLP_CWCHAR
  17. # define _STLP_CWCHAR
  18.  
  19. # ifndef _STLP_OUTERMOST_HEADER_ID
  20. #  define _STLP_OUTERMOST_HEADER_ID 0x120
  21. #  include <stl/_prolog.h>
  22. # endif
  23.  
  24. # ifdef __GNUC__
  25. #  include <cstddef>
  26. # endif
  27.  
  28. # if defined (__BORLANDC__) &&  (__BORLANDC__ >= 0x530 ) && ! defined (_STLP_OWN_IOSTREAMS)
  29. /*  Borland defines this stuff here */
  30. #   include <iosfwd>
  31. # endif
  32.  
  33. # if !  defined (_STLP_NO_CWCHAR) && defined  (_STLP_USE_NEW_C_HEADERS)
  34. #  include _STLP_NATIVE_CPP_C_HEADER(cwchar)
  35.  
  36. # elif defined (__MRC__) || defined (__SC__) || defined (__BORLANDC__) || defined(__FreeBSD__) || (defined (__GNUC__) && defined (__APPLE__) || defined( __Lynx__ )) || defined (_STLP_NO_WCHAR_T)
  37.  
  38. #  include _STLP_NATIVE_C_HEADER(stddef.h)
  39. #  if defined (__FreeBSD__) || defined (__Lynx__)
  40. #   ifndef _WINT_T
  41. typedef long int wint_t;
  42. #    define _WINT_T
  43. #   endif /* _WINT_T */
  44. #  endif
  45.  
  46. # elif defined(_STLP_WINCE)
  47. #  include _STLP_NATIVE_C_HEADER(stdlib.h)
  48. # else 
  49. #  include _STLP_NATIVE_C_HEADER(wchar.h)
  50.  
  51. #  if defined(__sun) && (defined(_XOPEN_SOURCE) || (_XOPEN_VERSION - 0 == 4))
  52. extern wint_t   btowc();
  53. extern int      fwprintf();
  54. extern int      fwscanf();
  55. extern int      fwide();
  56. extern int      mbsinit();
  57. extern size_t   mbrlen();
  58. extern size_t   mbrtowc();
  59. extern size_t   mbsrtowcs();
  60. extern int      swprintf();
  61. extern int      swscanf();
  62. extern int      vfwprintf();
  63. extern int      vwprintf();
  64. extern int      vswprintf();
  65. extern size_t   wcrtomb();
  66. extern size_t   wcsrtombs();
  67. extern wchar_t  *wcsstr();
  68. extern int      wctob();
  69. extern wchar_t  *wmemchr();
  70. extern int      wmemcmp();
  71. extern wchar_t  *wmemcpy();
  72. extern wchar_t  *wmemmove();
  73. extern wchar_t  *wmemset();
  74. extern int      wprintf();
  75. extern int      wscanf();
  76. #  endif
  77. # endif
  78.  
  79. #if defined(__MSL__) && __MSL__ <= 0x51FF    /* dwa 2/28/99 - not yet implemented by MSL  */
  80. #   define _STLP_WCHAR_MSL_EXCLUDE 1
  81. namespace std
  82.   extern "C" size_t wcsftime(wchar_t * str, size_t max_size, const wchar_t * format_str, const struct tm * timeptr);
  83. }
  84. #  define _STLP_NO_MBSTATE_T 1
  85. #elif defined (__BORLANDC__)
  86. #  ifdef _STLP_OWN_IOSTREAMS
  87. #   define _STLP_NO_NATIVE_MBSTATE_T
  88. #  endif
  89. #  define _STLP_WCHAR_BORLAND_EXCLUDE 1
  90. #  if (__BORLANDC__ < 0x540 )
  91. #   define _STLP_NO_MBSTATE_T 1
  92. #   define _STLP_WCHAR_SUNPRO_EXCLUDE
  93. #  endif
  94. #endif
  95.  
  96. # if defined ( _STLP_OWN_IOSTREAMS ) && defined (_STLP_NO_NATIVE_MBSTATE_T) && ! defined (_STLP_NO_MBSTATE_T) && ! defined (_MBSTATE_T) && ! defined (__mbstate_t_defined)
  97. #  define _STLP_USE_OWN_MBSTATE_T
  98. #  define _MBSTATE_T
  99. # endif
  100.  
  101. # ifdef _STLP_USE_OWN_MBSTATE_T
  102.  
  103. // to be compatible across different SUN platforms
  104. #ifdef __sun
  105. # define __stl_mbstate_t __mbstate_t
  106. #endif
  107.  
  108. struct __stl_mbstate_t;
  109.  
  110. # ifdef __cplusplus
  111. struct __stl_mbstate_t { 
  112.   __stl_mbstate_t( long __st = 0 ) { _M_state[0] = __st ; }
  113.   __stl_mbstate_t& operator=(const long __st) {
  114.     _M_state[0] = __st;              
  115.     return *this;
  116.   } 
  117.   __stl_mbstate_t(const __stl_mbstate_t& __x) {_M_state[0]= __x._M_state[0]; }         
  118.   __stl_mbstate_t& operator=(const __stl_mbstate_t& __x) {
  119.     _M_state[0]= __x._M_state[0];              
  120.     return *this;
  121.   }
  122. # if defined (__sun)
  123. #  ifdef _LP64
  124.   long _M_state[4];
  125. #  else
  126.   int _M_state[6];
  127. #  endif
  128. # else       
  129.   long _M_state[1];
  130. # endif
  131. };          
  132.  
  133. inline bool operator==(const __stl_mbstate_t& __x, const __stl_mbstate_t& __y) {
  134.   return ( __x._M_state[0] == __y._M_state[0] );
  135. }
  136.  
  137. inline bool operator!=(const __stl_mbstate_t& __x, const __stl_mbstate_t& __y) {
  138.   return ( __x._M_state[0] == __y._M_state[0] );
  139. }
  140. # endif
  141.  
  142.  
  143. _STLP_BEGIN_NAMESPACE
  144.  
  145. typedef struct __stl_mbstate_t mbstate_t;
  146.  
  147. _STLP_END_NAMESPACE
  148.  
  149. # endif /* _STLP_USE_OWN_MBSTATE_T */
  150.  
  151.  
  152. # ifdef _STLP_IMPORT_VENDOR_CSTD
  153.  
  154. #if defined (__SUNPRO_CC) && defined (_STLP_NO_OWN_IOSTREAMS) && !defined (_STLP_HAS_NO_NEW_C_HEADERS)
  155. using _STLP_VENDOR_CSTD::wint_t; 
  156. #endif
  157.  
  158. _STLP_BEGIN_NAMESPACE
  159. # ifdef _STLP_NO_WCHAR_T
  160. typedef int wint_t;
  161. # else
  162. // gcc 3.0 has a glitch : wint_t only sucked into the global namespace if _GLIBCPP_USE_WCHAR_T is defined
  163. #  if defined (__GNUC__) && ! defined (_GLIBCPP_USE_WCHAR_T)
  164. using ::wint_t;
  165. #  else
  166. using _STLP_VENDOR_CSTD::wint_t;
  167. #  endif
  168. # endif
  169.  
  170.  
  171. using _STLP_VENDOR_CSTD::size_t;
  172.  
  173. #  if !defined (_STLP_NO_NATIVE_MBSTATE_T) && ! defined (_STLP_USE_OWN_MBSTATE_T)
  174. using _STLP_VENDOR_MB_NAMESPACE::mbstate_t;
  175.  
  176. # if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !defined(_STLP_WCHAR_BORLAND_EXCLUDE) \
  177.   && (!defined(__MSL__) || __MSL__ > 0x6001)
  178. #  if ! (defined (__KCC) || defined (__GNUC__))
  179. using _STLP_VENDOR_MB_NAMESPACE::btowc;
  180. #   if (!defined(__MSL__) || __MSL__ > 0x7001)
  181. using _STLP_VENDOR_MB_NAMESPACE::mbsinit;
  182. #   endif
  183. #  endif
  184. # if ! defined (__GNUC__)
  185. using _STLP_VENDOR_MB_NAMESPACE::mbrlen;
  186. using _STLP_VENDOR_MB_NAMESPACE::mbrtowc;
  187. using _STLP_VENDOR_MB_NAMESPACE::mbsrtowcs;
  188. using _STLP_VENDOR_MB_NAMESPACE::wcrtomb;
  189. using _STLP_VENDOR_MB_NAMESPACE::wcsrtombs;
  190. # endif
  191. #    endif /* BORLAND && !__MSL__ || __MSL__ > 0x6001 */
  192.  
  193. #  endif /* _STLP_NO_NATIVE_MBSTATE_T */
  194.  
  195. # if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
  196.  
  197. # if !defined (_STLP_WCHAR_BORLAND_EXCLUDE) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
  198. using _STLP_VENDOR_CSTD::fgetwc;
  199. using _STLP_VENDOR_CSTD::fgetws;
  200. using _STLP_VENDOR_CSTD::fputwc;
  201. using _STLP_VENDOR_CSTD::fputws;
  202. # endif
  203.  
  204. #  if !( defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) \
  205.       || defined(_STLP_WCHAR_HPACC_EXCLUDE) || defined(_STLP_WCHAR_IBM_EXCLUDE)) //TORLAB DEBUG changed
  206.     //TORLAB original      || defined(_STLP_WCHAR_HPACC_EXCLUDE) ) 
  207. # ifndef __DECCXX
  208. using _STLP_VENDOR_CSTD::fwide;
  209. # endif
  210. using _STLP_VENDOR_CSTD::fwprintf;
  211. using _STLP_VENDOR_CSTD::fwscanf;
  212. using _STLP_VENDOR_CSTD::getwchar;
  213. #  endif
  214.  
  215. # ifndef _STLP_WCHAR_BORLAND_EXCLUDE
  216. using _STLP_VENDOR_CSTD::getwc;
  217. using _STLP_VENDOR_CSTD::ungetwc;
  218.  
  219. using _STLP_VENDOR_CSTD::putwc;
  220. using _STLP_VENDOR_CSTD::putwchar;
  221. # endif
  222.  
  223. #  if !( defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE)\
  224.       || defined(_STLP_WCHAR_HPACC_EXCLUDE) ) 
  225. using _STLP_VENDOR_CSTD::swprintf;
  226. using _STLP_VENDOR_CSTD::swscanf;
  227. using _STLP_VENDOR_CSTD::vfwprintf;
  228. using _STLP_VENDOR_CSTD::vwprintf;
  229. using _STLP_VENDOR_CSTD::vswprintf;
  230.  
  231. #   if !defined(__MSL__) || __MSL__ > 0x7001
  232. using _STLP_VENDOR_CSTD::wcsftime;
  233. #   endif
  234. using _STLP_VENDOR_CSTD::wcstok;
  235.  
  236. #  endif
  237.  
  238. # if !(defined (__BORLANDC__) && (__BORLANDC__ < 0x540))
  239. using _STLP_VENDOR_CSTD::wcscat;
  240. using _STLP_VENDOR_CSTD::wcsrchr;
  241. using _STLP_VENDOR_CSTD::wcscmp;
  242. using _STLP_VENDOR_CSTD::wcscoll;
  243.  
  244. using _STLP_VENDOR_CSTD::wcscpy;
  245. using _STLP_VENDOR_CSTD::wcscspn;
  246.  
  247. using _STLP_VENDOR_CSTD::wcslen;
  248. using _STLP_VENDOR_CSTD::wcsncat;
  249. using _STLP_VENDOR_CSTD::wcsncmp;
  250. using _STLP_VENDOR_CSTD::wcsncpy;
  251. using _STLP_VENDOR_CSTD::wcspbrk;
  252. using _STLP_VENDOR_CSTD::wcschr;
  253.  
  254. using _STLP_VENDOR_CSTD::wcsspn;
  255. using _STLP_VENDOR_CSTD::wcsxfrm;
  256.  
  257. # endif
  258.  
  259. #  if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
  260.  
  261. using _STLP_VENDOR_CSTD::wcstod;
  262. using _STLP_VENDOR_CSTD::wcstol;
  263.  
  264. # endif
  265.  
  266. #  if !( defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined(_STLP_WCHAR_HPACC_EXCLUDE) )
  267.  
  268. using _STLP_VENDOR_CSTD::wcsstr;
  269. using _STLP_VENDOR_CSTD::wmemchr;
  270.  
  271. #  if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
  272.  
  273. using _STLP_VENDOR_CSTD::wctob;
  274. using _STLP_VENDOR_CSTD::wmemcmp;
  275. using _STLP_VENDOR_CSTD::wmemmove;
  276. using _STLP_VENDOR_CSTD::wprintf;
  277. #if !defined (_STLP_WCHAR_IBM_EXCLUDE ) //TORLAB DEBUG added
  278. using _STLP_VENDOR_CSTD::wscanf;
  279. #endif //TORLAB DEBUG added
  280.  
  281. #  endif
  282.  
  283. using _STLP_VENDOR_CSTD::wmemcpy;
  284. using _STLP_VENDOR_CSTD::wmemset;
  285. #  endif
  286.  
  287. # endif /* _STLP_NO_NATIVE_WIDE_FUNCTIONS */
  288. _STLP_END_NAMESPACE
  289. # endif /* _STLP_IMPORT_VENDOR_CSTD */
  290.  
  291. # undef _STLP_WCHAR_SUNPRO_EXCLUDE
  292. # undef _STLP_WCHAR_MSL_EXCLUDE
  293.  
  294. #if !defined (_STLP_NO_WCHAR_T)
  295. # ifndef WCHAR_MIN
  296. #  define WCHAR_MIN 0
  297. // SUNpro has some bugs with casts. wchar_t is size of int there anyway.
  298. #  if defined (__SUNPRO_CC) || defined (__DJGPP)
  299. #   define WCHAR_MAX (~0)
  300. #  else
  301. #   define WCHAR_MAX ((wchar_t)~0)
  302. #  endif
  303. # endif
  304. #endif
  305.  
  306. # if (_STLP_OUTERMOST_HEADER_ID == 0x120)
  307. #  include <stl/_epilog.h>
  308. #  undef _STLP_OUTERMOST_HEADER_ID
  309. # endif
  310.  
  311. #endif /* _STLP_CWCHAR */
  312.  
  313.