cwchar 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. // -*- C++ -*-
  2. //===--------------------------- cwchar -----------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_CWCHAR
  11. #define _LIBCPP_CWCHAR
  12. /*
  13. cwchar synopsis
  14. Macros:
  15. NULL
  16. WCHAR_MAX
  17. WCHAR_MIN
  18. WEOF
  19. namespace std
  20. {
  21. Types:
  22. mbstate_t
  23. size_t
  24. tm
  25. wint_t
  26. int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
  27. int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
  28. int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
  29. int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
  30. int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
  31. int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
  32. int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
  33. int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
  34. int vwprintf(const wchar_t* restrict format, va_list arg);
  35. int vwscanf(const wchar_t* restrict format, va_list arg); // C99
  36. int wprintf(const wchar_t* restrict format, ...);
  37. int wscanf(const wchar_t* restrict format, ...);
  38. wint_t fgetwc(FILE* stream);
  39. wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
  40. wint_t fputwc(wchar_t c, FILE* stream);
  41. int fputws(const wchar_t* restrict s, FILE* restrict stream);
  42. int fwide(FILE* stream, int mode);
  43. wint_t getwc(FILE* stream);
  44. wint_t getwchar();
  45. wint_t putwc(wchar_t c, FILE* stream);
  46. wint_t putwchar(wchar_t c);
  47. wint_t ungetwc(wint_t c, FILE* stream);
  48. double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
  49. float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
  50. long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
  51. long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
  52. long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
  53. unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
  54. unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
  55. wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
  56. wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
  57. wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
  58. wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
  59. int wcscmp(const wchar_t* s1, const wchar_t* s2);
  60. int wcscoll(const wchar_t* s1, const wchar_t* s2);
  61. int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
  62. size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
  63. const wchar_t* wcschr(const wchar_t* s, wchar_t c);
  64. wchar_t* wcschr( wchar_t* s, wchar_t c);
  65. size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
  66. size_t wcslen(const wchar_t* s);
  67. const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
  68. wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
  69. const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
  70. wchar_t* wcsrchr( wchar_t* s, wchar_t c);
  71. size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
  72. const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
  73. wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
  74. wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
  75. const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
  76. wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
  77. int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
  78. wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
  79. wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
  80. wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
  81. size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
  82. const tm* restrict timeptr);
  83. wint_t btowc(int c);
  84. int wctob(wint_t c);
  85. int mbsinit(const mbstate_t* ps);
  86. size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
  87. size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
  88. size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
  89. size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
  90. mbstate_t* restrict ps);
  91. size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
  92. mbstate_t* restrict ps);
  93. } // std
  94. */
  95. #include <__config>
  96. #include <cwctype>
  97. #include <wchar.h>
  98. #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
  99. #if !defined(_LIBCPP_SGX_CONFIG)
  100. #include <support/win32/support.h> // pull in *swprintf defines
  101. #endif // !defined(_LIBCPP_SGX_CONFIG)
  102. #endif // _LIBCPP_MSVCRT
  103. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  104. #pragma GCC system_header
  105. #endif
  106. _LIBCPP_BEGIN_NAMESPACE_STD
  107. using ::mbstate_t;
  108. using ::size_t;
  109. #ifndef _LIBCPP_SGX_CONFIG
  110. using ::tm;
  111. #endif //_LIBCPP_SGX_CONFIG
  112. using ::wint_t;
  113. #ifndef _LIBCPP_SGX_CONFIG
  114. using ::FILE;
  115. using ::fwprintf;
  116. using ::fwscanf;
  117. #endif //_LIBCPP_SGX_CONFIG
  118. using ::swprintf;
  119. #ifndef _LIBCPP_SGX_CONFIG
  120. using ::vfwprintf;
  121. #endif //_LIBCPP_SGX_CONFIG
  122. using ::vswprintf;
  123. #ifndef _LIBCPP_SGX_CONFIG
  124. using ::swscanf;
  125. using ::vfwscanf;
  126. using ::vswscanf;
  127. #endif // _LIBCPP_SGX_CONFIG
  128. #ifndef _LIBCPP_SGX_CONFIG
  129. using ::fgetwc;
  130. using ::fgetws;
  131. using ::fputwc;
  132. using ::fputws;
  133. using ::fwide;
  134. using ::getwc;
  135. using ::putwc;
  136. using ::ungetwc;
  137. using ::wcstod;
  138. #endif //_LIBCPP_SGX_CONFIG
  139. #ifndef _LIBCPP_SGX_CONFIG
  140. using ::wcstof;
  141. using ::wcstold;
  142. #endif // _LIBCPP_SGX_CONFIG
  143. #ifndef _LIBCPP_SGX_CONFIG
  144. using ::wcstol;
  145. #ifndef _LIBCPP_HAS_NO_LONG_LONG
  146. using ::wcstoll;
  147. #endif // _LIBCPP_HAS_NO_LONG_LONG
  148. using ::wcstoul;
  149. #ifndef _LIBCPP_HAS_NO_LONG_LONG
  150. using ::wcstoull;
  151. #endif // _LIBCPP_HAS_NO_LONG_LONG
  152. using ::wcscpy;
  153. #endif //_LIBCPP_SGX_CONFIG
  154. using ::wcsncpy;
  155. #ifndef _LIBCPP_SGX_CONFIG
  156. using ::wcscat;
  157. #endif //_LIBCPP_SGX_CONFIG
  158. using ::wcsncat;
  159. using ::wcscmp;
  160. using ::wcscoll;
  161. using ::wcsncmp;
  162. using ::wcsxfrm;
  163. #if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
  164. using ::wcschr;
  165. using ::wcspbrk;
  166. using ::wcsrchr;
  167. using ::wcsstr;
  168. using ::wmemchr;
  169. #else
  170. inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
  171. inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
  172. inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
  173. inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
  174. inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
  175. inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
  176. inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
  177. inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
  178. inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
  179. inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
  180. #endif
  181. using ::wcscspn;
  182. using ::wcslen;
  183. using ::wcsspn;
  184. using ::wcstok;
  185. using ::wmemcmp;
  186. using ::wmemcpy;
  187. using ::wmemmove;
  188. using ::wmemset;
  189. #ifndef _LIBCPP_SGX_CONFIG
  190. using ::wcsftime;
  191. #endif _LIBCPP_SGX_CONFIG
  192. using ::btowc;
  193. using ::wctob;
  194. using ::mbsinit;
  195. using ::mbrlen;
  196. using ::mbrtowc;
  197. using ::wcrtomb;
  198. using ::mbsrtowcs;
  199. using ::wcsrtombs;
  200. #ifndef _LIBCPP_HAS_NO_STDIN
  201. using ::getwchar;
  202. #ifndef _LIBCPP_MSVCRT
  203. using ::vwscanf;
  204. #endif // _LIBCPP_MSVCRT
  205. using ::wscanf;
  206. #endif
  207. #ifndef _LIBCPP_HAS_NO_STDOUT
  208. using ::putwchar;
  209. using ::vwprintf;
  210. using ::wprintf;
  211. #endif
  212. _LIBCPP_END_NAMESPACE_STD
  213. #endif // _LIBCPP_CWCHAR