epoc32/include/stdapis/stlportv5/stl/_cwchar.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Boris Fomitchev
     6  *
     7  * This material is provided "as is", with absolutely no warranty expressed
     8  * or implied. Any use is at your own risk.
     9  *
    10  * Permission to use or copy this software for any purpose is hereby granted
    11  * without fee, provided the above notices are retained on all copies.
    12  * Permission to modify the code and to distribute modified code is granted,
    13  * provided the above notices are retained, and a notice that the code was
    14  * modified is included with the above copyright notice.
    15  *
    16  */
    17 
    18 #ifndef _STLP_INTERNAL_CWCHAR
    19 #define _STLP_INTERNAL_CWCHAR
    20 
    21 #if defined (_STLP_WCE_EVC3)
    22 #  ifndef _STLP_INTERNAL_MBSTATE_T
    23 #    include <stl/_mbstate_t.h>
    24 #  endif
    25 #else
    26 #  if defined (__GNUC__) && !defined (__SYMBIAN32__)
    27 #    include _STLP_NATIVE_CPP_C_HEADER(cstddef)
    28 #  endif
    29 
    30 #  if !defined (_STLP_NO_CWCHAR) && defined (_STLP_USE_NEW_C_HEADERS)
    31 #    include _STLP_NATIVE_CPP_C_HEADER(cwchar)
    32 #    if defined (__OpenBSD__)
    33 typedef _BSD_WINT_T_ wint_t;
    34 #    endif /* __OpenBSD__ */
    35 
    36 #  elif defined (_STLP_NO_WCHAR_T) || defined (__MRC__) || (defined (__SC__) && !defined (__DMC__)) || \
    37        (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) || \
    38         defined (__OpenBSD__) || defined (__FreeBSD__) || \
    39        (defined (__GNUC__) && (defined (__APPLE__) || defined ( __Lynx__ )))
    40 #    include _STLP_NATIVE_C_HEADER(stddef.h)
    41 #    if defined (__Lynx__)
    42 #      ifndef _WINT_T
    43 typedef long int wint_t;
    44 #        define _WINT_T
    45 #      endif /* _WINT_T */
    46 #    endif
    47 #    if defined(__OpenBSD__)
    48 typedef _BSD_WINT_T_ wint_t;
    49 #    endif /* __OpenBSD__ */
    50 #  elif defined (__MWERKS__) && defined (N_PLAT_NLM)
    51 #    include <wchar.h>
    52 #  else
    53 #    include _STLP_NATIVE_C_HEADER(wchar.h)
    54 
    55 #    if defined (__sun) && (defined (_XOPEN_SOURCE) || (_XOPEN_VERSION - 0 == 4))
    56 extern wint_t   btowc();
    57 extern int      fwprintf();
    58 extern int      fwscanf();
    59 extern int      fwide();
    60 extern int      mbsinit();
    61 extern size_t   mbrlen();
    62 extern size_t   mbrtowc();
    63 extern size_t   mbsrtowcs();
    64 extern int      swprintf();
    65 extern int      swscanf();
    66 extern int      vfwprintf();
    67 extern int      vwprintf();
    68 extern int      vswprintf();
    69 extern size_t   wcrtomb();
    70 extern size_t   wcsrtombs();
    71 extern wchar_t  *wcsstr();
    72 extern int      wctob();
    73 extern wchar_t  *wmemchr();
    74 extern int      wmemcmp();
    75 extern wchar_t  *wmemcpy();
    76 extern wchar_t  *wmemmove();
    77 extern wchar_t  *wmemset();
    78 extern int      wprintf();
    79 extern int      wscanf();
    80 #    endif
    81 #  endif
    82 
    83 #  if defined (__MSL__) && (__MSL__ <= 0x51FF)  /* dwa 2/28/99 - not yet implemented by MSL  */
    84 #    define _STLP_WCHAR_MSL_EXCLUDE 1
    85 namespace std {
    86   extern "C" size_t wcsftime(wchar_t * str, size_t max_size, const wchar_t * format_str, const struct tm * timeptr);
    87 }
    88 #    define _STLP_NO_MBSTATE_T 1
    89 #  elif defined (__BORLANDC__)
    90 #    if !defined (_STLP_USE_NO_IOSTREAMS)
    91 #      define _STLP_NO_NATIVE_MBSTATE_T
    92 #    endif
    93 #    define _STLP_WCHAR_BORLAND_EXCLUDE 1
    94 #  endif
    95 
    96 #  ifndef _STLP_INTERNAL_MBSTATE_T
    97 #    include <stl/_mbstate_t.h>
    98 #  endif
    99 
   100 #  if !defined (_STLP_NO_WCHAR_T)
   101 #    ifndef WCHAR_MIN
   102 #      define WCHAR_MIN 0
   103 /* SUNpro has some bugs with casts. wchar_t is size of int there anyway. */
   104 #      if defined (__SUNPRO_CC) || defined (__DJGPP)
   105 #        define WCHAR_MAX (~0)
   106 #      else
   107 #        define WCHAR_MAX ((wchar_t)~0)
   108 #      endif
   109 #    endif
   110 #    if defined (__GNUC__) && defined (__alpha__)
   111 /* Definition of WCHAR_MIN and MAX are wrong for alpha platform
   112  * as gcc consider wchar_t as an unsigned type. Static assertion are
   113  * here to check that a future alpha SDK or a future gcc won't change the
   114  * situation making this workaround useless.
   115  */
   116 _STLP_STATIC_ASSERT(((wchar_t)-1 > 0) && (WCHAR_MIN < 0))
   117 #      undef WCHAR_MIN
   118 #      define WCHAR_MIN 0
   119 #      undef WCHAR_MAX
   120 #      define WCHAR_MAX ((wchar_t)~0)
   121 #    endif
   122 #    if defined(__HP_aCC) && (__HP_aCC >= 60000)
   123 /* Starting with B.11.31, HP-UX/ia64 provides C99-compliant definitions
   124  * of WCHAR_MIN/MAX macros without having to define
   125  * _INCLUDE_STDC__SOURCE_199901 macro (which aCC compiler does not
   126  * predefine). Let STLport provide B.11.31 definitions on any version of
   127  * HP-UX/ia64.
   128  */
   129 #      undef WCHAR_MIN
   130 #      define WCHAR_MIN 0
   131 #      undef WCHAR_MAX
   132 #      define WCHAR_MAX UINT_MAX 
   133 #    endif
   134 #  endif
   135 
   136 #  if defined (_STLP_IMPORT_VENDOR_CSTD)
   137 
   138 #    if defined (__SUNPRO_CC) && !defined (_STLP_HAS_NO_NEW_C_HEADERS)
   139 using _STLP_VENDOR_CSTD::wint_t;
   140 #    endif
   141 
   142 _STLP_BEGIN_NAMESPACE
   143 #    if defined (_STLP_NO_WCHAR_T)
   144 typedef int wint_t;
   145 #    else
   146 // gcc 3.0 has a glitch : wint_t only sucked into the global namespace if _GLIBCPP_USE_WCHAR_T is defined
   147 // __MWERKS__ has definition in wchar_t.h (MSL C++), but ones differ from definition
   148 // in stdio.h; I prefer settings from last file.
   149 #      if (defined (__GNUC__) && ! defined (_GLIBCPP_USE_WCHAR_T)) // || (defined(__MWERKS__) && defined(N_PLAT_NLM))
   150 using ::wint_t;
   151 #      else
   152 using _STLP_VENDOR_CSTD::wint_t;
   153 #      endif
   154 #    endif
   155 
   156 using _STLP_VENDOR_CSTD::size_t;
   157 
   158 #    if !defined (_STLP_NO_NATIVE_MBSTATE_T) && !defined (_STLP_USE_OWN_MBSTATE_T)
   159 using _STLP_VENDOR_MB_NAMESPACE::mbstate_t;
   160 
   161 #      if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !defined(_STLP_WCHAR_BORLAND_EXCLUDE) && \
   162          (!defined(__MSL__) || __MSL__ > 0x6001)
   163 #        if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \
   164           !(defined (__KCC) || defined (__GNUC__)) && !defined(_STLP_WCE_NET) && !(defined(__MWERKS__) && defined(N_PLAT_NLM))
   165 using _STLP_VENDOR_MB_NAMESPACE::btowc;
   166 #          if (!defined(__MSL__) || __MSL__ > 0x7001)
   167 using _STLP_VENDOR_MB_NAMESPACE::mbsinit;
   168 #          endif
   169 #        endif
   170 #        if defined (__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8))) || \
   171            !defined (__GNUC__) && !defined(_STLP_WCE_NET) && !(defined(__MWERKS__) && defined(N_PLAT_NLM))
   172 using _STLP_VENDOR_MB_NAMESPACE::mbrlen;
   173 using _STLP_VENDOR_MB_NAMESPACE::mbrtowc;
   174 using _STLP_VENDOR_MB_NAMESPACE::mbsrtowcs;
   175 using _STLP_VENDOR_MB_NAMESPACE::wcrtomb;
   176 using _STLP_VENDOR_MB_NAMESPACE::wcsrtombs;
   177 #        endif
   178 #      endif /* BORLAND && !__MSL__ || __MSL__ > 0x6001 */
   179 
   180 #    endif /* _STLP_NO_NATIVE_MBSTATE_T */
   181 
   182 #    if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
   183 
   184 #      if !defined (_STLP_WCHAR_BORLAND_EXCLUDE) && ! defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !(defined(__MWERKS__) && defined(N_PLAT_NLM))
   185 using _STLP_VENDOR_CSTD::fgetwc;
   186 using _STLP_VENDOR_CSTD::fgetws;
   187 using _STLP_VENDOR_CSTD::fputwc;
   188 using _STLP_VENDOR_CSTD::fputws;
   189 #      endif
   190 
   191 #      if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \
   192             defined(_STLP_WCHAR_HPACC_EXCLUDE) || (defined(__MWERKS__) && defined(N_PLAT_NLM)))
   193 #        if !defined (__DECCXX)
   194 using _STLP_VENDOR_CSTD::fwide;
   195 #        endif
   196 using _STLP_VENDOR_CSTD::fwprintf;
   197 using _STLP_VENDOR_CSTD::fwscanf;
   198 using _STLP_VENDOR_CSTD::getwchar;
   199 #      endif
   200 
   201 #      if !defined(_STLP_WCHAR_BORLAND_EXCLUDE) && !(defined(__MWERKS__) && defined(N_PLAT_NLM))
   202 #        ifndef _STLP_WCE_NET
   203 using _STLP_VENDOR_CSTD::getwc;
   204 #        endif
   205 using _STLP_VENDOR_CSTD::ungetwc;
   206 #        ifndef _STLP_WCE_NET
   207 using _STLP_VENDOR_CSTD::putwc;
   208 #        endif
   209 using _STLP_VENDOR_CSTD::putwchar;
   210 #      endif
   211 
   212 #      if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_BORLAND_EXCLUDE) || \
   213             defined (_STLP_WCHAR_HPACC_EXCLUDE) || (defined (__MWERKS__) && defined (N_PLAT_NLM)))
   214 #        if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB <= 1300) || \
   215             (defined (__MINGW32__) && !(defined (__SYMBIAN32__) && defined (__GCCXML__)))
   216 #          undef swprintf
   217 #          define swprintf _snwprintf
   218 #          undef vswprintf
   219 #          define vswprintf _vsnwprintf
   220 using ::swprintf;
   221 using ::vswprintf;
   222 #        else
   223 using _STLP_VENDOR_CSTD::swprintf;
   224 using _STLP_VENDOR_CSTD::vswprintf;
   225 #        endif
   226 using _STLP_VENDOR_CSTD::swscanf;
   227 using _STLP_VENDOR_CSTD::vfwprintf;
   228 using _STLP_VENDOR_CSTD::vwprintf;
   229 
   230 #        if (!defined(__MSL__) || __MSL__ > 0x7001 ) && !defined(_STLP_WCE_NET) && \
   231              !defined(_STLP_USE_UCLIBC) /* at least in uClibc 0.9.26 */
   232 
   233 using _STLP_VENDOR_CSTD::wcsftime;
   234 #        endif
   235 using _STLP_VENDOR_CSTD::wcstok;
   236 
   237 #      endif
   238 
   239 #      if !(defined(__MWERKS__) && defined(N_PLAT_NLM))
   240 #        if !defined (_STLP_WCE_NET)
   241 using _STLP_VENDOR_CSTD::wcscoll;
   242 using _STLP_VENDOR_CSTD::wcsxfrm;
   243 #        endif
   244 using _STLP_VENDOR_CSTD::wcscat;
   245 using _STLP_VENDOR_CSTD::wcsrchr;
   246 using _STLP_VENDOR_CSTD::wcscmp;
   247 
   248 using _STLP_VENDOR_CSTD::wcscpy;
   249 using _STLP_VENDOR_CSTD::wcscspn;
   250 
   251 using _STLP_VENDOR_CSTD::wcslen;
   252 using _STLP_VENDOR_CSTD::wcsncat;
   253 using _STLP_VENDOR_CSTD::wcsncmp;
   254 using _STLP_VENDOR_CSTD::wcsncpy;
   255 using _STLP_VENDOR_CSTD::wcspbrk;
   256 using _STLP_VENDOR_CSTD::wcschr;
   257 
   258 using _STLP_VENDOR_CSTD::wcsspn;
   259 #      endif
   260 
   261 #      if !defined (_STLP_WCHAR_BORLAND_EXCLUDE) && !(defined(__MWERKS__) && defined(N_PLAT_NLM))
   262 using _STLP_VENDOR_CSTD::wcstod;
   263 using _STLP_VENDOR_CSTD::wcstol;
   264 #      endif
   265 
   266 #      if !(defined (_STLP_WCHAR_SUNPRO_EXCLUDE) || defined (_STLP_WCHAR_HPACC_EXCLUDE) || \
   267             (defined (__MWERKS__) && defined (N_PLAT_NLM)))
   268 using _STLP_VENDOR_CSTD::wcsstr;
   269 using _STLP_VENDOR_CSTD::wmemchr;
   270 
   271 #        if !defined (_STLP_WCHAR_BORLAND_EXCLUDE)
   272 #            if !defined (_STLP_WCE_NET)
   273 using _STLP_VENDOR_CSTD::wctob;
   274 #            endif
   275 #          if !defined (__DMC__)
   276 using _STLP_VENDOR_CSTD::wmemcmp;
   277 using _STLP_VENDOR_CSTD::wmemmove;
   278 #          endif
   279 using _STLP_VENDOR_CSTD::wprintf;
   280 using _STLP_VENDOR_CSTD::wscanf;
   281 #        endif
   282 
   283 #        if defined (__BORLANDC__)
   284 inline wchar_t* _STLP_wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n)
   285 { return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::wmemcpy(__wdst, __wsrc, __n)); }
   286 inline wchar_t* _STLP_wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
   287 { return __STATIC_CAST(wchar_t*, _STLP_VENDOR_CSTD::memset(__wdst, __wc, __n)); }
   288 #          undef wmemcpy
   289 #          undef wmemset
   290 inline wchar_t* wmemcpy(wchar_t* __wdst, const wchar_t* __wsrc, size_t __n)
   291 { return _STLP_wmemcpy(__wdst, __wsrc, __n); }
   292 inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
   293 { return _STLP_wmemset(__wdst, __wc, __n); }
   294 #        elif defined (__DMC__)
   295 inline wchar_t* wmemcpy(wchar_t* __RESTRICT __wdst, const wchar_t* __RESTRICT __wsrc, size_t __n)
   296 { return __STATIC_CAST(wchar_t*, memcpy(__wdst, __wsrc, __n * sizeof(wchar_t))); }
   297 inline wchar_t* wmemmove(wchar_t* __RESTRICT __wdst, const wchar_t * __RESTRICT __wc, size_t __n)
   298 { return __STATIC_CAST(wchar_t*, memmove(__wdst, __wc, __n * sizeof(wchar_t))); }
   299 inline wchar_t* wmemset(wchar_t* __wdst, wchar_t __wc, size_t __n)
   300 { for (size_t i = 0; i < __n; i++) __wdst[i] = __wc; return __wdst; }
   301 #        else
   302 using _STLP_VENDOR_CSTD::wmemcpy;
   303 using _STLP_VENDOR_CSTD::wmemset;
   304 #        endif
   305 #      endif
   306 
   307 #    elif defined (__MWERKS__) && defined (N_PLAT_NLM) /* _STLP_NO_NATIVE_WIDE_FUNCTIONS */
   308 using _STLP_VENDOR_CSTD::wcslen;
   309 using _STLP_VENDOR_CSTD::wcscmp;
   310 using _STLP_VENDOR_CSTD::wcscpy;
   311 using _STLP_VENDOR_CSTD::wcsstr;
   312 using _STLP_VENDOR_CSTD::wcschr;
   313 using _STLP_VENDOR_CSTD::wcsrchr;
   314 using _STLP_VENDOR_CSTD::wcspbrk;
   315 #    endif /* _STLP_NO_NATIVE_WIDE_FUNCTIONS */
   316 _STLP_END_NAMESPACE
   317 
   318 #  endif /* _STLP_IMPORT_VENDOR_CSTD */
   319 
   320 #  undef _STLP_WCHAR_SUNPRO_EXCLUDE
   321 #  undef _STLP_WCHAR_MSL_EXCLUDE
   322 
   323 #  endif /* !defined(_STLP_WCE_EVC3) */
   324 
   325 #endif /* _STLP_INTERNAL_CWCHAR */