libstdc++
cwchar
Go to the documentation of this file.
1 // -*- C++ -*- forwarding header.
2 
3 // Copyright (C) 1997-2017 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 namespace std _GLIBCXX_VISIBILITY(default)
136 {
137 _GLIBCXX_BEGIN_NAMESPACE_VERSION
138 
139  using ::wint_t;
140 
141  using ::btowc;
142  using ::fgetwc;
143  using ::fgetws;
144  using ::fputwc;
145  using ::fputws;
146  using ::fwide;
147  using ::fwprintf;
148  using ::fwscanf;
149  using ::getwc;
150  using ::getwchar;
151  using ::mbrlen;
152  using ::mbrtowc;
153  using ::mbsinit;
154  using ::mbsrtowcs;
155  using ::putwc;
156  using ::putwchar;
157 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
158  using ::swprintf;
159 #endif
160  using ::swscanf;
161  using ::ungetwc;
162  using ::vfwprintf;
163 #if _GLIBCXX_HAVE_VFWSCANF
164  using ::vfwscanf;
165 #endif
166 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
167  using ::vswprintf;
168 #endif
169 #if _GLIBCXX_HAVE_VSWSCANF
170  using ::vswscanf;
171 #endif
172  using ::vwprintf;
173 #if _GLIBCXX_HAVE_VWSCANF
174  using ::vwscanf;
175 #endif
176  using ::wcrtomb;
177  using ::wcscat;
178  using ::wcscmp;
179  using ::wcscoll;
180  using ::wcscpy;
181  using ::wcscspn;
182  using ::wcsftime;
183  using ::wcslen;
184  using ::wcsncat;
185  using ::wcsncmp;
186  using ::wcsncpy;
187  using ::wcsrtombs;
188  using ::wcsspn;
189  using ::wcstod;
190 #if _GLIBCXX_HAVE_WCSTOF
191  using ::wcstof;
192 #endif
193  using ::wcstok;
194  using ::wcstol;
195  using ::wcstoul;
196  using ::wcsxfrm;
197  using ::wctob;
198  using ::wmemcmp;
199  using ::wmemcpy;
200  using ::wmemmove;
201  using ::wmemset;
202  using ::wprintf;
203  using ::wscanf;
204  using ::wcschr;
205  using ::wcspbrk;
206  using ::wcsrchr;
207  using ::wcsstr;
208  using ::wmemchr;
209 
210 #ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO
211  inline wchar_t*
212  wcschr(wchar_t* __p, wchar_t __c)
213  { return wcschr(const_cast<const wchar_t*>(__p), __c); }
214 
215  inline wchar_t*
216  wcspbrk(wchar_t* __s1, const wchar_t* __s2)
217  { return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
218 
219  inline wchar_t*
220  wcsrchr(wchar_t* __p, wchar_t __c)
221  { return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
222 
223  inline wchar_t*
224  wcsstr(wchar_t* __s1, const wchar_t* __s2)
225  { return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
226 
227  inline wchar_t*
228  wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
229  { return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
230 #endif
231 
232 _GLIBCXX_END_NAMESPACE_VERSION
233 } // namespace
234 
235 #if _GLIBCXX_USE_C99_WCHAR
236 
237 #undef wcstold
238 #undef wcstoll
239 #undef wcstoull
240 
241 namespace __gnu_cxx
242 {
243 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
244  extern "C" long double
245  (wcstold)(const wchar_t * __restrict, wchar_t ** __restrict) throw ();
246 #endif
247 #if !_GLIBCXX_USE_C99_DYNAMIC
248  using ::wcstold;
249 #endif
250 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
251  extern "C" long long int
252  (wcstoll)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
253  extern "C" unsigned long long int
254  (wcstoull)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
255 #endif
256 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
257  using ::wcstoll;
258  using ::wcstoull;
259 #endif
260 } // namespace __gnu_cxx
261 
262 namespace std
263 {
264  using ::__gnu_cxx::wcstold;
265  using ::__gnu_cxx::wcstoll;
266  using ::__gnu_cxx::wcstoull;
267 } // namespace
268 
269 #endif
270 
271 #endif //_GLIBCXX_USE_WCHAR_T
272 
273 #if __cplusplus >= 201103L
274 
275 #ifdef _GLIBCXX_USE_WCHAR_T
276 
277 namespace std
278 {
279 #if _GLIBCXX_HAVE_WCSTOF
280  using std::wcstof;
281 #endif
282 #if _GLIBCXX_HAVE_VFWSCANF
283  using std::vfwscanf;
284 #endif
285 #if _GLIBCXX_HAVE_VSWSCANF
286  using std::vswscanf;
287 #endif
288 #if _GLIBCXX_HAVE_VWSCANF
289  using std::vwscanf;
290 #endif
291 
292 #if _GLIBCXX_USE_C99_WCHAR
293  using std::wcstold;
294  using std::wcstoll;
295  using std::wcstoull;
296 #endif
297 } // namespace
298 
299 #endif // _GLIBCXX_USE_WCHAR_T
300 
301 #endif // C++11
302 
303 #endif