Warning, /include/c++/v1/cwchar is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_CWCHAR
0011 #define _LIBCPP_CWCHAR
0012
0013 /*
0014 cwchar synopsis
0015
0016 Macros:
0017
0018 NULL
0019 WCHAR_MAX
0020 WCHAR_MIN
0021 WEOF
0022
0023 namespace std
0024 {
0025
0026 Types:
0027
0028 mbstate_t
0029 size_t
0030 tm
0031 wint_t
0032
0033 int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
0034 int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
0035 int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
0036 int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
0037 int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
0038 int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
0039 int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
0040 int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
0041 int vwprintf(const wchar_t* restrict format, va_list arg);
0042 int vwscanf(const wchar_t* restrict format, va_list arg); // C99
0043 int wprintf(const wchar_t* restrict format, ...);
0044 int wscanf(const wchar_t* restrict format, ...);
0045 wint_t fgetwc(FILE* stream);
0046 wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
0047 wint_t fputwc(wchar_t c, FILE* stream);
0048 int fputws(const wchar_t* restrict s, FILE* restrict stream);
0049 int fwide(FILE* stream, int mode);
0050 wint_t getwc(FILE* stream);
0051 wint_t getwchar();
0052 wint_t putwc(wchar_t c, FILE* stream);
0053 wint_t putwchar(wchar_t c);
0054 wint_t ungetwc(wint_t c, FILE* stream);
0055 double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
0056 float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
0057 long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
0058 long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
0059 long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
0060 unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
0061 unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
0062 wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
0063 wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
0064 wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
0065 wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
0066 int wcscmp(const wchar_t* s1, const wchar_t* s2);
0067 int wcscoll(const wchar_t* s1, const wchar_t* s2);
0068 int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
0069 size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
0070 const wchar_t* wcschr(const wchar_t* s, wchar_t c);
0071 wchar_t* wcschr( wchar_t* s, wchar_t c);
0072 size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
0073 size_t wcslen(const wchar_t* s);
0074 const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
0075 wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
0076 const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
0077 wchar_t* wcsrchr( wchar_t* s, wchar_t c);
0078 size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
0079 const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
0080 wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
0081 wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
0082 const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
0083 wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
0084 int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
0085 wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
0086 wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
0087 wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
0088 size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
0089 const tm* restrict timeptr);
0090 wint_t btowc(int c);
0091 int wctob(wint_t c);
0092 int mbsinit(const mbstate_t* ps);
0093 size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
0094 size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
0095 size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
0096 size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
0097 mbstate_t* restrict ps);
0098 size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
0099 mbstate_t* restrict ps);
0100
0101 } // std
0102
0103 */
0104
0105 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0106 # include <__cxx03/cwchar>
0107 #else
0108 # include <__config>
0109 # include <__cstddef/size_t.h>
0110 # include <__type_traits/copy_cv.h>
0111 # include <__type_traits/is_constant_evaluated.h>
0112 # include <__type_traits/is_equality_comparable.h>
0113 # include <__type_traits/is_same.h>
0114 # include <__type_traits/remove_cv.h>
0115 # include <cwctype>
0116
0117 # include <wchar.h>
0118
0119 # ifndef _LIBCPP_WCHAR_H
0120 # error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \
0121 This usually means that your header search paths are not configured properly. \
0122 The header search paths should contain the C++ Standard Library headers before \
0123 any C Standard Library, and you are probably using compiler flags that make that \
0124 not be the case.
0125 # endif
0126
0127 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0128 # pragma GCC system_header
0129 # endif
0130
0131 _LIBCPP_BEGIN_NAMESPACE_STD
0132
0133 using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
0134 using ::tm _LIBCPP_USING_IF_EXISTS;
0135 using ::wint_t _LIBCPP_USING_IF_EXISTS;
0136 using ::FILE _LIBCPP_USING_IF_EXISTS;
0137 using ::fwprintf _LIBCPP_USING_IF_EXISTS;
0138 using ::fwscanf _LIBCPP_USING_IF_EXISTS;
0139 using ::swprintf _LIBCPP_USING_IF_EXISTS;
0140 using ::vfwprintf _LIBCPP_USING_IF_EXISTS;
0141 using ::vswprintf _LIBCPP_USING_IF_EXISTS;
0142 using ::swscanf _LIBCPP_USING_IF_EXISTS;
0143 using ::vfwscanf _LIBCPP_USING_IF_EXISTS;
0144 using ::vswscanf _LIBCPP_USING_IF_EXISTS;
0145 using ::fgetwc _LIBCPP_USING_IF_EXISTS;
0146 using ::fgetws _LIBCPP_USING_IF_EXISTS;
0147 using ::fputwc _LIBCPP_USING_IF_EXISTS;
0148 using ::fputws _LIBCPP_USING_IF_EXISTS;
0149 using ::fwide _LIBCPP_USING_IF_EXISTS;
0150 using ::getwc _LIBCPP_USING_IF_EXISTS;
0151 using ::putwc _LIBCPP_USING_IF_EXISTS;
0152 using ::ungetwc _LIBCPP_USING_IF_EXISTS;
0153 using ::wcstod _LIBCPP_USING_IF_EXISTS;
0154 using ::wcstof _LIBCPP_USING_IF_EXISTS;
0155 using ::wcstold _LIBCPP_USING_IF_EXISTS;
0156 using ::wcstol _LIBCPP_USING_IF_EXISTS;
0157 using ::wcstoll _LIBCPP_USING_IF_EXISTS;
0158 using ::wcstoul _LIBCPP_USING_IF_EXISTS;
0159 using ::wcstoull _LIBCPP_USING_IF_EXISTS;
0160 using ::wcscpy _LIBCPP_USING_IF_EXISTS;
0161 using ::wcsncpy _LIBCPP_USING_IF_EXISTS;
0162 using ::wcscat _LIBCPP_USING_IF_EXISTS;
0163 using ::wcsncat _LIBCPP_USING_IF_EXISTS;
0164 using ::wcscmp _LIBCPP_USING_IF_EXISTS;
0165 using ::wcscoll _LIBCPP_USING_IF_EXISTS;
0166 using ::wcsncmp _LIBCPP_USING_IF_EXISTS;
0167 using ::wcsxfrm _LIBCPP_USING_IF_EXISTS;
0168 using ::wcschr _LIBCPP_USING_IF_EXISTS;
0169 using ::wcspbrk _LIBCPP_USING_IF_EXISTS;
0170 using ::wcsrchr _LIBCPP_USING_IF_EXISTS;
0171 using ::wcsstr _LIBCPP_USING_IF_EXISTS;
0172 using ::wmemchr _LIBCPP_USING_IF_EXISTS;
0173 using ::wcscspn _LIBCPP_USING_IF_EXISTS;
0174 using ::wcslen _LIBCPP_USING_IF_EXISTS;
0175 using ::wcsspn _LIBCPP_USING_IF_EXISTS;
0176 using ::wcstok _LIBCPP_USING_IF_EXISTS;
0177 using ::wmemcmp _LIBCPP_USING_IF_EXISTS;
0178 using ::wmemcpy _LIBCPP_USING_IF_EXISTS;
0179 using ::wmemmove _LIBCPP_USING_IF_EXISTS;
0180 using ::wmemset _LIBCPP_USING_IF_EXISTS;
0181 using ::wcsftime _LIBCPP_USING_IF_EXISTS;
0182 using ::btowc _LIBCPP_USING_IF_EXISTS;
0183 using ::wctob _LIBCPP_USING_IF_EXISTS;
0184 using ::mbsinit _LIBCPP_USING_IF_EXISTS;
0185 using ::mbrlen _LIBCPP_USING_IF_EXISTS;
0186 using ::mbrtowc _LIBCPP_USING_IF_EXISTS;
0187 using ::wcrtomb _LIBCPP_USING_IF_EXISTS;
0188 using ::mbsrtowcs _LIBCPP_USING_IF_EXISTS;
0189 using ::wcsrtombs _LIBCPP_USING_IF_EXISTS;
0190
0191 using ::getwchar _LIBCPP_USING_IF_EXISTS;
0192 using ::vwscanf _LIBCPP_USING_IF_EXISTS;
0193 using ::wscanf _LIBCPP_USING_IF_EXISTS;
0194
0195 using ::putwchar _LIBCPP_USING_IF_EXISTS;
0196 using ::vwprintf _LIBCPP_USING_IF_EXISTS;
0197 using ::wprintf _LIBCPP_USING_IF_EXISTS;
0198
0199 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) {
0200 # if __has_builtin(__builtin_wcslen)
0201 return __builtin_wcslen(__str);
0202 # else
0203 if (!__libcpp_is_constant_evaluated())
0204 return std::wcslen(__str);
0205
0206 size_t __len = 0;
0207 for (; *__str != L'\0'; ++__str)
0208 ++__len;
0209 return __len;
0210 # endif
0211 }
0212
0213 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
0214 __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) {
0215 # if __has_builtin(__builtin_wmemcmp)
0216 return __builtin_wmemcmp(__lhs, __rhs, __count);
0217 # else
0218 if (!__libcpp_is_constant_evaluated())
0219 return std::wmemcmp(__lhs, __rhs, __count);
0220
0221 for (; __count; --__count, ++__lhs, ++__rhs) {
0222 if (*__lhs < *__rhs)
0223 return -1;
0224 if (*__rhs < *__lhs)
0225 return 1;
0226 }
0227 return 0;
0228 # endif
0229 }
0230
0231 template <class _Tp, class _Up>
0232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp* __str, _Up __value, size_t __count) {
0233 static_assert(sizeof(_Tp) == sizeof(wchar_t)&& _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t) &&
0234 __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value,
0235 "Calling wmemchr on non-trivially equality comparable types is unsafe.");
0236
0237 # if __has_builtin(__builtin_wmemchr)
0238 if (!__libcpp_is_constant_evaluated()) {
0239 wchar_t __value_buffer = 0;
0240 __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t));
0241 return reinterpret_cast<_Tp*>(
0242 __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
0243 }
0244 # if _LIBCPP_STD_VER >= 17
0245 else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>)
0246 return __builtin_wmemchr(__str, __value, __count);
0247 # endif
0248 # endif // __has_builtin(__builtin_wmemchr)
0249
0250 for (; __count; --__count) {
0251 if (*__str == __value)
0252 return __str;
0253 ++__str;
0254 }
0255 return nullptr;
0256 }
0257
0258 _LIBCPP_END_NAMESPACE_STD
0259
0260 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0261 # include <cstddef>
0262 # endif
0263 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0264
0265 #endif // _LIBCPP_CWCHAR