cwchar 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. // -*- C++ -*- forwarding header.
  2. // Copyright (C) 1997-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file include/cwchar
  21. * This is a Standard C++ Library file. You should @c #include this file
  22. * in your programs, rather than any of the @a *.h implementation files.
  23. *
  24. * This is the C++ version of the Standard C Library header @c wchar.h,
  25. * and its contents are (mostly) the same as that header, but are all
  26. * contained in the namespace @c std (except for names which are defined
  27. * as macros in C).
  28. */
  29. //
  30. // ISO C++ 14882: 21.4
  31. //
  32. #ifndef _GLIBCXX_CWCHAR
  33. #define _GLIBCXX_CWCHAR 1
  34. #pragma GCC system_header
  35. #include <bits/c++config.h>
  36. #if _GLIBCXX_HAVE_WCHAR_H
  37. #include <wchar.h>
  38. #endif
  39. // Need to do a bit of trickery here with mbstate_t as char_traits
  40. // assumes it is in wchar.h, regardless of wchar_t specializations.
  41. #ifndef _GLIBCXX_HAVE_MBSTATE_T
  42. extern "C"
  43. {
  44. typedef struct
  45. {
  46. int __fill[6];
  47. } mbstate_t;
  48. }
  49. #endif
  50. namespace std
  51. {
  52. using ::mbstate_t;
  53. } // namespace std
  54. // Get rid of those macros defined in <wchar.h> in lieu of real functions.
  55. #undef btowc
  56. #undef fgetwc
  57. #undef fgetws
  58. #undef fputwc
  59. #undef fputws
  60. #undef fwide
  61. #undef fwprintf
  62. #undef fwscanf
  63. #undef getwc
  64. #undef getwchar
  65. #undef mbrlen
  66. #undef mbrtowc
  67. #undef mbsinit
  68. #undef mbsrtowcs
  69. #undef putwc
  70. #undef putwchar
  71. #undef swprintf
  72. #undef swscanf
  73. #undef ungetwc
  74. #undef vfwprintf
  75. #if _GLIBCXX_HAVE_VFWSCANF
  76. # undef vfwscanf
  77. #endif
  78. #undef vswprintf
  79. #if _GLIBCXX_HAVE_VSWSCANF
  80. # undef vswscanf
  81. #endif
  82. #undef vwprintf
  83. #if _GLIBCXX_HAVE_VWSCANF
  84. # undef vwscanf
  85. #endif
  86. #undef wcrtomb
  87. #undef wcscat
  88. #undef wcschr
  89. #undef wcscmp
  90. #undef wcscoll
  91. #undef wcscpy
  92. #undef wcscspn
  93. #undef wcsftime
  94. #undef wcslen
  95. #undef wcsncat
  96. #undef wcsncmp
  97. #undef wcsncpy
  98. #undef wcspbrk
  99. #undef wcsrchr
  100. #undef wcsrtombs
  101. #undef wcsspn
  102. #undef wcsstr
  103. #undef wcstod
  104. #if _GLIBCXX_HAVE_WCSTOF
  105. # undef wcstof
  106. #endif
  107. #undef wcstok
  108. #undef wcstol
  109. #undef wcstoul
  110. #undef wcsxfrm
  111. #undef wctob
  112. #undef wmemchr
  113. #undef wmemcmp
  114. #undef wmemcpy
  115. #undef wmemmove
  116. #undef wmemset
  117. #undef wprintf
  118. #undef wscanf
  119. #if _GLIBCXX_USE_WCHAR_T
  120. namespace std _GLIBCXX_VISIBILITY(default)
  121. {
  122. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  123. using ::wint_t;
  124. using ::btowc;
  125. using ::fgetwc;
  126. using ::fgetws;
  127. using ::fputwc;
  128. using ::fputws;
  129. using ::fwide;
  130. using ::fwprintf;
  131. using ::fwscanf;
  132. using ::getwc;
  133. using ::getwchar;
  134. using ::mbrlen;
  135. using ::mbrtowc;
  136. using ::mbsinit;
  137. using ::mbsrtowcs;
  138. using ::putwc;
  139. using ::putwchar;
  140. using ::swprintf;
  141. using ::swscanf;
  142. using ::ungetwc;
  143. using ::vfwprintf;
  144. #if _GLIBCXX_HAVE_VFWSCANF
  145. using ::vfwscanf;
  146. #endif
  147. using ::vswprintf;
  148. #if _GLIBCXX_HAVE_VSWSCANF
  149. using ::vswscanf;
  150. #endif
  151. using ::vwprintf;
  152. #if _GLIBCXX_HAVE_VWSCANF
  153. using ::vwscanf;
  154. #endif
  155. using ::wcrtomb;
  156. using ::wcscat;
  157. using ::wcscmp;
  158. using ::wcscoll;
  159. using ::wcscpy;
  160. using ::wcscspn;
  161. using ::wcsftime;
  162. using ::wcslen;
  163. using ::wcsncat;
  164. using ::wcsncmp;
  165. using ::wcsncpy;
  166. using ::wcsrtombs;
  167. using ::wcsspn;
  168. using ::wcstod;
  169. #if _GLIBCXX_HAVE_WCSTOF
  170. using ::wcstof;
  171. #endif
  172. using ::wcstok;
  173. using ::wcstol;
  174. using ::wcstoul;
  175. using ::wcsxfrm;
  176. using ::wctob;
  177. using ::wmemcmp;
  178. using ::wmemcpy;
  179. using ::wmemmove;
  180. using ::wmemset;
  181. using ::wprintf;
  182. using ::wscanf;
  183. using ::wcschr;
  184. using ::wcspbrk;
  185. using ::wcsrchr;
  186. using ::wcsstr;
  187. using ::wmemchr;
  188. #ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  189. inline wchar_t*
  190. wcschr(wchar_t* __p, wchar_t __c)
  191. { return wcschr(const_cast<const wchar_t*>(__p), __c); }
  192. inline wchar_t*
  193. wcspbrk(wchar_t* __s1, const wchar_t* __s2)
  194. { return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
  195. inline wchar_t*
  196. wcsrchr(wchar_t* __p, wchar_t __c)
  197. { return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
  198. inline wchar_t*
  199. wcsstr(wchar_t* __s1, const wchar_t* __s2)
  200. { return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
  201. inline wchar_t*
  202. wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
  203. { return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
  204. #endif
  205. _GLIBCXX_END_NAMESPACE_VERSION
  206. } // namespace
  207. #if _GLIBCXX_USE_C99_WCHAR
  208. #undef wcstold
  209. #undef wcstoll
  210. #undef wcstoull
  211. namespace __gnu_cxx
  212. {
  213. #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
  214. extern "C" long double
  215. (wcstold)(const wchar_t * __restrict, wchar_t ** __restrict) throw ();
  216. #endif
  217. #if !_GLIBCXX_USE_C99_DYNAMIC
  218. using ::wcstold;
  219. #endif
  220. #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
  221. extern "C" long long int
  222. (wcstoll)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
  223. extern "C" unsigned long long int
  224. (wcstoull)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
  225. #endif
  226. #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
  227. using ::wcstoll;
  228. using ::wcstoull;
  229. #endif
  230. } // namespace __gnu_cxx
  231. namespace std
  232. {
  233. using ::__gnu_cxx::wcstold;
  234. using ::__gnu_cxx::wcstoll;
  235. using ::__gnu_cxx::wcstoull;
  236. } // namespace std
  237. #endif
  238. #endif //_GLIBCXX_USE_WCHAR_T
  239. #endif