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