cwchar

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