libstdc++
cwchar
Go to the documentation of this file.
00001 // -*- C++ -*- forwarding header.
00002 
00003 // Copyright (C) 1997-2019 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file include/cwchar
00026  *  This is a Standard C++ Library file.  You should @c \#include this file
00027  *  in your programs, rather than any of the @a *.h implementation files.
00028  *
00029  *  This is the C++ version of the Standard C Library header @c wchar.h,
00030  *  and its contents are (mostly) the same as that header, but are all
00031  *  contained in the namespace @c std (except for names which are defined
00032  *  as macros in C).
00033  */
00034 
00035 //
00036 // ISO C++ 14882: 21.4
00037 //
00038 
00039 #pragma GCC system_header
00040 
00041 #include <bits/c++config.h>
00042 
00043 #if _GLIBCXX_HAVE_WCHAR_H
00044 #include <wchar.h>
00045 #endif
00046 
00047 #ifndef _GLIBCXX_CWCHAR
00048 #define _GLIBCXX_CWCHAR 1
00049 
00050 // Need to do a bit of trickery here with mbstate_t as char_traits
00051 // assumes it is in wchar.h, regardless of wchar_t specializations.
00052 #ifndef _GLIBCXX_HAVE_MBSTATE_T
00053 extern "C"
00054 {
00055   typedef struct
00056   {
00057     int __fill[6];
00058   } mbstate_t;
00059 }
00060 #endif
00061 
00062 namespace std
00063 {
00064   using ::mbstate_t;
00065 } // namespace std
00066 
00067 // Get rid of those macros defined in <wchar.h> in lieu of real functions.
00068 #undef btowc
00069 #undef fgetwc
00070 #undef fgetws
00071 #undef fputwc
00072 #undef fputws
00073 #undef fwide
00074 #undef fwprintf
00075 #undef fwscanf
00076 #undef getwc
00077 #undef getwchar
00078 #undef mbrlen
00079 #undef mbrtowc
00080 #undef mbsinit
00081 #undef mbsrtowcs
00082 #undef putwc
00083 #undef putwchar
00084 #undef swprintf
00085 #undef swscanf
00086 #undef ungetwc
00087 #undef vfwprintf
00088 #if _GLIBCXX_HAVE_VFWSCANF
00089 # undef vfwscanf
00090 #endif
00091 #undef vswprintf
00092 #if _GLIBCXX_HAVE_VSWSCANF
00093 # undef vswscanf
00094 #endif
00095 #undef vwprintf
00096 #if _GLIBCXX_HAVE_VWSCANF
00097 # undef vwscanf
00098 #endif
00099 #undef wcrtomb
00100 #undef wcscat
00101 #undef wcschr
00102 #undef wcscmp
00103 #undef wcscoll
00104 #undef wcscpy
00105 #undef wcscspn
00106 #undef wcsftime
00107 #undef wcslen
00108 #undef wcsncat
00109 #undef wcsncmp
00110 #undef wcsncpy
00111 #undef wcspbrk
00112 #undef wcsrchr
00113 #undef wcsrtombs
00114 #undef wcsspn
00115 #undef wcsstr
00116 #undef wcstod
00117 #if _GLIBCXX_HAVE_WCSTOF
00118 # undef wcstof
00119 #endif
00120 #undef wcstok
00121 #undef wcstol
00122 #undef wcstoul
00123 #undef wcsxfrm
00124 #undef wctob
00125 #undef wmemchr
00126 #undef wmemcmp
00127 #undef wmemcpy
00128 #undef wmemmove
00129 #undef wmemset
00130 #undef wprintf
00131 #undef wscanf
00132 
00133 #if _GLIBCXX_USE_WCHAR_T
00134 
00135 extern "C++"
00136 {
00137 namespace std _GLIBCXX_VISIBILITY(default)
00138 {
00139 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00140 
00141   using ::wint_t;
00142 
00143   using ::btowc;
00144   using ::fgetwc;
00145   using ::fgetws;
00146   using ::fputwc;
00147   using ::fputws;
00148   using ::fwide;
00149   using ::fwprintf;
00150   using ::fwscanf;
00151   using ::getwc;
00152   using ::getwchar;
00153   using ::mbrlen;
00154   using ::mbrtowc;
00155   using ::mbsinit;
00156   using ::mbsrtowcs;
00157   using ::putwc;
00158   using ::putwchar;
00159 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
00160   using ::swprintf;
00161 #endif
00162   using ::swscanf;
00163   using ::ungetwc;
00164   using ::vfwprintf;
00165 #if _GLIBCXX_HAVE_VFWSCANF
00166   using ::vfwscanf;
00167 #endif
00168 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
00169   using ::vswprintf;
00170 #endif
00171 #if _GLIBCXX_HAVE_VSWSCANF
00172   using ::vswscanf;
00173 #endif
00174   using ::vwprintf;
00175 #if _GLIBCXX_HAVE_VWSCANF
00176   using ::vwscanf;
00177 #endif
00178   using ::wcrtomb;
00179   using ::wcscat;
00180   using ::wcscmp;
00181   using ::wcscoll;
00182   using ::wcscpy;
00183   using ::wcscspn;
00184   using ::wcsftime;
00185   using ::wcslen;
00186   using ::wcsncat;
00187   using ::wcsncmp;
00188   using ::wcsncpy;
00189   using ::wcsrtombs;
00190   using ::wcsspn;
00191   using ::wcstod;
00192 #if _GLIBCXX_HAVE_WCSTOF
00193   using ::wcstof;
00194 #endif
00195   using ::wcstok;
00196   using ::wcstol;
00197   using ::wcstoul;
00198   using ::wcsxfrm;
00199   using ::wctob;
00200   using ::wmemcmp;
00201   using ::wmemcpy;
00202   using ::wmemmove;
00203   using ::wmemset;
00204   using ::wprintf;
00205   using ::wscanf;
00206   using ::wcschr;
00207   using ::wcspbrk;
00208   using ::wcsrchr;
00209   using ::wcsstr;
00210   using ::wmemchr;
00211 
00212 #ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO
00213   inline wchar_t*
00214   wcschr(wchar_t* __p, wchar_t __c)
00215   { return wcschr(const_cast<const wchar_t*>(__p), __c); }
00216 
00217   inline wchar_t*
00218   wcspbrk(wchar_t* __s1, const wchar_t* __s2)
00219   { return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
00220 
00221   inline wchar_t*
00222   wcsrchr(wchar_t* __p, wchar_t __c)
00223   { return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
00224 
00225   inline wchar_t*
00226   wcsstr(wchar_t* __s1, const wchar_t* __s2)
00227   { return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
00228 
00229   inline wchar_t*
00230   wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
00231   { return wmemchr(const_cast<const wchar_t*>(__p), __c, __n); }
00232 #endif
00233 
00234 _GLIBCXX_END_NAMESPACE_VERSION
00235 } // namespace
00236 } // extern "C++"
00237 
00238 #if _GLIBCXX_USE_C99_WCHAR
00239 
00240 #undef wcstold
00241 #undef wcstoll
00242 #undef wcstoull
00243 
00244 namespace __gnu_cxx
00245 {
00246 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
00247   extern "C" long double
00248     (wcstold)(const wchar_t * __restrict, wchar_t ** __restrict) throw ();
00249 #endif
00250 #if !_GLIBCXX_USE_C99_DYNAMIC
00251   using ::wcstold;
00252 #endif
00253 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00254   extern "C" long long int
00255     (wcstoll)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
00256   extern "C" unsigned long long int
00257     (wcstoull)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw ();
00258 #endif
00259 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00260   using ::wcstoll;
00261   using ::wcstoull;
00262 #endif
00263 } // namespace __gnu_cxx
00264 
00265 namespace std
00266 {
00267   using ::__gnu_cxx::wcstold;
00268   using ::__gnu_cxx::wcstoll;
00269   using ::__gnu_cxx::wcstoull;
00270 } // namespace
00271 
00272 #endif
00273 
00274 #endif //_GLIBCXX_USE_WCHAR_T
00275 
00276 #if __cplusplus >= 201103L
00277 
00278 #ifdef _GLIBCXX_USE_WCHAR_T
00279 
00280 namespace std
00281 {
00282 #if _GLIBCXX_HAVE_WCSTOF
00283   using std::wcstof;
00284 #endif
00285 #if _GLIBCXX_HAVE_VFWSCANF
00286   using std::vfwscanf;
00287 #endif
00288 #if _GLIBCXX_HAVE_VSWSCANF
00289   using std::vswscanf;
00290 #endif
00291 #if _GLIBCXX_HAVE_VWSCANF
00292   using std::vwscanf;
00293 #endif
00294 
00295 #if _GLIBCXX_USE_C99_WCHAR
00296   using std::wcstold;
00297   using std::wcstoll;
00298   using std::wcstoull;
00299 #endif
00300 } // namespace
00301 
00302 #endif // _GLIBCXX_USE_WCHAR_T
00303 
00304 #endif // C++11
00305 
00306 #endif