10b57cec5SDimitry Andric// -*- C++ -*- 20b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP___LOCALE 110b57cec5SDimitry Andric#define _LIBCPP___LOCALE 120b57cec5SDimitry Andric 13e8d8bef9SDimitry Andric#include <__availability> 14fe6060f1SDimitry Andric#include <__config> 1506c3fb27SDimitry Andric#include <__memory/shared_ptr.h> // __shared_count 16*5f757f3fSDimitry Andric#include <__mutex/once_flag.h> 1706c3fb27SDimitry Andric#include <__type_traits/make_unsigned.h> 18*5f757f3fSDimitry Andric#include <__utility/no_destroy.h> 190b57cec5SDimitry Andric#include <cctype> 2006c3fb27SDimitry Andric#include <clocale> 2104eeddc0SDimitry Andric#include <cstdint> 2206c3fb27SDimitry Andric#include <cstdlib> 2304eeddc0SDimitry Andric#include <string> 2404eeddc0SDimitry Andric 25bdd1243dSDimitry Andric// Some platforms require more includes than others. Keep the includes on all plaforms for now. 26bdd1243dSDimitry Andric#include <cstddef> 27bdd1243dSDimitry Andric#include <cstring> 28bdd1243dSDimitry Andric 2906c3fb27SDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 3006c3fb27SDimitry Andric# include <cwchar> 3106c3fb27SDimitry Andric#else 3206c3fb27SDimitry Andric# include <__std_mbstate_t.h> 3306c3fb27SDimitry Andric#endif 3406c3fb27SDimitry Andric 350b57cec5SDimitry Andric#if defined(_LIBCPP_MSVCRT_LIKE) 36d409305fSDimitry Andric# include <__support/win32/locale_win32.h> 37e8d8bef9SDimitry Andric#elif defined(_AIX) || defined(__MVS__) 38d409305fSDimitry Andric# include <__support/ibm/xlocale.h> 390b57cec5SDimitry Andric#elif defined(__ANDROID__) 40d409305fSDimitry Andric# include <__support/android/locale_bionic.h> 410b57cec5SDimitry Andric#elif defined(_NEWLIB_VERSION) 42d409305fSDimitry Andric# include <__support/newlib/xlocale.h> 43e8d8bef9SDimitry Andric#elif defined(__OpenBSD__) 44d409305fSDimitry Andric# include <__support/openbsd/xlocale.h> 45fcaf7f86SDimitry Andric#elif (defined(__APPLE__) || defined(__FreeBSD__)) 460b57cec5SDimitry Andric# include <xlocale.h> 470b57cec5SDimitry Andric#elif defined(__Fuchsia__) 48d409305fSDimitry Andric# include <__support/fuchsia/xlocale.h> 490b57cec5SDimitry Andric#elif defined(__wasi__) 500b57cec5SDimitry Andric// WASI libc uses musl's locales support. 51d409305fSDimitry Andric# include <__support/musl/xlocale.h> 520b57cec5SDimitry Andric#elif defined(_LIBCPP_HAS_MUSL_LIBC) 53d409305fSDimitry Andric# include <__support/musl/xlocale.h> 540b57cec5SDimitry Andric#endif 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 570b57cec5SDimitry Andric# pragma GCC system_header 580b57cec5SDimitry Andric#endif 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 610b57cec5SDimitry Andric 6206c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale; 630b57cec5SDimitry Andric 640b57cec5SDimitry Andrictemplate <class _Facet> 65*5f757f3fSDimitry Andric_LIBCPP_HIDE_FROM_ABI 660b57cec5SDimitry Andricbool 670b57cec5SDimitry Andrichas_facet(const locale&) _NOEXCEPT; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andrictemplate <class _Facet> 70*5f757f3fSDimitry Andric_LIBCPP_HIDE_FROM_ABI 710b57cec5SDimitry Andricconst _Facet& 720b57cec5SDimitry Andricuse_facet(const locale&); 730b57cec5SDimitry Andric 7406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale 750b57cec5SDimitry Andric{ 760b57cec5SDimitry Andricpublic: 770b57cec5SDimitry Andric // types: 7806c3fb27SDimitry Andric class _LIBCPP_EXPORTED_FROM_ABI facet; 7906c3fb27SDimitry Andric class _LIBCPP_EXPORTED_FROM_ABI id; 800b57cec5SDimitry Andric 810b57cec5SDimitry Andric typedef int category; 82*5f757f3fSDimitry Andric 830b57cec5SDimitry Andric static const category // values assigned here are for exposition only 840b57cec5SDimitry Andric none = 0, 850b57cec5SDimitry Andric collate = LC_COLLATE_MASK, 860b57cec5SDimitry Andric ctype = LC_CTYPE_MASK, 870b57cec5SDimitry Andric monetary = LC_MONETARY_MASK, 880b57cec5SDimitry Andric numeric = LC_NUMERIC_MASK, 890b57cec5SDimitry Andric time = LC_TIME_MASK, 900b57cec5SDimitry Andric messages = LC_MESSAGES_MASK, 910b57cec5SDimitry Andric all = collate | ctype | monetary | numeric | time | messages; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric // construct/copy/destroy: 940b57cec5SDimitry Andric locale() _NOEXCEPT; 950b57cec5SDimitry Andric locale(const locale&) _NOEXCEPT; 960b57cec5SDimitry Andric explicit locale(const char*); 970b57cec5SDimitry Andric explicit locale(const string&); 980b57cec5SDimitry Andric locale(const locale&, const char*, category); 990b57cec5SDimitry Andric locale(const locale&, const string&, category); 1000b57cec5SDimitry Andric template <class _Facet> 101*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI locale(const locale&, _Facet*); 1020b57cec5SDimitry Andric locale(const locale&, const locale&, category); 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric ~locale(); 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric const locale& operator=(const locale&) _NOEXCEPT; 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andric template <class _Facet> 1090b57cec5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1100b57cec5SDimitry Andric locale combine(const locale&) const; 1110b57cec5SDimitry Andric 1120b57cec5SDimitry Andric // locale operations: 1130b57cec5SDimitry Andric string name() const; 1140b57cec5SDimitry Andric bool operator==(const locale&) const; 11506c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 11606c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const {return !(*this == __y);} 11706c3fb27SDimitry Andric#endif 1180b57cec5SDimitry Andric template <class _CharT, class _Traits, class _Allocator> 1190b57cec5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1200b57cec5SDimitry Andric bool operator()(const basic_string<_CharT, _Traits, _Allocator>&, 1210b57cec5SDimitry Andric const basic_string<_CharT, _Traits, _Allocator>&) const; 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andric // global locale objects: 1240b57cec5SDimitry Andric static locale global(const locale&); 1250b57cec5SDimitry Andric static const locale& classic(); 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andricprivate: 1280b57cec5SDimitry Andric class __imp; 1290b57cec5SDimitry Andric __imp* __locale_; 1300b57cec5SDimitry Andric 131*5f757f3fSDimitry Andric template <class> friend struct __no_destroy; 132*5f757f3fSDimitry Andric struct __private_tag { }; 133*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit locale(__private_tag, __imp* __loc) : __locale_(__loc) {} 134*5f757f3fSDimitry Andric 1350b57cec5SDimitry Andric void __install_ctor(const locale&, facet*, long); 1360b57cec5SDimitry Andric static locale& __global(); 1370b57cec5SDimitry Andric bool has_facet(id&) const; 1380b57cec5SDimitry Andric const facet* use_facet(id&) const; 1390b57cec5SDimitry Andric 1400b57cec5SDimitry Andric template <class _Facet> friend bool has_facet(const locale&) _NOEXCEPT; 1410b57cec5SDimitry Andric template <class _Facet> friend const _Facet& use_facet(const locale&); 1420b57cec5SDimitry Andric}; 1430b57cec5SDimitry Andric 14406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale::facet 1450b57cec5SDimitry Andric : public __shared_count 1460b57cec5SDimitry Andric{ 1470b57cec5SDimitry Andricprotected: 148*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1490b57cec5SDimitry Andric explicit facet(size_t __refs = 0) 1500b57cec5SDimitry Andric : __shared_count(static_cast<long>(__refs)-1) {} 1510b57cec5SDimitry Andric 152bdd1243dSDimitry Andric ~facet() override; 1530b57cec5SDimitry Andric 1540b57cec5SDimitry Andric// facet(const facet&) = delete; // effectively done in __shared_count 1550b57cec5SDimitry Andric// void operator=(const facet&) = delete; 1560b57cec5SDimitry Andricprivate: 157bdd1243dSDimitry Andric void __on_zero_shared() _NOEXCEPT override; 1580b57cec5SDimitry Andric}; 1590b57cec5SDimitry Andric 16006c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale::id 1610b57cec5SDimitry Andric{ 1620b57cec5SDimitry Andric once_flag __flag_; 1630b57cec5SDimitry Andric int32_t __id_; 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andric static int32_t __next_id; 1660b57cec5SDimitry Andricpublic: 167*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR id() :__id_(0) {} 1680eae32dcSDimitry Andric void operator=(const id&) = delete; 1690eae32dcSDimitry Andric id(const id&) = delete; 1700eae32dcSDimitry Andric 1710b57cec5SDimitry Andricpublic: // only needed for tests 1720b57cec5SDimitry Andric long __get(); 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andric friend class locale; 1750b57cec5SDimitry Andric friend class locale::__imp; 1760b57cec5SDimitry Andric}; 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andrictemplate <class _Facet> 179*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 1800b57cec5SDimitry Andriclocale::locale(const locale& __other, _Facet* __f) 1810b57cec5SDimitry Andric{ 1820b57cec5SDimitry Andric __install_ctor(__other, __f, __f ? __f->id.__get() : 0); 1830b57cec5SDimitry Andric} 1840b57cec5SDimitry Andric 1850b57cec5SDimitry Andrictemplate <class _Facet> 1860b57cec5SDimitry Andriclocale 1870b57cec5SDimitry Andriclocale::combine(const locale& __other) const 1880b57cec5SDimitry Andric{ 189*5f757f3fSDimitry Andric if (!std::has_facet<_Facet>(__other)) 1900b57cec5SDimitry Andric __throw_runtime_error("locale::combine: locale missing facet"); 1910b57cec5SDimitry Andric 192*5f757f3fSDimitry Andric return locale(*this, &const_cast<_Facet&>(std::use_facet<_Facet>(__other))); 1930b57cec5SDimitry Andric} 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andrictemplate <class _Facet> 196*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 1970b57cec5SDimitry Andricbool 1980b57cec5SDimitry Andrichas_facet(const locale& __l) _NOEXCEPT 1990b57cec5SDimitry Andric{ 2000b57cec5SDimitry Andric return __l.has_facet(_Facet::id); 2010b57cec5SDimitry Andric} 2020b57cec5SDimitry Andric 2030b57cec5SDimitry Andrictemplate <class _Facet> 204*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 2050b57cec5SDimitry Andricconst _Facet& 2060b57cec5SDimitry Andricuse_facet(const locale& __l) 2070b57cec5SDimitry Andric{ 2080b57cec5SDimitry Andric return static_cast<const _Facet&>(*__l.use_facet(_Facet::id)); 2090b57cec5SDimitry Andric} 2100b57cec5SDimitry Andric 2110b57cec5SDimitry Andric// template <class _CharT> class collate; 2120b57cec5SDimitry Andric 2130b57cec5SDimitry Andrictemplate <class _CharT> 2140b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS collate 2150b57cec5SDimitry Andric : public locale::facet 2160b57cec5SDimitry Andric{ 2170b57cec5SDimitry Andricpublic: 2180b57cec5SDimitry Andric typedef _CharT char_type; 2190b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 2200b57cec5SDimitry Andric 221*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2220b57cec5SDimitry Andric explicit collate(size_t __refs = 0) 2230b57cec5SDimitry Andric : locale::facet(__refs) {} 2240b57cec5SDimitry Andric 225*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2260b57cec5SDimitry Andric int compare(const char_type* __lo1, const char_type* __hi1, 2270b57cec5SDimitry Andric const char_type* __lo2, const char_type* __hi2) const 2280b57cec5SDimitry Andric { 2290b57cec5SDimitry Andric return do_compare(__lo1, __hi1, __lo2, __hi2); 2300b57cec5SDimitry Andric } 2310b57cec5SDimitry Andric 2320b57cec5SDimitry Andric // FIXME(EricWF): The _LIBCPP_ALWAYS_INLINE is needed on Windows to work 2330b57cec5SDimitry Andric // around a dllimport bug that expects an external instantiation. 234*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2350b57cec5SDimitry Andric _LIBCPP_ALWAYS_INLINE 2360b57cec5SDimitry Andric string_type transform(const char_type* __lo, const char_type* __hi) const 2370b57cec5SDimitry Andric { 2380b57cec5SDimitry Andric return do_transform(__lo, __hi); 2390b57cec5SDimitry Andric } 2400b57cec5SDimitry Andric 241*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2420b57cec5SDimitry Andric long hash(const char_type* __lo, const char_type* __hi) const 2430b57cec5SDimitry Andric { 2440b57cec5SDimitry Andric return do_hash(__lo, __hi); 2450b57cec5SDimitry Andric } 2460b57cec5SDimitry Andric 2470b57cec5SDimitry Andric static locale::id id; 2480b57cec5SDimitry Andric 2490b57cec5SDimitry Andricprotected: 250bdd1243dSDimitry Andric ~collate() override; 2510b57cec5SDimitry Andric virtual int do_compare(const char_type* __lo1, const char_type* __hi1, 2520b57cec5SDimitry Andric const char_type* __lo2, const char_type* __hi2) const; 2530b57cec5SDimitry Andric virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const 2540b57cec5SDimitry Andric {return string_type(__lo, __hi);} 2550b57cec5SDimitry Andric virtual long do_hash(const char_type* __lo, const char_type* __hi) const; 2560b57cec5SDimitry Andric}; 2570b57cec5SDimitry Andric 2580b57cec5SDimitry Andrictemplate <class _CharT> locale::id collate<_CharT>::id; 2590b57cec5SDimitry Andric 2600b57cec5SDimitry Andrictemplate <class _CharT> 2610b57cec5SDimitry Andriccollate<_CharT>::~collate() 2620b57cec5SDimitry Andric{ 2630b57cec5SDimitry Andric} 2640b57cec5SDimitry Andric 2650b57cec5SDimitry Andrictemplate <class _CharT> 2660b57cec5SDimitry Andricint 2670b57cec5SDimitry Andriccollate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1, 2680b57cec5SDimitry Andric const char_type* __lo2, const char_type* __hi2) const 2690b57cec5SDimitry Andric{ 2700b57cec5SDimitry Andric for (; __lo2 != __hi2; ++__lo1, ++__lo2) 2710b57cec5SDimitry Andric { 2720b57cec5SDimitry Andric if (__lo1 == __hi1 || *__lo1 < *__lo2) 2730b57cec5SDimitry Andric return -1; 2740b57cec5SDimitry Andric if (*__lo2 < *__lo1) 2750b57cec5SDimitry Andric return 1; 2760b57cec5SDimitry Andric } 2770b57cec5SDimitry Andric return __lo1 != __hi1; 2780b57cec5SDimitry Andric} 2790b57cec5SDimitry Andric 2800b57cec5SDimitry Andrictemplate <class _CharT> 2810b57cec5SDimitry Andriclong 2820b57cec5SDimitry Andriccollate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const 2830b57cec5SDimitry Andric{ 2840b57cec5SDimitry Andric size_t __h = 0; 2850b57cec5SDimitry Andric const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8; 2860b57cec5SDimitry Andric const size_t __mask = size_t(0xF) << (__sr + 4); 2870b57cec5SDimitry Andric for(const char_type* __p = __lo; __p != __hi; ++__p) 2880b57cec5SDimitry Andric { 2890b57cec5SDimitry Andric __h = (__h << 4) + static_cast<size_t>(*__p); 2900b57cec5SDimitry Andric size_t __g = __h & __mask; 2910b57cec5SDimitry Andric __h ^= __g | (__g >> __sr); 2920b57cec5SDimitry Andric } 2930b57cec5SDimitry Andric return static_cast<long>(__h); 2940b57cec5SDimitry Andric} 2950b57cec5SDimitry Andric 29681ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>; 297349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 29881ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>; 299349cc55cSDimitry Andric#endif 3000b57cec5SDimitry Andric 3010b57cec5SDimitry Andric// template <class CharT> class collate_byname; 3020b57cec5SDimitry Andric 3030b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname; 3040b57cec5SDimitry Andric 3050b57cec5SDimitry Andrictemplate <> 30606c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> 3070b57cec5SDimitry Andric : public collate<char> 3080b57cec5SDimitry Andric{ 309bdd1243dSDimitry Andric locale_t __l_; 3100b57cec5SDimitry Andricpublic: 3110b57cec5SDimitry Andric typedef char char_type; 3120b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andric explicit collate_byname(const char* __n, size_t __refs = 0); 3150b57cec5SDimitry Andric explicit collate_byname(const string& __n, size_t __refs = 0); 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andricprotected: 318bdd1243dSDimitry Andric ~collate_byname() override; 319bdd1243dSDimitry Andric int do_compare(const char_type* __lo1, const char_type* __hi1, 320bdd1243dSDimitry Andric const char_type* __lo2, const char_type* __hi2) const override; 321bdd1243dSDimitry Andric string_type do_transform(const char_type* __lo, const char_type* __hi) const override; 3220b57cec5SDimitry Andric}; 3230b57cec5SDimitry Andric 324349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 3250b57cec5SDimitry Andrictemplate <> 32606c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> 3270b57cec5SDimitry Andric : public collate<wchar_t> 3280b57cec5SDimitry Andric{ 329bdd1243dSDimitry Andric locale_t __l_; 3300b57cec5SDimitry Andricpublic: 3310b57cec5SDimitry Andric typedef wchar_t char_type; 3320b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andric explicit collate_byname(const char* __n, size_t __refs = 0); 3350b57cec5SDimitry Andric explicit collate_byname(const string& __n, size_t __refs = 0); 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andricprotected: 338bdd1243dSDimitry Andric ~collate_byname() override; 3390b57cec5SDimitry Andric 340bdd1243dSDimitry Andric int do_compare(const char_type* __lo1, const char_type* __hi1, 341bdd1243dSDimitry Andric const char_type* __lo2, const char_type* __hi2) const override; 342bdd1243dSDimitry Andric string_type do_transform(const char_type* __lo, const char_type* __hi) const override; 3430b57cec5SDimitry Andric}; 344349cc55cSDimitry Andric#endif 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3470b57cec5SDimitry Andricbool 3480b57cec5SDimitry Andriclocale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, 3490b57cec5SDimitry Andric const basic_string<_CharT, _Traits, _Allocator>& __y) const 3500b57cec5SDimitry Andric{ 351*5f757f3fSDimitry Andric return std::use_facet<std::collate<_CharT> >(*this).compare( 3520b57cec5SDimitry Andric __x.data(), __x.data() + __x.size(), 3530b57cec5SDimitry Andric __y.data(), __y.data() + __y.size()) < 0; 3540b57cec5SDimitry Andric} 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric// template <class charT> class ctype 3570b57cec5SDimitry Andric 35806c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype_base 3590b57cec5SDimitry Andric{ 3600b57cec5SDimitry Andricpublic: 361e8d8bef9SDimitry Andric#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE) 362e8d8bef9SDimitry Andric typedef unsigned long mask; 363e8d8bef9SDimitry Andric static const mask space = 1<<0; 364e8d8bef9SDimitry Andric static const mask print = 1<<1; 365e8d8bef9SDimitry Andric static const mask cntrl = 1<<2; 366e8d8bef9SDimitry Andric static const mask upper = 1<<3; 367e8d8bef9SDimitry Andric static const mask lower = 1<<4; 368e8d8bef9SDimitry Andric static const mask alpha = 1<<5; 369e8d8bef9SDimitry Andric static const mask digit = 1<<6; 370e8d8bef9SDimitry Andric static const mask punct = 1<<7; 371e8d8bef9SDimitry Andric static const mask xdigit = 1<<8; 372e8d8bef9SDimitry Andric static const mask blank = 1<<9; 373e8d8bef9SDimitry Andric#if defined(__BIONIC__) 374e8d8bef9SDimitry Andric // Historically this was a part of regex_traits rather than ctype_base. The 375e8d8bef9SDimitry Andric // historical value of the constant is preserved for ABI compatibility. 376e8d8bef9SDimitry Andric static const mask __regex_word = 0x8000; 377e8d8bef9SDimitry Andric#else 378e8d8bef9SDimitry Andric static const mask __regex_word = 1<<10; 379e8d8bef9SDimitry Andric#endif // defined(__BIONIC__) 380e8d8bef9SDimitry Andric#elif defined(__GLIBC__) 3810b57cec5SDimitry Andric typedef unsigned short mask; 3820b57cec5SDimitry Andric static const mask space = _ISspace; 3830b57cec5SDimitry Andric static const mask print = _ISprint; 3840b57cec5SDimitry Andric static const mask cntrl = _IScntrl; 3850b57cec5SDimitry Andric static const mask upper = _ISupper; 3860b57cec5SDimitry Andric static const mask lower = _ISlower; 3870b57cec5SDimitry Andric static const mask alpha = _ISalpha; 3880b57cec5SDimitry Andric static const mask digit = _ISdigit; 3890b57cec5SDimitry Andric static const mask punct = _ISpunct; 3900b57cec5SDimitry Andric static const mask xdigit = _ISxdigit; 3910b57cec5SDimitry Andric static const mask blank = _ISblank; 392*5f757f3fSDimitry Andric#if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN) 3930b57cec5SDimitry Andric static const mask __regex_word = static_cast<mask>(_ISbit(15)); 3940b57cec5SDimitry Andric#else 3950b57cec5SDimitry Andric static const mask __regex_word = 0x80; 3960b57cec5SDimitry Andric#endif 3970b57cec5SDimitry Andric#elif defined(_LIBCPP_MSVCRT_LIKE) 3980b57cec5SDimitry Andric typedef unsigned short mask; 3990b57cec5SDimitry Andric static const mask space = _SPACE; 4000b57cec5SDimitry Andric static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; 4010b57cec5SDimitry Andric static const mask cntrl = _CONTROL; 4020b57cec5SDimitry Andric static const mask upper = _UPPER; 4030b57cec5SDimitry Andric static const mask lower = _LOWER; 4040b57cec5SDimitry Andric static const mask alpha = _ALPHA; 4050b57cec5SDimitry Andric static const mask digit = _DIGIT; 4060b57cec5SDimitry Andric static const mask punct = _PUNCT; 4070b57cec5SDimitry Andric static const mask xdigit = _HEX; 4080b57cec5SDimitry Andric static const mask blank = _BLANK; 4091fd87a68SDimitry Andric static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used 4100b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT 41181ad6265SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA 4120b57cec5SDimitry Andric#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) 4130b57cec5SDimitry Andric# ifdef __APPLE__ 4140b57cec5SDimitry Andric typedef __uint32_t mask; 4150b57cec5SDimitry Andric# elif defined(__FreeBSD__) 4160b57cec5SDimitry Andric typedef unsigned long mask; 4170b57cec5SDimitry Andric# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) 4180b57cec5SDimitry Andric typedef unsigned short mask; 4190b57cec5SDimitry Andric# endif 4200b57cec5SDimitry Andric static const mask space = _CTYPE_S; 4210b57cec5SDimitry Andric static const mask print = _CTYPE_R; 4220b57cec5SDimitry Andric static const mask cntrl = _CTYPE_C; 4230b57cec5SDimitry Andric static const mask upper = _CTYPE_U; 4240b57cec5SDimitry Andric static const mask lower = _CTYPE_L; 4250b57cec5SDimitry Andric static const mask alpha = _CTYPE_A; 4260b57cec5SDimitry Andric static const mask digit = _CTYPE_D; 4270b57cec5SDimitry Andric static const mask punct = _CTYPE_P; 4280b57cec5SDimitry Andric static const mask xdigit = _CTYPE_X; 4290b57cec5SDimitry Andric 4300b57cec5SDimitry Andric# if defined(__NetBSD__) 4310b57cec5SDimitry Andric static const mask blank = _CTYPE_BL; 4320b57cec5SDimitry Andric // NetBSD defines classes up to 0x2000 4330b57cec5SDimitry Andric // see sys/ctype_bits.h, _CTYPE_Q 4340b57cec5SDimitry Andric static const mask __regex_word = 0x8000; 4350b57cec5SDimitry Andric# else 4360b57cec5SDimitry Andric static const mask blank = _CTYPE_B; 4370b57cec5SDimitry Andric static const mask __regex_word = 0x80; 4380b57cec5SDimitry Andric# endif 43906c3fb27SDimitry Andric#elif defined(_AIX) 4400b57cec5SDimitry Andric typedef unsigned int mask; 4410b57cec5SDimitry Andric static const mask space = _ISSPACE; 4420b57cec5SDimitry Andric static const mask print = _ISPRINT; 4430b57cec5SDimitry Andric static const mask cntrl = _ISCNTRL; 4440b57cec5SDimitry Andric static const mask upper = _ISUPPER; 4450b57cec5SDimitry Andric static const mask lower = _ISLOWER; 4460b57cec5SDimitry Andric static const mask alpha = _ISALPHA; 4470b57cec5SDimitry Andric static const mask digit = _ISDIGIT; 4480b57cec5SDimitry Andric static const mask punct = _ISPUNCT; 4490b57cec5SDimitry Andric static const mask xdigit = _ISXDIGIT; 4500b57cec5SDimitry Andric static const mask blank = _ISBLANK; 451fcaf7f86SDimitry Andric static const mask __regex_word = 0x8000; 4520b57cec5SDimitry Andric#elif defined(_NEWLIB_VERSION) 4530b57cec5SDimitry Andric // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. 4540b57cec5SDimitry Andric typedef char mask; 455*5f757f3fSDimitry Andric // In case char is signed, static_cast is needed to avoid warning on 456*5f757f3fSDimitry Andric // positive value becomming negative. 457*5f757f3fSDimitry Andric static const mask space = static_cast<mask>(_S); 458*5f757f3fSDimitry Andric static const mask print = static_cast<mask>(_P | _U | _L | _N | _B); 459*5f757f3fSDimitry Andric static const mask cntrl = static_cast<mask>(_C); 460*5f757f3fSDimitry Andric static const mask upper = static_cast<mask>(_U); 461*5f757f3fSDimitry Andric static const mask lower = static_cast<mask>(_L); 462*5f757f3fSDimitry Andric static const mask alpha = static_cast<mask>(_U | _L); 463*5f757f3fSDimitry Andric static const mask digit = static_cast<mask>(_N); 464*5f757f3fSDimitry Andric static const mask punct = static_cast<mask>(_P); 465*5f757f3fSDimitry Andric static const mask xdigit = static_cast<mask>(_X | _N); 466*5f757f3fSDimitry Andric static const mask blank = static_cast<mask>(_B); 467bdd1243dSDimitry Andric // mask is already fully saturated, use a different type in regex_type_traits. 468bdd1243dSDimitry Andric static const unsigned short __regex_word = 0x100; 4690b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT 4700b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA 4710b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT 47204eeddc0SDimitry Andric#elif defined(__MVS__) 47304eeddc0SDimitry Andric# if defined(__NATIVE_ASCII_F) 47404eeddc0SDimitry Andric typedef unsigned int mask; 47504eeddc0SDimitry Andric static const mask space = _ISSPACE_A; 47604eeddc0SDimitry Andric static const mask print = _ISPRINT_A; 47704eeddc0SDimitry Andric static const mask cntrl = _ISCNTRL_A; 47804eeddc0SDimitry Andric static const mask upper = _ISUPPER_A; 47904eeddc0SDimitry Andric static const mask lower = _ISLOWER_A; 48004eeddc0SDimitry Andric static const mask alpha = _ISALPHA_A; 48104eeddc0SDimitry Andric static const mask digit = _ISDIGIT_A; 48204eeddc0SDimitry Andric static const mask punct = _ISPUNCT_A; 48304eeddc0SDimitry Andric static const mask xdigit = _ISXDIGIT_A; 48404eeddc0SDimitry Andric static const mask blank = _ISBLANK_A; 48504eeddc0SDimitry Andric# else 48604eeddc0SDimitry Andric typedef unsigned short mask; 48704eeddc0SDimitry Andric static const mask space = __ISSPACE; 48804eeddc0SDimitry Andric static const mask print = __ISPRINT; 48904eeddc0SDimitry Andric static const mask cntrl = __ISCNTRL; 49004eeddc0SDimitry Andric static const mask upper = __ISUPPER; 49104eeddc0SDimitry Andric static const mask lower = __ISLOWER; 49204eeddc0SDimitry Andric static const mask alpha = __ISALPHA; 49304eeddc0SDimitry Andric static const mask digit = __ISDIGIT; 49404eeddc0SDimitry Andric static const mask punct = __ISPUNCT; 49504eeddc0SDimitry Andric static const mask xdigit = __ISXDIGIT; 49604eeddc0SDimitry Andric static const mask blank = __ISBLANK; 49704eeddc0SDimitry Andric# endif 49804eeddc0SDimitry Andric static const mask __regex_word = 0x8000; 4990b57cec5SDimitry Andric#else 500e8d8bef9SDimitry Andric# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? 5010b57cec5SDimitry Andric#endif 5020b57cec5SDimitry Andric static const mask alnum = alpha | digit; 5030b57cec5SDimitry Andric static const mask graph = alnum | punct; 5040b57cec5SDimitry Andric 505*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI ctype_base() {} 5061fd87a68SDimitry Andric 507bdd1243dSDimitry Andric static_assert((__regex_word & ~(std::make_unsigned<mask>::type)(space | print | cntrl | upper | lower | alpha | 508bdd1243dSDimitry Andric digit | punct | xdigit | blank)) == __regex_word, 5091fd87a68SDimitry Andric "__regex_word can't overlap other bits"); 5100b57cec5SDimitry Andric}; 5110b57cec5SDimitry Andric 5120b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype; 5130b57cec5SDimitry Andric 514349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 5150b57cec5SDimitry Andrictemplate <> 51606c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> 5170b57cec5SDimitry Andric : public locale::facet, 5180b57cec5SDimitry Andric public ctype_base 5190b57cec5SDimitry Andric{ 5200b57cec5SDimitry Andricpublic: 5210b57cec5SDimitry Andric typedef wchar_t char_type; 5220b57cec5SDimitry Andric 523*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5240b57cec5SDimitry Andric explicit ctype(size_t __refs = 0) 5250b57cec5SDimitry Andric : locale::facet(__refs) {} 5260b57cec5SDimitry Andric 527*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5280b57cec5SDimitry Andric bool is(mask __m, char_type __c) const 5290b57cec5SDimitry Andric { 5300b57cec5SDimitry Andric return do_is(__m, __c); 5310b57cec5SDimitry Andric } 5320b57cec5SDimitry Andric 533*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5340b57cec5SDimitry Andric const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const 5350b57cec5SDimitry Andric { 5360b57cec5SDimitry Andric return do_is(__low, __high, __vec); 5370b57cec5SDimitry Andric } 5380b57cec5SDimitry Andric 539*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5400b57cec5SDimitry Andric const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const 5410b57cec5SDimitry Andric { 5420b57cec5SDimitry Andric return do_scan_is(__m, __low, __high); 5430b57cec5SDimitry Andric } 5440b57cec5SDimitry Andric 545*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5460b57cec5SDimitry Andric const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const 5470b57cec5SDimitry Andric { 5480b57cec5SDimitry Andric return do_scan_not(__m, __low, __high); 5490b57cec5SDimitry Andric } 5500b57cec5SDimitry Andric 551*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5520b57cec5SDimitry Andric char_type toupper(char_type __c) const 5530b57cec5SDimitry Andric { 5540b57cec5SDimitry Andric return do_toupper(__c); 5550b57cec5SDimitry Andric } 5560b57cec5SDimitry Andric 557*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5580b57cec5SDimitry Andric const char_type* toupper(char_type* __low, const char_type* __high) const 5590b57cec5SDimitry Andric { 5600b57cec5SDimitry Andric return do_toupper(__low, __high); 5610b57cec5SDimitry Andric } 5620b57cec5SDimitry Andric 563*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5640b57cec5SDimitry Andric char_type tolower(char_type __c) const 5650b57cec5SDimitry Andric { 5660b57cec5SDimitry Andric return do_tolower(__c); 5670b57cec5SDimitry Andric } 5680b57cec5SDimitry Andric 569*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5700b57cec5SDimitry Andric const char_type* tolower(char_type* __low, const char_type* __high) const 5710b57cec5SDimitry Andric { 5720b57cec5SDimitry Andric return do_tolower(__low, __high); 5730b57cec5SDimitry Andric } 5740b57cec5SDimitry Andric 575*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5760b57cec5SDimitry Andric char_type widen(char __c) const 5770b57cec5SDimitry Andric { 5780b57cec5SDimitry Andric return do_widen(__c); 5790b57cec5SDimitry Andric } 5800b57cec5SDimitry Andric 581*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5820b57cec5SDimitry Andric const char* widen(const char* __low, const char* __high, char_type* __to) const 5830b57cec5SDimitry Andric { 5840b57cec5SDimitry Andric return do_widen(__low, __high, __to); 5850b57cec5SDimitry Andric } 5860b57cec5SDimitry Andric 587*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5880b57cec5SDimitry Andric char narrow(char_type __c, char __dfault) const 5890b57cec5SDimitry Andric { 5900b57cec5SDimitry Andric return do_narrow(__c, __dfault); 5910b57cec5SDimitry Andric } 5920b57cec5SDimitry Andric 593*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5940b57cec5SDimitry Andric const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const 5950b57cec5SDimitry Andric { 5960b57cec5SDimitry Andric return do_narrow(__low, __high, __dfault, __to); 5970b57cec5SDimitry Andric } 5980b57cec5SDimitry Andric 5990b57cec5SDimitry Andric static locale::id id; 6000b57cec5SDimitry Andric 6010b57cec5SDimitry Andricprotected: 602bdd1243dSDimitry Andric ~ctype() override; 6030b57cec5SDimitry Andric virtual bool do_is(mask __m, char_type __c) const; 6040b57cec5SDimitry Andric virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; 6050b57cec5SDimitry Andric virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; 6060b57cec5SDimitry Andric virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; 6070b57cec5SDimitry Andric virtual char_type do_toupper(char_type) const; 6080b57cec5SDimitry Andric virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; 6090b57cec5SDimitry Andric virtual char_type do_tolower(char_type) const; 6100b57cec5SDimitry Andric virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; 6110b57cec5SDimitry Andric virtual char_type do_widen(char) const; 6120b57cec5SDimitry Andric virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; 6130b57cec5SDimitry Andric virtual char do_narrow(char_type, char __dfault) const; 6140b57cec5SDimitry Andric virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; 6150b57cec5SDimitry Andric}; 616349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 6170b57cec5SDimitry Andric 6180b57cec5SDimitry Andrictemplate <> 61906c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype<char> 6200b57cec5SDimitry Andric : public locale::facet, public ctype_base 6210b57cec5SDimitry Andric{ 6220b57cec5SDimitry Andric const mask* __tab_; 6230b57cec5SDimitry Andric bool __del_; 6240b57cec5SDimitry Andricpublic: 6250b57cec5SDimitry Andric typedef char char_type; 6260b57cec5SDimitry Andric 627e8d8bef9SDimitry Andric explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0); 6280b57cec5SDimitry Andric 629*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6300b57cec5SDimitry Andric bool is(mask __m, char_type __c) const 6310b57cec5SDimitry Andric { 6320b57cec5SDimitry Andric return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false; 6330b57cec5SDimitry Andric } 6340b57cec5SDimitry Andric 635*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6360b57cec5SDimitry Andric const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const 6370b57cec5SDimitry Andric { 6380b57cec5SDimitry Andric for (; __low != __high; ++__low, ++__vec) 6390b57cec5SDimitry Andric *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0; 6400b57cec5SDimitry Andric return __low; 6410b57cec5SDimitry Andric } 6420b57cec5SDimitry Andric 643*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6440b57cec5SDimitry Andric const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const 6450b57cec5SDimitry Andric { 6460b57cec5SDimitry Andric for (; __low != __high; ++__low) 6470b57cec5SDimitry Andric if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)) 6480b57cec5SDimitry Andric break; 6490b57cec5SDimitry Andric return __low; 6500b57cec5SDimitry Andric } 6510b57cec5SDimitry Andric 652*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6530b57cec5SDimitry Andric const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const 6540b57cec5SDimitry Andric { 6550b57cec5SDimitry Andric for (; __low != __high; ++__low) 656bdd1243dSDimitry Andric if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m)) 6570b57cec5SDimitry Andric break; 6580b57cec5SDimitry Andric return __low; 6590b57cec5SDimitry Andric } 6600b57cec5SDimitry Andric 661*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6620b57cec5SDimitry Andric char_type toupper(char_type __c) const 6630b57cec5SDimitry Andric { 6640b57cec5SDimitry Andric return do_toupper(__c); 6650b57cec5SDimitry Andric } 6660b57cec5SDimitry Andric 667*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6680b57cec5SDimitry Andric const char_type* toupper(char_type* __low, const char_type* __high) const 6690b57cec5SDimitry Andric { 6700b57cec5SDimitry Andric return do_toupper(__low, __high); 6710b57cec5SDimitry Andric } 6720b57cec5SDimitry Andric 673*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6740b57cec5SDimitry Andric char_type tolower(char_type __c) const 6750b57cec5SDimitry Andric { 6760b57cec5SDimitry Andric return do_tolower(__c); 6770b57cec5SDimitry Andric } 6780b57cec5SDimitry Andric 679*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6800b57cec5SDimitry Andric const char_type* tolower(char_type* __low, const char_type* __high) const 6810b57cec5SDimitry Andric { 6820b57cec5SDimitry Andric return do_tolower(__low, __high); 6830b57cec5SDimitry Andric } 6840b57cec5SDimitry Andric 685*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6860b57cec5SDimitry Andric char_type widen(char __c) const 6870b57cec5SDimitry Andric { 6880b57cec5SDimitry Andric return do_widen(__c); 6890b57cec5SDimitry Andric } 6900b57cec5SDimitry Andric 691*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6920b57cec5SDimitry Andric const char* widen(const char* __low, const char* __high, char_type* __to) const 6930b57cec5SDimitry Andric { 6940b57cec5SDimitry Andric return do_widen(__low, __high, __to); 6950b57cec5SDimitry Andric } 6960b57cec5SDimitry Andric 697*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6980b57cec5SDimitry Andric char narrow(char_type __c, char __dfault) const 6990b57cec5SDimitry Andric { 7000b57cec5SDimitry Andric return do_narrow(__c, __dfault); 7010b57cec5SDimitry Andric } 7020b57cec5SDimitry Andric 703*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7040b57cec5SDimitry Andric const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const 7050b57cec5SDimitry Andric { 7060b57cec5SDimitry Andric return do_narrow(__low, __high, __dfault, __to); 7070b57cec5SDimitry Andric } 7080b57cec5SDimitry Andric 7090b57cec5SDimitry Andric static locale::id id; 7100b57cec5SDimitry Andric 7110b57cec5SDimitry Andric#ifdef _CACHED_RUNES 7120b57cec5SDimitry Andric static const size_t table_size = _CACHED_RUNES; 7130b57cec5SDimitry Andric#else 7140b57cec5SDimitry Andric static const size_t table_size = 256; // FIXME: Don't hardcode this. 7150b57cec5SDimitry Andric#endif 716*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT {return __tab_;} 7170b57cec5SDimitry Andric static const mask* classic_table() _NOEXCEPT; 7180b57cec5SDimitry Andric#if defined(__GLIBC__) || defined(__EMSCRIPTEN__) 7190b57cec5SDimitry Andric static const int* __classic_upper_table() _NOEXCEPT; 7200b57cec5SDimitry Andric static const int* __classic_lower_table() _NOEXCEPT; 7210b57cec5SDimitry Andric#endif 7220b57cec5SDimitry Andric#if defined(__NetBSD__) 7230b57cec5SDimitry Andric static const short* __classic_upper_table() _NOEXCEPT; 7240b57cec5SDimitry Andric static const short* __classic_lower_table() _NOEXCEPT; 7250b57cec5SDimitry Andric#endif 72604eeddc0SDimitry Andric#if defined(__MVS__) 72704eeddc0SDimitry Andric static const unsigned short* __classic_upper_table() _NOEXCEPT; 72804eeddc0SDimitry Andric static const unsigned short* __classic_lower_table() _NOEXCEPT; 72904eeddc0SDimitry Andric#endif 7300b57cec5SDimitry Andric 7310b57cec5SDimitry Andricprotected: 732bdd1243dSDimitry Andric ~ctype() override; 7330b57cec5SDimitry Andric virtual char_type do_toupper(char_type __c) const; 7340b57cec5SDimitry Andric virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; 7350b57cec5SDimitry Andric virtual char_type do_tolower(char_type __c) const; 7360b57cec5SDimitry Andric virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; 7370b57cec5SDimitry Andric virtual char_type do_widen(char __c) const; 7380b57cec5SDimitry Andric virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const; 7390b57cec5SDimitry Andric virtual char do_narrow(char_type __c, char __dfault) const; 7400b57cec5SDimitry Andric virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const; 7410b57cec5SDimitry Andric}; 7420b57cec5SDimitry Andric 7430b57cec5SDimitry Andric// template <class CharT> class ctype_byname; 7440b57cec5SDimitry Andric 7450b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname; 7460b57cec5SDimitry Andric 7470b57cec5SDimitry Andrictemplate <> 74806c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> 7490b57cec5SDimitry Andric : public ctype<char> 7500b57cec5SDimitry Andric{ 751bdd1243dSDimitry Andric locale_t __l_; 7520b57cec5SDimitry Andric 7530b57cec5SDimitry Andricpublic: 7540b57cec5SDimitry Andric explicit ctype_byname(const char*, size_t = 0); 7550b57cec5SDimitry Andric explicit ctype_byname(const string&, size_t = 0); 7560b57cec5SDimitry Andric 7570b57cec5SDimitry Andricprotected: 758bdd1243dSDimitry Andric ~ctype_byname() override; 759bdd1243dSDimitry Andric char_type do_toupper(char_type) const override; 760bdd1243dSDimitry Andric const char_type* do_toupper(char_type* __low, const char_type* __high) const override; 761bdd1243dSDimitry Andric char_type do_tolower(char_type) const override; 762bdd1243dSDimitry Andric const char_type* do_tolower(char_type* __low, const char_type* __high) const override; 7630b57cec5SDimitry Andric}; 7640b57cec5SDimitry Andric 765349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 7660b57cec5SDimitry Andrictemplate <> 76706c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> 7680b57cec5SDimitry Andric : public ctype<wchar_t> 7690b57cec5SDimitry Andric{ 770bdd1243dSDimitry Andric locale_t __l_; 7710b57cec5SDimitry Andric 7720b57cec5SDimitry Andricpublic: 7730b57cec5SDimitry Andric explicit ctype_byname(const char*, size_t = 0); 7740b57cec5SDimitry Andric explicit ctype_byname(const string&, size_t = 0); 7750b57cec5SDimitry Andric 7760b57cec5SDimitry Andricprotected: 777bdd1243dSDimitry Andric ~ctype_byname() override; 778bdd1243dSDimitry Andric bool do_is(mask __m, char_type __c) const override; 779bdd1243dSDimitry Andric const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const override; 780bdd1243dSDimitry Andric const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const override; 781bdd1243dSDimitry Andric const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const override; 782bdd1243dSDimitry Andric char_type do_toupper(char_type) const override; 783bdd1243dSDimitry Andric const char_type* do_toupper(char_type* __low, const char_type* __high) const override; 784bdd1243dSDimitry Andric char_type do_tolower(char_type) const override; 785bdd1243dSDimitry Andric const char_type* do_tolower(char_type* __low, const char_type* __high) const override; 786bdd1243dSDimitry Andric char_type do_widen(char) const override; 787bdd1243dSDimitry Andric const char* do_widen(const char* __low, const char* __high, char_type* __dest) const override; 788bdd1243dSDimitry Andric char do_narrow(char_type, char __dfault) const override; 789bdd1243dSDimitry Andric const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override; 7900b57cec5SDimitry Andric}; 791349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 7920b57cec5SDimitry Andric 7930b57cec5SDimitry Andrictemplate <class _CharT> 794*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 7950b57cec5SDimitry Andricbool 7960b57cec5SDimitry Andricisspace(_CharT __c, const locale& __loc) 7970b57cec5SDimitry Andric{ 798bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); 7990b57cec5SDimitry Andric} 8000b57cec5SDimitry Andric 8010b57cec5SDimitry Andrictemplate <class _CharT> 802*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8030b57cec5SDimitry Andricbool 8040b57cec5SDimitry Andricisprint(_CharT __c, const locale& __loc) 8050b57cec5SDimitry Andric{ 806bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); 8070b57cec5SDimitry Andric} 8080b57cec5SDimitry Andric 8090b57cec5SDimitry Andrictemplate <class _CharT> 810*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8110b57cec5SDimitry Andricbool 8120b57cec5SDimitry Andriciscntrl(_CharT __c, const locale& __loc) 8130b57cec5SDimitry Andric{ 814bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); 8150b57cec5SDimitry Andric} 8160b57cec5SDimitry Andric 8170b57cec5SDimitry Andrictemplate <class _CharT> 818*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8190b57cec5SDimitry Andricbool 8200b57cec5SDimitry Andricisupper(_CharT __c, const locale& __loc) 8210b57cec5SDimitry Andric{ 822bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); 8230b57cec5SDimitry Andric} 8240b57cec5SDimitry Andric 8250b57cec5SDimitry Andrictemplate <class _CharT> 826*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8270b57cec5SDimitry Andricbool 8280b57cec5SDimitry Andricislower(_CharT __c, const locale& __loc) 8290b57cec5SDimitry Andric{ 830bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); 8310b57cec5SDimitry Andric} 8320b57cec5SDimitry Andric 8330b57cec5SDimitry Andrictemplate <class _CharT> 834*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8350b57cec5SDimitry Andricbool 8360b57cec5SDimitry Andricisalpha(_CharT __c, const locale& __loc) 8370b57cec5SDimitry Andric{ 838bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); 8390b57cec5SDimitry Andric} 8400b57cec5SDimitry Andric 8410b57cec5SDimitry Andrictemplate <class _CharT> 842*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8430b57cec5SDimitry Andricbool 8440b57cec5SDimitry Andricisdigit(_CharT __c, const locale& __loc) 8450b57cec5SDimitry Andric{ 846bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); 8470b57cec5SDimitry Andric} 8480b57cec5SDimitry Andric 8490b57cec5SDimitry Andrictemplate <class _CharT> 850*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8510b57cec5SDimitry Andricbool 8520b57cec5SDimitry Andricispunct(_CharT __c, const locale& __loc) 8530b57cec5SDimitry Andric{ 854bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); 8550b57cec5SDimitry Andric} 8560b57cec5SDimitry Andric 8570b57cec5SDimitry Andrictemplate <class _CharT> 858*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8590b57cec5SDimitry Andricbool 8600b57cec5SDimitry Andricisxdigit(_CharT __c, const locale& __loc) 8610b57cec5SDimitry Andric{ 862bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); 8630b57cec5SDimitry Andric} 8640b57cec5SDimitry Andric 8650b57cec5SDimitry Andrictemplate <class _CharT> 866*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8670b57cec5SDimitry Andricbool 8680b57cec5SDimitry Andricisalnum(_CharT __c, const locale& __loc) 8690b57cec5SDimitry Andric{ 870bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); 8710b57cec5SDimitry Andric} 8720b57cec5SDimitry Andric 8730b57cec5SDimitry Andrictemplate <class _CharT> 874*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8750b57cec5SDimitry Andricbool 8760b57cec5SDimitry Andricisgraph(_CharT __c, const locale& __loc) 8770b57cec5SDimitry Andric{ 878bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); 8790b57cec5SDimitry Andric} 8800b57cec5SDimitry Andric 8810b57cec5SDimitry Andrictemplate <class _CharT> 88206c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) { 88306c3fb27SDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c); 88406c3fb27SDimitry Andric} 88506c3fb27SDimitry Andric 88606c3fb27SDimitry Andrictemplate <class _CharT> 887*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8880b57cec5SDimitry Andric_CharT 8890b57cec5SDimitry Andrictoupper(_CharT __c, const locale& __loc) 8900b57cec5SDimitry Andric{ 891bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).toupper(__c); 8920b57cec5SDimitry Andric} 8930b57cec5SDimitry Andric 8940b57cec5SDimitry Andrictemplate <class _CharT> 895*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 8960b57cec5SDimitry Andric_CharT 8970b57cec5SDimitry Andrictolower(_CharT __c, const locale& __loc) 8980b57cec5SDimitry Andric{ 899bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).tolower(__c); 9000b57cec5SDimitry Andric} 9010b57cec5SDimitry Andric 9020b57cec5SDimitry Andric// codecvt_base 9030b57cec5SDimitry Andric 90406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt_base 9050b57cec5SDimitry Andric{ 9060b57cec5SDimitry Andricpublic: 907*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI codecvt_base() {} 9080b57cec5SDimitry Andric enum result {ok, partial, error, noconv}; 9090b57cec5SDimitry Andric}; 9100b57cec5SDimitry Andric 9110b57cec5SDimitry Andric// template <class internT, class externT, class stateT> class codecvt; 9120b57cec5SDimitry Andric 9130b57cec5SDimitry Andrictemplate <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt; 9140b57cec5SDimitry Andric 9150b57cec5SDimitry Andric// template <> class codecvt<char, char, mbstate_t> 9160b57cec5SDimitry Andric 9170b57cec5SDimitry Andrictemplate <> 91806c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<char, char, mbstate_t> 9190b57cec5SDimitry Andric : public locale::facet, 9200b57cec5SDimitry Andric public codecvt_base 9210b57cec5SDimitry Andric{ 9220b57cec5SDimitry Andricpublic: 9230b57cec5SDimitry Andric typedef char intern_type; 9240b57cec5SDimitry Andric typedef char extern_type; 9250b57cec5SDimitry Andric typedef mbstate_t state_type; 9260b57cec5SDimitry Andric 927*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9280b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0) 9290b57cec5SDimitry Andric : locale::facet(__refs) {} 9300b57cec5SDimitry Andric 931*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9320b57cec5SDimitry Andric result out(state_type& __st, 9330b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 9340b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 9350b57cec5SDimitry Andric { 9360b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 9370b57cec5SDimitry Andric } 9380b57cec5SDimitry Andric 939*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9400b57cec5SDimitry Andric result unshift(state_type& __st, 9410b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 9420b57cec5SDimitry Andric { 9430b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 9440b57cec5SDimitry Andric } 9450b57cec5SDimitry Andric 946*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9470b57cec5SDimitry Andric result in(state_type& __st, 9480b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 9490b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 9500b57cec5SDimitry Andric { 9510b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 9520b57cec5SDimitry Andric } 9530b57cec5SDimitry Andric 954*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9550b57cec5SDimitry Andric int encoding() const _NOEXCEPT 9560b57cec5SDimitry Andric { 9570b57cec5SDimitry Andric return do_encoding(); 9580b57cec5SDimitry Andric } 9590b57cec5SDimitry Andric 960*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9610b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 9620b57cec5SDimitry Andric { 9630b57cec5SDimitry Andric return do_always_noconv(); 9640b57cec5SDimitry Andric } 9650b57cec5SDimitry Andric 966*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9670b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 9680b57cec5SDimitry Andric { 9690b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 9700b57cec5SDimitry Andric } 9710b57cec5SDimitry Andric 972*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9730b57cec5SDimitry Andric int max_length() const _NOEXCEPT 9740b57cec5SDimitry Andric { 9750b57cec5SDimitry Andric return do_max_length(); 9760b57cec5SDimitry Andric } 9770b57cec5SDimitry Andric 9780b57cec5SDimitry Andric static locale::id id; 9790b57cec5SDimitry Andric 9800b57cec5SDimitry Andricprotected: 981*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 9820b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 9830b57cec5SDimitry Andric : locale::facet(__refs) {} 9840b57cec5SDimitry Andric 985bdd1243dSDimitry Andric ~codecvt() override; 9860b57cec5SDimitry Andric 9870b57cec5SDimitry Andric virtual result do_out(state_type& __st, 9880b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 9890b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 9900b57cec5SDimitry Andric virtual result do_in(state_type& __st, 9910b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 9920b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 9930b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 9940b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 9950b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 9960b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 9970b57cec5SDimitry Andric virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 9980b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 9990b57cec5SDimitry Andric}; 10000b57cec5SDimitry Andric 10010b57cec5SDimitry Andric// template <> class codecvt<wchar_t, char, mbstate_t> 10020b57cec5SDimitry Andric 1003349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 10040b57cec5SDimitry Andrictemplate <> 100506c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> 10060b57cec5SDimitry Andric : public locale::facet, 10070b57cec5SDimitry Andric public codecvt_base 10080b57cec5SDimitry Andric{ 1009bdd1243dSDimitry Andric locale_t __l_; 10100b57cec5SDimitry Andricpublic: 10110b57cec5SDimitry Andric typedef wchar_t intern_type; 10120b57cec5SDimitry Andric typedef char extern_type; 10130b57cec5SDimitry Andric typedef mbstate_t state_type; 10140b57cec5SDimitry Andric 10150b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0); 10160b57cec5SDimitry Andric 1017*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10180b57cec5SDimitry Andric result out(state_type& __st, 10190b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 10200b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 10210b57cec5SDimitry Andric { 10220b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 10230b57cec5SDimitry Andric } 10240b57cec5SDimitry Andric 1025*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10260b57cec5SDimitry Andric result unshift(state_type& __st, 10270b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 10280b57cec5SDimitry Andric { 10290b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 10300b57cec5SDimitry Andric } 10310b57cec5SDimitry Andric 1032*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10330b57cec5SDimitry Andric result in(state_type& __st, 10340b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 10350b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 10360b57cec5SDimitry Andric { 10370b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 10380b57cec5SDimitry Andric } 10390b57cec5SDimitry Andric 1040*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10410b57cec5SDimitry Andric int encoding() const _NOEXCEPT 10420b57cec5SDimitry Andric { 10430b57cec5SDimitry Andric return do_encoding(); 10440b57cec5SDimitry Andric } 10450b57cec5SDimitry Andric 1046*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10470b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 10480b57cec5SDimitry Andric { 10490b57cec5SDimitry Andric return do_always_noconv(); 10500b57cec5SDimitry Andric } 10510b57cec5SDimitry Andric 1052*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10530b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 10540b57cec5SDimitry Andric { 10550b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 10560b57cec5SDimitry Andric } 10570b57cec5SDimitry Andric 1058*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10590b57cec5SDimitry Andric int max_length() const _NOEXCEPT 10600b57cec5SDimitry Andric { 10610b57cec5SDimitry Andric return do_max_length(); 10620b57cec5SDimitry Andric } 10630b57cec5SDimitry Andric 10640b57cec5SDimitry Andric static locale::id id; 10650b57cec5SDimitry Andric 10660b57cec5SDimitry Andricprotected: 10670b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0); 10680b57cec5SDimitry Andric 1069bdd1243dSDimitry Andric ~codecvt() override; 10700b57cec5SDimitry Andric 10710b57cec5SDimitry Andric virtual result do_out(state_type& __st, 10720b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 10730b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 10740b57cec5SDimitry Andric virtual result do_in(state_type& __st, 10750b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 10760b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 10770b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 10780b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 10790b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 10800b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 10810b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 10820b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 10830b57cec5SDimitry Andric}; 1084349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 10850b57cec5SDimitry Andric 1086e8d8bef9SDimitry Andric// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20 10870b57cec5SDimitry Andric 10880b57cec5SDimitry Andrictemplate <> 108906c3fb27SDimitry Andricclass _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char, mbstate_t> 10900b57cec5SDimitry Andric : public locale::facet, 10910b57cec5SDimitry Andric public codecvt_base 10920b57cec5SDimitry Andric{ 10930b57cec5SDimitry Andricpublic: 10940b57cec5SDimitry Andric typedef char16_t intern_type; 10950b57cec5SDimitry Andric typedef char extern_type; 10960b57cec5SDimitry Andric typedef mbstate_t state_type; 10970b57cec5SDimitry Andric 1098*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 10990b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0) 11000b57cec5SDimitry Andric : locale::facet(__refs) {} 11010b57cec5SDimitry Andric 1102*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11030b57cec5SDimitry Andric result out(state_type& __st, 11040b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 11050b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 11060b57cec5SDimitry Andric { 11070b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 11080b57cec5SDimitry Andric } 11090b57cec5SDimitry Andric 1110*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11110b57cec5SDimitry Andric result unshift(state_type& __st, 11120b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 11130b57cec5SDimitry Andric { 11140b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 11150b57cec5SDimitry Andric } 11160b57cec5SDimitry Andric 1117*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11180b57cec5SDimitry Andric result in(state_type& __st, 11190b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 11200b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 11210b57cec5SDimitry Andric { 11220b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 11230b57cec5SDimitry Andric } 11240b57cec5SDimitry Andric 1125*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11260b57cec5SDimitry Andric int encoding() const _NOEXCEPT 11270b57cec5SDimitry Andric { 11280b57cec5SDimitry Andric return do_encoding(); 11290b57cec5SDimitry Andric } 11300b57cec5SDimitry Andric 1131*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11320b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 11330b57cec5SDimitry Andric { 11340b57cec5SDimitry Andric return do_always_noconv(); 11350b57cec5SDimitry Andric } 11360b57cec5SDimitry Andric 1137*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11380b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 11390b57cec5SDimitry Andric { 11400b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 11410b57cec5SDimitry Andric } 11420b57cec5SDimitry Andric 1143*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11440b57cec5SDimitry Andric int max_length() const _NOEXCEPT 11450b57cec5SDimitry Andric { 11460b57cec5SDimitry Andric return do_max_length(); 11470b57cec5SDimitry Andric } 11480b57cec5SDimitry Andric 11490b57cec5SDimitry Andric static locale::id id; 11500b57cec5SDimitry Andric 11510b57cec5SDimitry Andricprotected: 1152*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 11530b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 11540b57cec5SDimitry Andric : locale::facet(__refs) {} 11550b57cec5SDimitry Andric 1156bdd1243dSDimitry Andric ~codecvt() override; 11570b57cec5SDimitry Andric 11580b57cec5SDimitry Andric virtual result do_out(state_type& __st, 11590b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 11600b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 11610b57cec5SDimitry Andric virtual result do_in(state_type& __st, 11620b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 11630b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 11640b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 11650b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 11660b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 11670b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 11680b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 11690b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 11700b57cec5SDimitry Andric}; 11710b57cec5SDimitry Andric 1172fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T 1173e8d8bef9SDimitry Andric 1174e8d8bef9SDimitry Andric// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20 11750b57cec5SDimitry Andric 11760b57cec5SDimitry Andrictemplate <> 117706c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char8_t, mbstate_t> 1178e8d8bef9SDimitry Andric : public locale::facet, 1179e8d8bef9SDimitry Andric public codecvt_base 1180e8d8bef9SDimitry Andric{ 1181e8d8bef9SDimitry Andricpublic: 1182e8d8bef9SDimitry Andric typedef char16_t intern_type; 1183e8d8bef9SDimitry Andric typedef char8_t extern_type; 1184e8d8bef9SDimitry Andric typedef mbstate_t state_type; 1185e8d8bef9SDimitry Andric 1186*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1187e8d8bef9SDimitry Andric explicit codecvt(size_t __refs = 0) 1188e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1189e8d8bef9SDimitry Andric 1190*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1191e8d8bef9SDimitry Andric result out(state_type& __st, 1192e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1193e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1194e8d8bef9SDimitry Andric { 1195e8d8bef9SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1196e8d8bef9SDimitry Andric } 1197e8d8bef9SDimitry Andric 1198*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1199e8d8bef9SDimitry Andric result unshift(state_type& __st, 1200e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1201e8d8bef9SDimitry Andric { 1202e8d8bef9SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 1203e8d8bef9SDimitry Andric } 1204e8d8bef9SDimitry Andric 1205*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1206e8d8bef9SDimitry Andric result in(state_type& __st, 1207e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1208e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 1209e8d8bef9SDimitry Andric { 1210e8d8bef9SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1211e8d8bef9SDimitry Andric } 1212e8d8bef9SDimitry Andric 1213*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1214e8d8bef9SDimitry Andric int encoding() const _NOEXCEPT 1215e8d8bef9SDimitry Andric { 1216e8d8bef9SDimitry Andric return do_encoding(); 1217e8d8bef9SDimitry Andric } 1218e8d8bef9SDimitry Andric 1219*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1220e8d8bef9SDimitry Andric bool always_noconv() const _NOEXCEPT 1221e8d8bef9SDimitry Andric { 1222e8d8bef9SDimitry Andric return do_always_noconv(); 1223e8d8bef9SDimitry Andric } 1224e8d8bef9SDimitry Andric 1225*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1226e8d8bef9SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 1227e8d8bef9SDimitry Andric { 1228e8d8bef9SDimitry Andric return do_length(__st, __frm, __end, __mx); 1229e8d8bef9SDimitry Andric } 1230e8d8bef9SDimitry Andric 1231*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1232e8d8bef9SDimitry Andric int max_length() const _NOEXCEPT 1233e8d8bef9SDimitry Andric { 1234e8d8bef9SDimitry Andric return do_max_length(); 1235e8d8bef9SDimitry Andric } 1236e8d8bef9SDimitry Andric 1237e8d8bef9SDimitry Andric static locale::id id; 1238e8d8bef9SDimitry Andric 1239e8d8bef9SDimitry Andricprotected: 1240*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1241e8d8bef9SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 1242e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1243e8d8bef9SDimitry Andric 1244bdd1243dSDimitry Andric ~codecvt() override; 1245e8d8bef9SDimitry Andric 1246e8d8bef9SDimitry Andric virtual result do_out(state_type& __st, 1247e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1248e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1249e8d8bef9SDimitry Andric virtual result do_in(state_type& __st, 1250e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1251e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1252e8d8bef9SDimitry Andric virtual result do_unshift(state_type& __st, 1253e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1254e8d8bef9SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1255e8d8bef9SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1256e8d8bef9SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 1257e8d8bef9SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1258e8d8bef9SDimitry Andric}; 1259e8d8bef9SDimitry Andric 1260e8d8bef9SDimitry Andric#endif 1261e8d8bef9SDimitry Andric 1262e8d8bef9SDimitry Andric// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20 1263e8d8bef9SDimitry Andric 1264e8d8bef9SDimitry Andrictemplate <> 126506c3fb27SDimitry Andricclass _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char, mbstate_t> 12660b57cec5SDimitry Andric : public locale::facet, 12670b57cec5SDimitry Andric public codecvt_base 12680b57cec5SDimitry Andric{ 12690b57cec5SDimitry Andricpublic: 12700b57cec5SDimitry Andric typedef char32_t intern_type; 12710b57cec5SDimitry Andric typedef char extern_type; 12720b57cec5SDimitry Andric typedef mbstate_t state_type; 12730b57cec5SDimitry Andric 1274*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12750b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0) 12760b57cec5SDimitry Andric : locale::facet(__refs) {} 12770b57cec5SDimitry Andric 1278*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12790b57cec5SDimitry Andric result out(state_type& __st, 12800b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 12810b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 12820b57cec5SDimitry Andric { 12830b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 12840b57cec5SDimitry Andric } 12850b57cec5SDimitry Andric 1286*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12870b57cec5SDimitry Andric result unshift(state_type& __st, 12880b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 12890b57cec5SDimitry Andric { 12900b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 12910b57cec5SDimitry Andric } 12920b57cec5SDimitry Andric 1293*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 12940b57cec5SDimitry Andric result in(state_type& __st, 12950b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 12960b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 12970b57cec5SDimitry Andric { 12980b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 12990b57cec5SDimitry Andric } 13000b57cec5SDimitry Andric 1301*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13020b57cec5SDimitry Andric int encoding() const _NOEXCEPT 13030b57cec5SDimitry Andric { 13040b57cec5SDimitry Andric return do_encoding(); 13050b57cec5SDimitry Andric } 13060b57cec5SDimitry Andric 1307*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13080b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 13090b57cec5SDimitry Andric { 13100b57cec5SDimitry Andric return do_always_noconv(); 13110b57cec5SDimitry Andric } 13120b57cec5SDimitry Andric 1313*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13140b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 13150b57cec5SDimitry Andric { 13160b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 13170b57cec5SDimitry Andric } 13180b57cec5SDimitry Andric 1319*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13200b57cec5SDimitry Andric int max_length() const _NOEXCEPT 13210b57cec5SDimitry Andric { 13220b57cec5SDimitry Andric return do_max_length(); 13230b57cec5SDimitry Andric } 13240b57cec5SDimitry Andric 13250b57cec5SDimitry Andric static locale::id id; 13260b57cec5SDimitry Andric 13270b57cec5SDimitry Andricprotected: 1328*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 13290b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 13300b57cec5SDimitry Andric : locale::facet(__refs) {} 13310b57cec5SDimitry Andric 1332bdd1243dSDimitry Andric ~codecvt() override; 13330b57cec5SDimitry Andric 13340b57cec5SDimitry Andric virtual result do_out(state_type& __st, 13350b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 13360b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 13370b57cec5SDimitry Andric virtual result do_in(state_type& __st, 13380b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 13390b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 13400b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 13410b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 13420b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 13430b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 13440b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 13450b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 13460b57cec5SDimitry Andric}; 13470b57cec5SDimitry Andric 1348fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T 1349e8d8bef9SDimitry Andric 1350e8d8bef9SDimitry Andric// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20 1351e8d8bef9SDimitry Andric 1352e8d8bef9SDimitry Andrictemplate <> 135306c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char8_t, mbstate_t> 1354e8d8bef9SDimitry Andric : public locale::facet, 1355e8d8bef9SDimitry Andric public codecvt_base 1356e8d8bef9SDimitry Andric{ 1357e8d8bef9SDimitry Andricpublic: 1358e8d8bef9SDimitry Andric typedef char32_t intern_type; 1359e8d8bef9SDimitry Andric typedef char8_t extern_type; 1360e8d8bef9SDimitry Andric typedef mbstate_t state_type; 1361e8d8bef9SDimitry Andric 1362*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1363e8d8bef9SDimitry Andric explicit codecvt(size_t __refs = 0) 1364e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1365e8d8bef9SDimitry Andric 1366*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1367e8d8bef9SDimitry Andric result out(state_type& __st, 1368e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1369e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1370e8d8bef9SDimitry Andric { 1371e8d8bef9SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1372e8d8bef9SDimitry Andric } 1373e8d8bef9SDimitry Andric 1374*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1375e8d8bef9SDimitry Andric result unshift(state_type& __st, 1376e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1377e8d8bef9SDimitry Andric { 1378e8d8bef9SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 1379e8d8bef9SDimitry Andric } 1380e8d8bef9SDimitry Andric 1381*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1382e8d8bef9SDimitry Andric result in(state_type& __st, 1383e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1384e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 1385e8d8bef9SDimitry Andric { 1386e8d8bef9SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1387e8d8bef9SDimitry Andric } 1388e8d8bef9SDimitry Andric 1389*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1390e8d8bef9SDimitry Andric int encoding() const _NOEXCEPT 1391e8d8bef9SDimitry Andric { 1392e8d8bef9SDimitry Andric return do_encoding(); 1393e8d8bef9SDimitry Andric } 1394e8d8bef9SDimitry Andric 1395*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1396e8d8bef9SDimitry Andric bool always_noconv() const _NOEXCEPT 1397e8d8bef9SDimitry Andric { 1398e8d8bef9SDimitry Andric return do_always_noconv(); 1399e8d8bef9SDimitry Andric } 1400e8d8bef9SDimitry Andric 1401*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1402e8d8bef9SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 1403e8d8bef9SDimitry Andric { 1404e8d8bef9SDimitry Andric return do_length(__st, __frm, __end, __mx); 1405e8d8bef9SDimitry Andric } 1406e8d8bef9SDimitry Andric 1407*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1408e8d8bef9SDimitry Andric int max_length() const _NOEXCEPT 1409e8d8bef9SDimitry Andric { 1410e8d8bef9SDimitry Andric return do_max_length(); 1411e8d8bef9SDimitry Andric } 1412e8d8bef9SDimitry Andric 1413e8d8bef9SDimitry Andric static locale::id id; 1414e8d8bef9SDimitry Andric 1415e8d8bef9SDimitry Andricprotected: 1416*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1417e8d8bef9SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 1418e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1419e8d8bef9SDimitry Andric 1420bdd1243dSDimitry Andric ~codecvt() override; 1421e8d8bef9SDimitry Andric 1422e8d8bef9SDimitry Andric virtual result do_out(state_type& __st, 1423e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1424e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1425e8d8bef9SDimitry Andric virtual result do_in(state_type& __st, 1426e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1427e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1428e8d8bef9SDimitry Andric virtual result do_unshift(state_type& __st, 1429e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1430e8d8bef9SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1431e8d8bef9SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1432e8d8bef9SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 1433e8d8bef9SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1434e8d8bef9SDimitry Andric}; 1435e8d8bef9SDimitry Andric 1436e8d8bef9SDimitry Andric#endif 1437e8d8bef9SDimitry Andric 14380b57cec5SDimitry Andric// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname 14390b57cec5SDimitry Andric 14400b57cec5SDimitry Andrictemplate <class _InternT, class _ExternT, class _StateT> 14410b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_byname 14420b57cec5SDimitry Andric : public codecvt<_InternT, _ExternT, _StateT> 14430b57cec5SDimitry Andric{ 14440b57cec5SDimitry Andricpublic: 1445*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14460b57cec5SDimitry Andric explicit codecvt_byname(const char* __nm, size_t __refs = 0) 14470b57cec5SDimitry Andric : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} 1448*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14490b57cec5SDimitry Andric explicit codecvt_byname(const string& __nm, size_t __refs = 0) 14500b57cec5SDimitry Andric : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {} 14510b57cec5SDimitry Andricprotected: 1452bdd1243dSDimitry Andric ~codecvt_byname() override; 14530b57cec5SDimitry Andric}; 14540b57cec5SDimitry Andric 1455e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 14560b57cec5SDimitry Andrictemplate <class _InternT, class _ExternT, class _StateT> 14570b57cec5SDimitry Andriccodecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() 14580b57cec5SDimitry Andric{ 14590b57cec5SDimitry Andric} 1460e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 14610b57cec5SDimitry Andric 146281ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>; 1463349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 146481ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; 1465349cc55cSDimitry Andric#endif 146681ad6265SDimitry Andricextern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 146781ad6265SDimitry Andricextern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 1468fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T 146981ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 147081ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 1471e8d8bef9SDimitry Andric#endif 14720b57cec5SDimitry Andric 14730b57cec5SDimitry Andrictemplate <size_t _Np> 14740b57cec5SDimitry Andricstruct __narrow_to_utf8 14750b57cec5SDimitry Andric{ 14760b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 14770b57cec5SDimitry Andric _OutputIterator 14780b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const; 14790b57cec5SDimitry Andric}; 14800b57cec5SDimitry Andric 14810b57cec5SDimitry Andrictemplate <> 14820b57cec5SDimitry Andricstruct __narrow_to_utf8<8> 14830b57cec5SDimitry Andric{ 14840b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 1485*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 14860b57cec5SDimitry Andric _OutputIterator 14870b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const 14880b57cec5SDimitry Andric { 14890b57cec5SDimitry Andric for (; __wb < __we; ++__wb, ++__s) 14900b57cec5SDimitry Andric *__s = *__wb; 14910b57cec5SDimitry Andric return __s; 14920b57cec5SDimitry Andric } 14930b57cec5SDimitry Andric}; 14940b57cec5SDimitry Andric 1495e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 14960b57cec5SDimitry Andrictemplate <> 149706c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> 14980b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 14990b57cec5SDimitry Andric{ 1500*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15010b57cec5SDimitry Andric __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {} 1502e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 15030b57cec5SDimitry Andric 1504bdd1243dSDimitry Andric ~__narrow_to_utf8() override; 15050b57cec5SDimitry Andric 15060b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 1507*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15080b57cec5SDimitry Andric _OutputIterator 15090b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const 15100b57cec5SDimitry Andric { 15110b57cec5SDimitry Andric result __r = ok; 15120b57cec5SDimitry Andric mbstate_t __mb; 15130b57cec5SDimitry Andric while (__wb < __we && __r != error) 15140b57cec5SDimitry Andric { 15150b57cec5SDimitry Andric const int __sz = 32; 15160b57cec5SDimitry Andric char __buf[__sz]; 15170b57cec5SDimitry Andric char* __bn; 15180b57cec5SDimitry Andric const char16_t* __wn = (const char16_t*)__wb; 15190b57cec5SDimitry Andric __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, 15200b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 15210b57cec5SDimitry Andric if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) 15220b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 15230b57cec5SDimitry Andric for (const char* __p = __buf; __p < __bn; ++__p, ++__s) 15240b57cec5SDimitry Andric *__s = *__p; 15250b57cec5SDimitry Andric __wb = (const _CharT*)__wn; 15260b57cec5SDimitry Andric } 15270b57cec5SDimitry Andric return __s; 15280b57cec5SDimitry Andric } 15290b57cec5SDimitry Andric}; 15300b57cec5SDimitry Andric 1531e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 15320b57cec5SDimitry Andrictemplate <> 153306c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> 15340b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 15350b57cec5SDimitry Andric{ 1536*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15370b57cec5SDimitry Andric __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {} 1538e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 15390b57cec5SDimitry Andric 1540bdd1243dSDimitry Andric ~__narrow_to_utf8() override; 15410b57cec5SDimitry Andric 15420b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 1543*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15440b57cec5SDimitry Andric _OutputIterator 15450b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const 15460b57cec5SDimitry Andric { 15470b57cec5SDimitry Andric result __r = ok; 15480b57cec5SDimitry Andric mbstate_t __mb; 15490b57cec5SDimitry Andric while (__wb < __we && __r != error) 15500b57cec5SDimitry Andric { 15510b57cec5SDimitry Andric const int __sz = 32; 15520b57cec5SDimitry Andric char __buf[__sz]; 15530b57cec5SDimitry Andric char* __bn; 15540b57cec5SDimitry Andric const char32_t* __wn = (const char32_t*)__wb; 15550b57cec5SDimitry Andric __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, 15560b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 15570b57cec5SDimitry Andric if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) 15580b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 15590b57cec5SDimitry Andric for (const char* __p = __buf; __p < __bn; ++__p, ++__s) 15600b57cec5SDimitry Andric *__s = *__p; 15610b57cec5SDimitry Andric __wb = (const _CharT*)__wn; 15620b57cec5SDimitry Andric } 15630b57cec5SDimitry Andric return __s; 15640b57cec5SDimitry Andric } 15650b57cec5SDimitry Andric}; 15660b57cec5SDimitry Andric 15670b57cec5SDimitry Andrictemplate <size_t _Np> 15680b57cec5SDimitry Andricstruct __widen_from_utf8 15690b57cec5SDimitry Andric{ 15700b57cec5SDimitry Andric template <class _OutputIterator> 15710b57cec5SDimitry Andric _OutputIterator 15720b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const; 15730b57cec5SDimitry Andric}; 15740b57cec5SDimitry Andric 15750b57cec5SDimitry Andrictemplate <> 15760b57cec5SDimitry Andricstruct __widen_from_utf8<8> 15770b57cec5SDimitry Andric{ 15780b57cec5SDimitry Andric template <class _OutputIterator> 1579*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15800b57cec5SDimitry Andric _OutputIterator 15810b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const 15820b57cec5SDimitry Andric { 15830b57cec5SDimitry Andric for (; __nb < __ne; ++__nb, ++__s) 15840b57cec5SDimitry Andric *__s = *__nb; 15850b57cec5SDimitry Andric return __s; 15860b57cec5SDimitry Andric } 15870b57cec5SDimitry Andric}; 15880b57cec5SDimitry Andric 1589e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 15900b57cec5SDimitry Andrictemplate <> 159106c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> 15920b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 15930b57cec5SDimitry Andric{ 1594*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 15950b57cec5SDimitry Andric __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {} 1596e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 15970b57cec5SDimitry Andric 1598bdd1243dSDimitry Andric ~__widen_from_utf8() override; 15990b57cec5SDimitry Andric 16000b57cec5SDimitry Andric template <class _OutputIterator> 1601*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 16020b57cec5SDimitry Andric _OutputIterator 16030b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const 16040b57cec5SDimitry Andric { 16050b57cec5SDimitry Andric result __r = ok; 16060b57cec5SDimitry Andric mbstate_t __mb; 16070b57cec5SDimitry Andric while (__nb < __ne && __r != error) 16080b57cec5SDimitry Andric { 16090b57cec5SDimitry Andric const int __sz = 32; 16100b57cec5SDimitry Andric char16_t __buf[__sz]; 16110b57cec5SDimitry Andric char16_t* __bn; 16120b57cec5SDimitry Andric const char* __nn = __nb; 16130b57cec5SDimitry Andric __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, 16140b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 16150b57cec5SDimitry Andric if (__r == codecvt_base::error || __nn == __nb) 16160b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 16170b57cec5SDimitry Andric for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) 1618e8d8bef9SDimitry Andric *__s = *__p; 16190b57cec5SDimitry Andric __nb = __nn; 16200b57cec5SDimitry Andric } 16210b57cec5SDimitry Andric return __s; 16220b57cec5SDimitry Andric } 16230b57cec5SDimitry Andric}; 16240b57cec5SDimitry Andric 1625e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 16260b57cec5SDimitry Andrictemplate <> 162706c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> 16280b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 16290b57cec5SDimitry Andric{ 1630*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 16310b57cec5SDimitry Andric __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {} 1632e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 16330b57cec5SDimitry Andric 1634bdd1243dSDimitry Andric ~__widen_from_utf8() override; 16350b57cec5SDimitry Andric 16360b57cec5SDimitry Andric template <class _OutputIterator> 1637*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 16380b57cec5SDimitry Andric _OutputIterator 16390b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const 16400b57cec5SDimitry Andric { 16410b57cec5SDimitry Andric result __r = ok; 16420b57cec5SDimitry Andric mbstate_t __mb; 16430b57cec5SDimitry Andric while (__nb < __ne && __r != error) 16440b57cec5SDimitry Andric { 16450b57cec5SDimitry Andric const int __sz = 32; 16460b57cec5SDimitry Andric char32_t __buf[__sz]; 16470b57cec5SDimitry Andric char32_t* __bn; 16480b57cec5SDimitry Andric const char* __nn = __nb; 16490b57cec5SDimitry Andric __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, 16500b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 16510b57cec5SDimitry Andric if (__r == codecvt_base::error || __nn == __nb) 16520b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 16530b57cec5SDimitry Andric for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) 1654e8d8bef9SDimitry Andric *__s = *__p; 16550b57cec5SDimitry Andric __nb = __nn; 16560b57cec5SDimitry Andric } 16570b57cec5SDimitry Andric return __s; 16580b57cec5SDimitry Andric } 16590b57cec5SDimitry Andric}; 16600b57cec5SDimitry Andric 16610b57cec5SDimitry Andric// template <class charT> class numpunct 16620b57cec5SDimitry Andric 16630b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct; 16640b57cec5SDimitry Andric 16650b57cec5SDimitry Andrictemplate <> 166606c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct<char> 16670b57cec5SDimitry Andric : public locale::facet 16680b57cec5SDimitry Andric{ 16690b57cec5SDimitry Andricpublic: 16700b57cec5SDimitry Andric typedef char char_type; 16710b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 16720b57cec5SDimitry Andric 16730b57cec5SDimitry Andric explicit numpunct(size_t __refs = 0); 16740b57cec5SDimitry Andric 1675*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const {return do_decimal_point();} 1676*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const {return do_thousands_sep();} 1677*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI string grouping() const {return do_grouping();} 1678*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI string_type truename() const {return do_truename();} 1679*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI string_type falsename() const {return do_falsename();} 16800b57cec5SDimitry Andric 16810b57cec5SDimitry Andric static locale::id id; 16820b57cec5SDimitry Andric 16830b57cec5SDimitry Andricprotected: 1684bdd1243dSDimitry Andric ~numpunct() override; 16850b57cec5SDimitry Andric virtual char_type do_decimal_point() const; 16860b57cec5SDimitry Andric virtual char_type do_thousands_sep() const; 16870b57cec5SDimitry Andric virtual string do_grouping() const; 16880b57cec5SDimitry Andric virtual string_type do_truename() const; 16890b57cec5SDimitry Andric virtual string_type do_falsename() const; 16900b57cec5SDimitry Andric 16910b57cec5SDimitry Andric char_type __decimal_point_; 16920b57cec5SDimitry Andric char_type __thousands_sep_; 16930b57cec5SDimitry Andric string __grouping_; 16940b57cec5SDimitry Andric}; 16950b57cec5SDimitry Andric 1696349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 16970b57cec5SDimitry Andrictemplate <> 169806c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> 16990b57cec5SDimitry Andric : public locale::facet 17000b57cec5SDimitry Andric{ 17010b57cec5SDimitry Andricpublic: 17020b57cec5SDimitry Andric typedef wchar_t char_type; 17030b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 17040b57cec5SDimitry Andric 17050b57cec5SDimitry Andric explicit numpunct(size_t __refs = 0); 17060b57cec5SDimitry Andric 1707*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const {return do_decimal_point();} 1708*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const {return do_thousands_sep();} 1709*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI string grouping() const {return do_grouping();} 1710*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI string_type truename() const {return do_truename();} 1711*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI string_type falsename() const {return do_falsename();} 17120b57cec5SDimitry Andric 17130b57cec5SDimitry Andric static locale::id id; 17140b57cec5SDimitry Andric 17150b57cec5SDimitry Andricprotected: 1716bdd1243dSDimitry Andric ~numpunct() override; 17170b57cec5SDimitry Andric virtual char_type do_decimal_point() const; 17180b57cec5SDimitry Andric virtual char_type do_thousands_sep() const; 17190b57cec5SDimitry Andric virtual string do_grouping() const; 17200b57cec5SDimitry Andric virtual string_type do_truename() const; 17210b57cec5SDimitry Andric virtual string_type do_falsename() const; 17220b57cec5SDimitry Andric 17230b57cec5SDimitry Andric char_type __decimal_point_; 17240b57cec5SDimitry Andric char_type __thousands_sep_; 17250b57cec5SDimitry Andric string __grouping_; 17260b57cec5SDimitry Andric}; 1727349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 17280b57cec5SDimitry Andric 17290b57cec5SDimitry Andric// template <class charT> class numpunct_byname 17300b57cec5SDimitry Andric 17310b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname; 17320b57cec5SDimitry Andric 17330b57cec5SDimitry Andrictemplate <> 173406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> 17350b57cec5SDimitry Andric: public numpunct<char> 17360b57cec5SDimitry Andric{ 17370b57cec5SDimitry Andricpublic: 17380b57cec5SDimitry Andric typedef char char_type; 17390b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 17400b57cec5SDimitry Andric 17410b57cec5SDimitry Andric explicit numpunct_byname(const char* __nm, size_t __refs = 0); 17420b57cec5SDimitry Andric explicit numpunct_byname(const string& __nm, size_t __refs = 0); 17430b57cec5SDimitry Andric 17440b57cec5SDimitry Andricprotected: 1745bdd1243dSDimitry Andric ~numpunct_byname() override; 17460b57cec5SDimitry Andric 17470b57cec5SDimitry Andricprivate: 17480b57cec5SDimitry Andric void __init(const char*); 17490b57cec5SDimitry Andric}; 17500b57cec5SDimitry Andric 1751349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 17520b57cec5SDimitry Andrictemplate <> 175306c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> 17540b57cec5SDimitry Andric: public numpunct<wchar_t> 17550b57cec5SDimitry Andric{ 17560b57cec5SDimitry Andricpublic: 17570b57cec5SDimitry Andric typedef wchar_t char_type; 17580b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 17590b57cec5SDimitry Andric 17600b57cec5SDimitry Andric explicit numpunct_byname(const char* __nm, size_t __refs = 0); 17610b57cec5SDimitry Andric explicit numpunct_byname(const string& __nm, size_t __refs = 0); 17620b57cec5SDimitry Andric 17630b57cec5SDimitry Andricprotected: 1764bdd1243dSDimitry Andric ~numpunct_byname() override; 17650b57cec5SDimitry Andric 17660b57cec5SDimitry Andricprivate: 17670b57cec5SDimitry Andric void __init(const char*); 17680b57cec5SDimitry Andric}; 1769349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 17700b57cec5SDimitry Andric 17710b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 17720b57cec5SDimitry Andric 17730b57cec5SDimitry Andric#endif // _LIBCPP___LOCALE 1774