cwchar 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. // -*- C++ -*- forwarding header.
  2. // Copyright (C) 1997-2015 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. #pragma GCC system_header
  33. #include <bits/c++config.h>
  34. #if _GLIBCXX_HAVE_WCHAR_H
  35. #include <wchar.h>
  36. #endif
  37. #ifndef _GLIBCXX_CWCHAR
  38. #define _GLIBCXX_CWCHAR 1
  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. #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
  141. using ::swprintf;
  142. #endif
  143. using ::swscanf;
  144. using ::ungetwc;
  145. using ::vfwprintf;
  146. #if _GLIBCXX_HAVE_VFWSCANF
  147. using ::vfwscanf;
  148. #endif
  149. #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
  150. using ::vswprintf;
  151. #endif
  152. #if _GLIBCXX_HAVE_VSWSCANF
  153. using ::vswscanf;
  154. #endif
  155. using ::vwprintf;
  156. #if _GLIBCXX_HAVE_VWSCANF
  157. using ::vwscanf;
  158. #endif
  159. using ::wcrtomb;
  160. using ::wcscat;
  161. using ::wcscmp;
  162. using ::wcscoll;
  163. using ::wcscpy;
  164. using ::wcscspn;
  165. using ::wcsftime;
  166. using ::wcslen;
  167. using ::wcsncat;
  168. using ::wcsncmp;
  169. using ::wcsncpy;
  170. using ::wcsrtombs;
  171. using ::wcsspn;
  172. using ::wcstod;
  173. #if _GLIBCXX_HAVE_WCSTOF
  174. using ::wcstof;
  175. #endif
  176. using ::wcstok;
  177. using ::wcstol;
  178. using ::wcstoul;
  179. using ::wcsxfrm;
  180. using ::wctob;
  181. using ::wmemcmp;
  182. using ::wmemcpy;
  183. using ::wmemmove;
  184. using ::wmemset;
  185. using ::wprintf;
  186. using ::wscanf;
  187. using ::wcschr;
  188. using ::wcspbrk;
  189. using ::wcsrchr;
  190. using ::wcsstr;
  191. using ::wmemchr;
  192. #ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  193. inline wchar_t*
  194. wcschr(wchar_t* __p, wchar_t __c)
  195. { return wcschr(const_cast<const wchar_t*>(__p), __c); }
  196. inline wchar_t*
  197. wcspbrk(wchar_t* __s1, const wchar_t* __s2)
  198. { return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
  199. inline wchar_t*
  200. wcsrchr(wchar_t* __p, wchar_t __c)
  201. { return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
  202. inline wchar_t*
  203. wcsstr(wchar_t* __s1, const wchar_t* __s2)
  204. { return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
  205. inline wchar_t*
  206. wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
  207. { return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
  208. #endif
  209. _GLIBCXX_END_NAMESPACE_VERSION
  210. } // namespace
  211. #if _GLIBCXX_USE_C99
  212. #undef wcstold
  213. #undef wcstoll
  214. #undef wcstoull
  215. namespace __gnu_cxx
  216. {
  217. #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
  218. extern "C" long double
  219. (wcstold)(const wchar_t * __restrict, wchar_t ** __restrict) throw ();
  220. #endif
  221. #if !_GLIBCXX_USE_C99_DYNAMIC
  222. using ::wcstold;
  223. #endif
  224. #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
  225. extern "C" long long int
  226. (wcstoll)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
  227. extern "C" unsigned long long int
  228. (wcstoull)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
  229. #endif
  230. #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
  231. using ::wcstoll;
  232. using ::wcstoull;
  233. #endif
  234. } // namespace __gnu_cxx
  235. namespace std
  236. {
  237. using ::__gnu_cxx::wcstold;
  238. using ::__gnu_cxx::wcstoll;
  239. using ::__gnu_cxx::wcstoull;
  240. } // namespace
  241. #endif
  242. #endif //_GLIBCXX_USE_WCHAR_T
  243. #if __cplusplus >= 201103L
  244. #ifdef _GLIBCXX_USE_WCHAR_T
  245. namespace std
  246. {
  247. #if _GLIBCXX_HAVE_WCSTOF
  248. using std::wcstof;
  249. #endif
  250. #if _GLIBCXX_HAVE_VFWSCANF
  251. using std::vfwscanf;
  252. #endif
  253. #if _GLIBCXX_HAVE_VSWSCANF
  254. using std::vswscanf;
  255. #endif
  256. #if _GLIBCXX_HAVE_VWSCANF
  257. using std::vwscanf;
  258. #endif
  259. #if _GLIBCXX_USE_C99
  260. using std::wcstold;
  261. using std::wcstoll;
  262. using std::wcstoull;
  263. #endif
  264. } // namespace
  265. #endif // _GLIBCXX_USE_WCHAR_T
  266. #endif // C++11
  267. #endif