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