cwchar revision 1.1
1// -*- C++ -*- forwarding header.
2
3// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4// 2006, 2007, 2008, 2009, 2010
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 @a *.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
56extern "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#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
235
236#if _GLIBCXX_USE_C99
237
238#undef wcstold
239#undef wcstoll
240#undef wcstoull
241
242_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
243
244#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
245  extern "C" long double
246    (wcstold)(const wchar_t * restrict, wchar_t ** restrict) throw ();
247#endif
248#if !_GLIBCXX_USE_C99_DYNAMIC
249  using ::wcstold;
250#endif
251#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
252  extern "C" long long int
253    (wcstoll)(const wchar_t * restrict, wchar_t ** restrict, int) throw ();
254  extern "C" unsigned long long int
255    (wcstoull)(const wchar_t * restrict, wchar_t ** restrict, int) throw ();
256#endif
257#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
258  using ::wcstoll;
259  using ::wcstoull;
260#endif
261
262_GLIBCXX_END_NAMESPACE
263
264_GLIBCXX_BEGIN_NAMESPACE(std)
265
266  using ::__gnu_cxx::wcstold;
267  using ::__gnu_cxx::wcstoll;
268  using ::__gnu_cxx::wcstoull;
269
270_GLIBCXX_END_NAMESPACE
271
272#endif
273
274#endif //_GLIBCXX_USE_WCHAR_T
275
276#ifdef __GXX_EXPERIMENTAL_CXX0X__
277#  if defined(_GLIBCXX_INCLUDE_AS_TR1)
278#    error C++0x header cannot be included from TR1 header
279#  endif
280#  if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
281#    include <tr1_impl/cwchar>
282#  else
283#    define _GLIBCXX_INCLUDE_AS_CXX0X
284#    define _GLIBCXX_BEGIN_NAMESPACE_TR1
285#    define _GLIBCXX_END_NAMESPACE_TR1
286#    define _GLIBCXX_TR1
287#    include <tr1_impl/cwchar>
288#    undef _GLIBCXX_TR1
289#    undef _GLIBCXX_END_NAMESPACE_TR1
290#    undef _GLIBCXX_BEGIN_NAMESPACE_TR1
291#    undef _GLIBCXX_INCLUDE_AS_CXX0X
292#  endif
293#endif
294
295#endif
296