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> 15*06c3fb27SDimitry Andric#include <__memory/shared_ptr.h> // __shared_count 16*06c3fb27SDimitry Andric#include <__type_traits/make_unsigned.h> 170b57cec5SDimitry Andric#include <cctype> 18*06c3fb27SDimitry Andric#include <clocale> 1904eeddc0SDimitry Andric#include <cstdint> 20*06c3fb27SDimitry Andric#include <cstdlib> 2104eeddc0SDimitry Andric#include <mutex> 2204eeddc0SDimitry Andric#include <string> 2304eeddc0SDimitry Andric 24bdd1243dSDimitry Andric// Some platforms require more includes than others. Keep the includes on all plaforms for now. 25bdd1243dSDimitry Andric#include <cstddef> 26bdd1243dSDimitry Andric#include <cstring> 27bdd1243dSDimitry Andric 28*06c3fb27SDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 29*06c3fb27SDimitry Andric# include <cwchar> 30*06c3fb27SDimitry Andric#else 31*06c3fb27SDimitry Andric# include <__std_mbstate_t.h> 32*06c3fb27SDimitry Andric#endif 33*06c3fb27SDimitry Andric 340b57cec5SDimitry Andric#if defined(_LIBCPP_MSVCRT_LIKE) 35d409305fSDimitry Andric# include <__support/win32/locale_win32.h> 36e8d8bef9SDimitry Andric#elif defined(_AIX) || defined(__MVS__) 37d409305fSDimitry Andric# include <__support/ibm/xlocale.h> 380b57cec5SDimitry Andric#elif defined(__ANDROID__) 39d409305fSDimitry Andric# include <__support/android/locale_bionic.h> 400b57cec5SDimitry Andric#elif defined(_NEWLIB_VERSION) 41d409305fSDimitry Andric# include <__support/newlib/xlocale.h> 42e8d8bef9SDimitry Andric#elif defined(__OpenBSD__) 43d409305fSDimitry Andric# include <__support/openbsd/xlocale.h> 44fcaf7f86SDimitry Andric#elif (defined(__APPLE__) || defined(__FreeBSD__)) 450b57cec5SDimitry Andric# include <xlocale.h> 460b57cec5SDimitry Andric#elif defined(__Fuchsia__) 47d409305fSDimitry Andric# include <__support/fuchsia/xlocale.h> 480b57cec5SDimitry Andric#elif defined(__wasi__) 490b57cec5SDimitry Andric// WASI libc uses musl's locales support. 50d409305fSDimitry Andric# include <__support/musl/xlocale.h> 510b57cec5SDimitry Andric#elif defined(_LIBCPP_HAS_MUSL_LIBC) 52d409305fSDimitry Andric# include <__support/musl/xlocale.h> 530b57cec5SDimitry Andric#endif 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 560b57cec5SDimitry Andric# pragma GCC system_header 570b57cec5SDimitry Andric#endif 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 600b57cec5SDimitry Andric 61*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andrictemplate <class _Facet> 640b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 650b57cec5SDimitry Andricbool 660b57cec5SDimitry Andrichas_facet(const locale&) _NOEXCEPT; 670b57cec5SDimitry Andric 680b57cec5SDimitry Andrictemplate <class _Facet> 690b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 700b57cec5SDimitry Andricconst _Facet& 710b57cec5SDimitry Andricuse_facet(const locale&); 720b57cec5SDimitry Andric 73*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale 740b57cec5SDimitry Andric{ 750b57cec5SDimitry Andricpublic: 760b57cec5SDimitry Andric // types: 77*06c3fb27SDimitry Andric class _LIBCPP_EXPORTED_FROM_ABI facet; 78*06c3fb27SDimitry Andric class _LIBCPP_EXPORTED_FROM_ABI id; 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric typedef int category; 810b57cec5SDimitry Andric _LIBCPP_AVAILABILITY_LOCALE_CATEGORY 820b57cec5SDimitry Andric static const category // values assigned here are for exposition only 830b57cec5SDimitry Andric none = 0, 840b57cec5SDimitry Andric collate = LC_COLLATE_MASK, 850b57cec5SDimitry Andric ctype = LC_CTYPE_MASK, 860b57cec5SDimitry Andric monetary = LC_MONETARY_MASK, 870b57cec5SDimitry Andric numeric = LC_NUMERIC_MASK, 880b57cec5SDimitry Andric time = LC_TIME_MASK, 890b57cec5SDimitry Andric messages = LC_MESSAGES_MASK, 900b57cec5SDimitry Andric all = collate | ctype | monetary | numeric | time | messages; 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric // construct/copy/destroy: 930b57cec5SDimitry Andric locale() _NOEXCEPT; 940b57cec5SDimitry Andric locale(const locale&) _NOEXCEPT; 950b57cec5SDimitry Andric explicit locale(const char*); 960b57cec5SDimitry Andric explicit locale(const string&); 970b57cec5SDimitry Andric locale(const locale&, const char*, category); 980b57cec5SDimitry Andric locale(const locale&, const string&, category); 990b57cec5SDimitry Andric template <class _Facet> 1000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*); 1010b57cec5SDimitry Andric locale(const locale&, const locale&, category); 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric ~locale(); 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric const locale& operator=(const locale&) _NOEXCEPT; 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric template <class _Facet> 1080b57cec5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1090b57cec5SDimitry Andric locale combine(const locale&) const; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric // locale operations: 1120b57cec5SDimitry Andric string name() const; 1130b57cec5SDimitry Andric bool operator==(const locale&) const; 114*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 115*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const {return !(*this == __y);} 116*06c3fb27SDimitry Andric#endif 1170b57cec5SDimitry Andric template <class _CharT, class _Traits, class _Allocator> 1180b57cec5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1190b57cec5SDimitry Andric bool operator()(const basic_string<_CharT, _Traits, _Allocator>&, 1200b57cec5SDimitry Andric const basic_string<_CharT, _Traits, _Allocator>&) const; 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric // global locale objects: 1230b57cec5SDimitry Andric static locale global(const locale&); 1240b57cec5SDimitry Andric static const locale& classic(); 1250b57cec5SDimitry Andric 1260b57cec5SDimitry Andricprivate: 1270b57cec5SDimitry Andric class __imp; 1280b57cec5SDimitry Andric __imp* __locale_; 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andric void __install_ctor(const locale&, facet*, long); 1310b57cec5SDimitry Andric static locale& __global(); 1320b57cec5SDimitry Andric bool has_facet(id&) const; 1330b57cec5SDimitry Andric const facet* use_facet(id&) const; 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric template <class _Facet> friend bool has_facet(const locale&) _NOEXCEPT; 1360b57cec5SDimitry Andric template <class _Facet> friend const _Facet& use_facet(const locale&); 1370b57cec5SDimitry Andric}; 1380b57cec5SDimitry Andric 139*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale::facet 1400b57cec5SDimitry Andric : public __shared_count 1410b57cec5SDimitry Andric{ 1420b57cec5SDimitry Andricprotected: 1430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1440b57cec5SDimitry Andric explicit facet(size_t __refs = 0) 1450b57cec5SDimitry Andric : __shared_count(static_cast<long>(__refs)-1) {} 1460b57cec5SDimitry Andric 147bdd1243dSDimitry Andric ~facet() override; 1480b57cec5SDimitry Andric 1490b57cec5SDimitry Andric// facet(const facet&) = delete; // effectively done in __shared_count 1500b57cec5SDimitry Andric// void operator=(const facet&) = delete; 1510b57cec5SDimitry Andricprivate: 152bdd1243dSDimitry Andric void __on_zero_shared() _NOEXCEPT override; 1530b57cec5SDimitry Andric}; 1540b57cec5SDimitry Andric 155*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI locale::id 1560b57cec5SDimitry Andric{ 1570b57cec5SDimitry Andric once_flag __flag_; 1580b57cec5SDimitry Andric int32_t __id_; 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric static int32_t __next_id; 1610b57cec5SDimitry Andricpublic: 1620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} 1630eae32dcSDimitry Andric void operator=(const id&) = delete; 1640eae32dcSDimitry Andric id(const id&) = delete; 1650eae32dcSDimitry Andric 1660b57cec5SDimitry Andricprivate: 1670b57cec5SDimitry Andric void __init(); 1680b57cec5SDimitry Andricpublic: // only needed for tests 1690b57cec5SDimitry Andric long __get(); 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric friend class locale; 1720b57cec5SDimitry Andric friend class locale::__imp; 1730b57cec5SDimitry Andric}; 1740b57cec5SDimitry Andric 1750b57cec5SDimitry Andrictemplate <class _Facet> 1760b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1770b57cec5SDimitry Andriclocale::locale(const locale& __other, _Facet* __f) 1780b57cec5SDimitry Andric{ 1790b57cec5SDimitry Andric __install_ctor(__other, __f, __f ? __f->id.__get() : 0); 1800b57cec5SDimitry Andric} 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andrictemplate <class _Facet> 1830b57cec5SDimitry Andriclocale 1840b57cec5SDimitry Andriclocale::combine(const locale& __other) const 1850b57cec5SDimitry Andric{ 1860b57cec5SDimitry Andric if (!_VSTD::has_facet<_Facet>(__other)) 1870b57cec5SDimitry Andric __throw_runtime_error("locale::combine: locale missing facet"); 1880b57cec5SDimitry Andric 1890b57cec5SDimitry Andric return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other))); 1900b57cec5SDimitry Andric} 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andrictemplate <class _Facet> 1930b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 1940b57cec5SDimitry Andricbool 1950b57cec5SDimitry Andrichas_facet(const locale& __l) _NOEXCEPT 1960b57cec5SDimitry Andric{ 1970b57cec5SDimitry Andric return __l.has_facet(_Facet::id); 1980b57cec5SDimitry Andric} 1990b57cec5SDimitry Andric 2000b57cec5SDimitry Andrictemplate <class _Facet> 2010b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 2020b57cec5SDimitry Andricconst _Facet& 2030b57cec5SDimitry Andricuse_facet(const locale& __l) 2040b57cec5SDimitry Andric{ 2050b57cec5SDimitry Andric return static_cast<const _Facet&>(*__l.use_facet(_Facet::id)); 2060b57cec5SDimitry Andric} 2070b57cec5SDimitry Andric 2080b57cec5SDimitry Andric// template <class _CharT> class collate; 2090b57cec5SDimitry Andric 2100b57cec5SDimitry Andrictemplate <class _CharT> 2110b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS collate 2120b57cec5SDimitry Andric : public locale::facet 2130b57cec5SDimitry Andric{ 2140b57cec5SDimitry Andricpublic: 2150b57cec5SDimitry Andric typedef _CharT char_type; 2160b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 2170b57cec5SDimitry Andric 2180b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2190b57cec5SDimitry Andric explicit collate(size_t __refs = 0) 2200b57cec5SDimitry Andric : locale::facet(__refs) {} 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2230b57cec5SDimitry Andric int compare(const char_type* __lo1, const char_type* __hi1, 2240b57cec5SDimitry Andric const char_type* __lo2, const char_type* __hi2) const 2250b57cec5SDimitry Andric { 2260b57cec5SDimitry Andric return do_compare(__lo1, __hi1, __lo2, __hi2); 2270b57cec5SDimitry Andric } 2280b57cec5SDimitry Andric 2290b57cec5SDimitry Andric // FIXME(EricWF): The _LIBCPP_ALWAYS_INLINE is needed on Windows to work 2300b57cec5SDimitry Andric // around a dllimport bug that expects an external instantiation. 2310b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2320b57cec5SDimitry Andric _LIBCPP_ALWAYS_INLINE 2330b57cec5SDimitry Andric string_type transform(const char_type* __lo, const char_type* __hi) const 2340b57cec5SDimitry Andric { 2350b57cec5SDimitry Andric return do_transform(__lo, __hi); 2360b57cec5SDimitry Andric } 2370b57cec5SDimitry Andric 2380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2390b57cec5SDimitry Andric long hash(const char_type* __lo, const char_type* __hi) const 2400b57cec5SDimitry Andric { 2410b57cec5SDimitry Andric return do_hash(__lo, __hi); 2420b57cec5SDimitry Andric } 2430b57cec5SDimitry Andric 2440b57cec5SDimitry Andric static locale::id id; 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andricprotected: 247bdd1243dSDimitry Andric ~collate() override; 2480b57cec5SDimitry Andric virtual int do_compare(const char_type* __lo1, const char_type* __hi1, 2490b57cec5SDimitry Andric const char_type* __lo2, const char_type* __hi2) const; 2500b57cec5SDimitry Andric virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const 2510b57cec5SDimitry Andric {return string_type(__lo, __hi);} 2520b57cec5SDimitry Andric virtual long do_hash(const char_type* __lo, const char_type* __hi) const; 2530b57cec5SDimitry Andric}; 2540b57cec5SDimitry Andric 2550b57cec5SDimitry Andrictemplate <class _CharT> locale::id collate<_CharT>::id; 2560b57cec5SDimitry Andric 2570b57cec5SDimitry Andrictemplate <class _CharT> 2580b57cec5SDimitry Andriccollate<_CharT>::~collate() 2590b57cec5SDimitry Andric{ 2600b57cec5SDimitry Andric} 2610b57cec5SDimitry Andric 2620b57cec5SDimitry Andrictemplate <class _CharT> 2630b57cec5SDimitry Andricint 2640b57cec5SDimitry Andriccollate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1, 2650b57cec5SDimitry Andric const char_type* __lo2, const char_type* __hi2) const 2660b57cec5SDimitry Andric{ 2670b57cec5SDimitry Andric for (; __lo2 != __hi2; ++__lo1, ++__lo2) 2680b57cec5SDimitry Andric { 2690b57cec5SDimitry Andric if (__lo1 == __hi1 || *__lo1 < *__lo2) 2700b57cec5SDimitry Andric return -1; 2710b57cec5SDimitry Andric if (*__lo2 < *__lo1) 2720b57cec5SDimitry Andric return 1; 2730b57cec5SDimitry Andric } 2740b57cec5SDimitry Andric return __lo1 != __hi1; 2750b57cec5SDimitry Andric} 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andrictemplate <class _CharT> 2780b57cec5SDimitry Andriclong 2790b57cec5SDimitry Andriccollate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const 2800b57cec5SDimitry Andric{ 2810b57cec5SDimitry Andric size_t __h = 0; 2820b57cec5SDimitry Andric const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8; 2830b57cec5SDimitry Andric const size_t __mask = size_t(0xF) << (__sr + 4); 2840b57cec5SDimitry Andric for(const char_type* __p = __lo; __p != __hi; ++__p) 2850b57cec5SDimitry Andric { 2860b57cec5SDimitry Andric __h = (__h << 4) + static_cast<size_t>(*__p); 2870b57cec5SDimitry Andric size_t __g = __h & __mask; 2880b57cec5SDimitry Andric __h ^= __g | (__g >> __sr); 2890b57cec5SDimitry Andric } 2900b57cec5SDimitry Andric return static_cast<long>(__h); 2910b57cec5SDimitry Andric} 2920b57cec5SDimitry Andric 29381ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>; 294349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 29581ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>; 296349cc55cSDimitry Andric#endif 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric// template <class CharT> class collate_byname; 2990b57cec5SDimitry Andric 3000b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname; 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andrictemplate <> 303*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> 3040b57cec5SDimitry Andric : public collate<char> 3050b57cec5SDimitry Andric{ 306bdd1243dSDimitry Andric locale_t __l_; 3070b57cec5SDimitry Andricpublic: 3080b57cec5SDimitry Andric typedef char char_type; 3090b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andric explicit collate_byname(const char* __n, size_t __refs = 0); 3120b57cec5SDimitry Andric explicit collate_byname(const string& __n, size_t __refs = 0); 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andricprotected: 315bdd1243dSDimitry Andric ~collate_byname() override; 316bdd1243dSDimitry Andric int do_compare(const char_type* __lo1, const char_type* __hi1, 317bdd1243dSDimitry Andric const char_type* __lo2, const char_type* __hi2) const override; 318bdd1243dSDimitry Andric string_type do_transform(const char_type* __lo, const char_type* __hi) const override; 3190b57cec5SDimitry Andric}; 3200b57cec5SDimitry Andric 321349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 3220b57cec5SDimitry Andrictemplate <> 323*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> 3240b57cec5SDimitry Andric : public collate<wchar_t> 3250b57cec5SDimitry Andric{ 326bdd1243dSDimitry Andric locale_t __l_; 3270b57cec5SDimitry Andricpublic: 3280b57cec5SDimitry Andric typedef wchar_t char_type; 3290b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 3300b57cec5SDimitry Andric 3310b57cec5SDimitry Andric explicit collate_byname(const char* __n, size_t __refs = 0); 3320b57cec5SDimitry Andric explicit collate_byname(const string& __n, size_t __refs = 0); 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andricprotected: 335bdd1243dSDimitry Andric ~collate_byname() override; 3360b57cec5SDimitry Andric 337bdd1243dSDimitry Andric int do_compare(const char_type* __lo1, const char_type* __hi1, 338bdd1243dSDimitry Andric const char_type* __lo2, const char_type* __hi2) const override; 339bdd1243dSDimitry Andric string_type do_transform(const char_type* __lo, const char_type* __hi) const override; 3400b57cec5SDimitry Andric}; 341349cc55cSDimitry Andric#endif 3420b57cec5SDimitry Andric 3430b57cec5SDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3440b57cec5SDimitry Andricbool 3450b57cec5SDimitry Andriclocale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, 3460b57cec5SDimitry Andric const basic_string<_CharT, _Traits, _Allocator>& __y) const 3470b57cec5SDimitry Andric{ 3480b57cec5SDimitry Andric return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare( 3490b57cec5SDimitry Andric __x.data(), __x.data() + __x.size(), 3500b57cec5SDimitry Andric __y.data(), __y.data() + __y.size()) < 0; 3510b57cec5SDimitry Andric} 3520b57cec5SDimitry Andric 3530b57cec5SDimitry Andric// template <class charT> class ctype 3540b57cec5SDimitry Andric 355*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype_base 3560b57cec5SDimitry Andric{ 3570b57cec5SDimitry Andricpublic: 358e8d8bef9SDimitry Andric#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE) 359e8d8bef9SDimitry Andric typedef unsigned long mask; 360e8d8bef9SDimitry Andric static const mask space = 1<<0; 361e8d8bef9SDimitry Andric static const mask print = 1<<1; 362e8d8bef9SDimitry Andric static const mask cntrl = 1<<2; 363e8d8bef9SDimitry Andric static const mask upper = 1<<3; 364e8d8bef9SDimitry Andric static const mask lower = 1<<4; 365e8d8bef9SDimitry Andric static const mask alpha = 1<<5; 366e8d8bef9SDimitry Andric static const mask digit = 1<<6; 367e8d8bef9SDimitry Andric static const mask punct = 1<<7; 368e8d8bef9SDimitry Andric static const mask xdigit = 1<<8; 369e8d8bef9SDimitry Andric static const mask blank = 1<<9; 370e8d8bef9SDimitry Andric#if defined(__BIONIC__) 371e8d8bef9SDimitry Andric // Historically this was a part of regex_traits rather than ctype_base. The 372e8d8bef9SDimitry Andric // historical value of the constant is preserved for ABI compatibility. 373e8d8bef9SDimitry Andric static const mask __regex_word = 0x8000; 374e8d8bef9SDimitry Andric#else 375e8d8bef9SDimitry Andric static const mask __regex_word = 1<<10; 376e8d8bef9SDimitry Andric#endif // defined(__BIONIC__) 377e8d8bef9SDimitry Andric#elif defined(__GLIBC__) 3780b57cec5SDimitry Andric typedef unsigned short mask; 3790b57cec5SDimitry Andric static const mask space = _ISspace; 3800b57cec5SDimitry Andric static const mask print = _ISprint; 3810b57cec5SDimitry Andric static const mask cntrl = _IScntrl; 3820b57cec5SDimitry Andric static const mask upper = _ISupper; 3830b57cec5SDimitry Andric static const mask lower = _ISlower; 3840b57cec5SDimitry Andric static const mask alpha = _ISalpha; 3850b57cec5SDimitry Andric static const mask digit = _ISdigit; 3860b57cec5SDimitry Andric static const mask punct = _ISpunct; 3870b57cec5SDimitry Andric static const mask xdigit = _ISxdigit; 3880b57cec5SDimitry Andric static const mask blank = _ISblank; 3890b57cec5SDimitry Andric#if defined(__mips__) 3900b57cec5SDimitry Andric static const mask __regex_word = static_cast<mask>(_ISbit(15)); 3910b57cec5SDimitry Andric#else 3920b57cec5SDimitry Andric static const mask __regex_word = 0x80; 3930b57cec5SDimitry Andric#endif 3940b57cec5SDimitry Andric#elif defined(_LIBCPP_MSVCRT_LIKE) 3950b57cec5SDimitry Andric typedef unsigned short mask; 3960b57cec5SDimitry Andric static const mask space = _SPACE; 3970b57cec5SDimitry Andric static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; 3980b57cec5SDimitry Andric static const mask cntrl = _CONTROL; 3990b57cec5SDimitry Andric static const mask upper = _UPPER; 4000b57cec5SDimitry Andric static const mask lower = _LOWER; 4010b57cec5SDimitry Andric static const mask alpha = _ALPHA; 4020b57cec5SDimitry Andric static const mask digit = _DIGIT; 4030b57cec5SDimitry Andric static const mask punct = _PUNCT; 4040b57cec5SDimitry Andric static const mask xdigit = _HEX; 4050b57cec5SDimitry Andric static const mask blank = _BLANK; 4061fd87a68SDimitry Andric static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used 4070b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT 40881ad6265SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA 4090b57cec5SDimitry Andric#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) 4100b57cec5SDimitry Andric# ifdef __APPLE__ 4110b57cec5SDimitry Andric typedef __uint32_t mask; 4120b57cec5SDimitry Andric# elif defined(__FreeBSD__) 4130b57cec5SDimitry Andric typedef unsigned long mask; 4140b57cec5SDimitry Andric# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) 4150b57cec5SDimitry Andric typedef unsigned short mask; 4160b57cec5SDimitry Andric# endif 4170b57cec5SDimitry Andric static const mask space = _CTYPE_S; 4180b57cec5SDimitry Andric static const mask print = _CTYPE_R; 4190b57cec5SDimitry Andric static const mask cntrl = _CTYPE_C; 4200b57cec5SDimitry Andric static const mask upper = _CTYPE_U; 4210b57cec5SDimitry Andric static const mask lower = _CTYPE_L; 4220b57cec5SDimitry Andric static const mask alpha = _CTYPE_A; 4230b57cec5SDimitry Andric static const mask digit = _CTYPE_D; 4240b57cec5SDimitry Andric static const mask punct = _CTYPE_P; 4250b57cec5SDimitry Andric static const mask xdigit = _CTYPE_X; 4260b57cec5SDimitry Andric 4270b57cec5SDimitry Andric# if defined(__NetBSD__) 4280b57cec5SDimitry Andric static const mask blank = _CTYPE_BL; 4290b57cec5SDimitry Andric // NetBSD defines classes up to 0x2000 4300b57cec5SDimitry Andric // see sys/ctype_bits.h, _CTYPE_Q 4310b57cec5SDimitry Andric static const mask __regex_word = 0x8000; 4320b57cec5SDimitry Andric# else 4330b57cec5SDimitry Andric static const mask blank = _CTYPE_B; 4340b57cec5SDimitry Andric static const mask __regex_word = 0x80; 4350b57cec5SDimitry Andric# endif 436*06c3fb27SDimitry Andric#elif defined(_AIX) 4370b57cec5SDimitry Andric typedef unsigned int mask; 4380b57cec5SDimitry Andric static const mask space = _ISSPACE; 4390b57cec5SDimitry Andric static const mask print = _ISPRINT; 4400b57cec5SDimitry Andric static const mask cntrl = _ISCNTRL; 4410b57cec5SDimitry Andric static const mask upper = _ISUPPER; 4420b57cec5SDimitry Andric static const mask lower = _ISLOWER; 4430b57cec5SDimitry Andric static const mask alpha = _ISALPHA; 4440b57cec5SDimitry Andric static const mask digit = _ISDIGIT; 4450b57cec5SDimitry Andric static const mask punct = _ISPUNCT; 4460b57cec5SDimitry Andric static const mask xdigit = _ISXDIGIT; 4470b57cec5SDimitry Andric static const mask blank = _ISBLANK; 448fcaf7f86SDimitry Andric static const mask __regex_word = 0x8000; 4490b57cec5SDimitry Andric#elif defined(_NEWLIB_VERSION) 4500b57cec5SDimitry Andric // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. 4510b57cec5SDimitry Andric typedef char mask; 4520b57cec5SDimitry Andric static const mask space = _S; 4530b57cec5SDimitry Andric static const mask print = _P | _U | _L | _N | _B; 4540b57cec5SDimitry Andric static const mask cntrl = _C; 4550b57cec5SDimitry Andric static const mask upper = _U; 4560b57cec5SDimitry Andric static const mask lower = _L; 4570b57cec5SDimitry Andric static const mask alpha = _U | _L; 4580b57cec5SDimitry Andric static const mask digit = _N; 4590b57cec5SDimitry Andric static const mask punct = _P; 4600b57cec5SDimitry Andric static const mask xdigit = _X | _N; 4610b57cec5SDimitry Andric static const mask blank = _B; 462bdd1243dSDimitry Andric // mask is already fully saturated, use a different type in regex_type_traits. 463bdd1243dSDimitry Andric static const unsigned short __regex_word = 0x100; 4640b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT 4650b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA 4660b57cec5SDimitry Andric# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT 46704eeddc0SDimitry Andric#elif defined(__MVS__) 46804eeddc0SDimitry Andric# if defined(__NATIVE_ASCII_F) 46904eeddc0SDimitry Andric typedef unsigned int mask; 47004eeddc0SDimitry Andric static const mask space = _ISSPACE_A; 47104eeddc0SDimitry Andric static const mask print = _ISPRINT_A; 47204eeddc0SDimitry Andric static const mask cntrl = _ISCNTRL_A; 47304eeddc0SDimitry Andric static const mask upper = _ISUPPER_A; 47404eeddc0SDimitry Andric static const mask lower = _ISLOWER_A; 47504eeddc0SDimitry Andric static const mask alpha = _ISALPHA_A; 47604eeddc0SDimitry Andric static const mask digit = _ISDIGIT_A; 47704eeddc0SDimitry Andric static const mask punct = _ISPUNCT_A; 47804eeddc0SDimitry Andric static const mask xdigit = _ISXDIGIT_A; 47904eeddc0SDimitry Andric static const mask blank = _ISBLANK_A; 48004eeddc0SDimitry Andric# else 48104eeddc0SDimitry Andric typedef unsigned short mask; 48204eeddc0SDimitry Andric static const mask space = __ISSPACE; 48304eeddc0SDimitry Andric static const mask print = __ISPRINT; 48404eeddc0SDimitry Andric static const mask cntrl = __ISCNTRL; 48504eeddc0SDimitry Andric static const mask upper = __ISUPPER; 48604eeddc0SDimitry Andric static const mask lower = __ISLOWER; 48704eeddc0SDimitry Andric static const mask alpha = __ISALPHA; 48804eeddc0SDimitry Andric static const mask digit = __ISDIGIT; 48904eeddc0SDimitry Andric static const mask punct = __ISPUNCT; 49004eeddc0SDimitry Andric static const mask xdigit = __ISXDIGIT; 49104eeddc0SDimitry Andric static const mask blank = __ISBLANK; 49204eeddc0SDimitry Andric# endif 49304eeddc0SDimitry Andric static const mask __regex_word = 0x8000; 4940b57cec5SDimitry Andric#else 495e8d8bef9SDimitry Andric# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? 4960b57cec5SDimitry Andric#endif 4970b57cec5SDimitry Andric static const mask alnum = alpha | digit; 4980b57cec5SDimitry Andric static const mask graph = alnum | punct; 4990b57cec5SDimitry Andric 5000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY ctype_base() {} 5011fd87a68SDimitry Andric 502bdd1243dSDimitry Andric static_assert((__regex_word & ~(std::make_unsigned<mask>::type)(space | print | cntrl | upper | lower | alpha | 503bdd1243dSDimitry Andric digit | punct | xdigit | blank)) == __regex_word, 5041fd87a68SDimitry Andric "__regex_word can't overlap other bits"); 5050b57cec5SDimitry Andric}; 5060b57cec5SDimitry Andric 5070b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype; 5080b57cec5SDimitry Andric 509349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 5100b57cec5SDimitry Andrictemplate <> 511*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> 5120b57cec5SDimitry Andric : public locale::facet, 5130b57cec5SDimitry Andric public ctype_base 5140b57cec5SDimitry Andric{ 5150b57cec5SDimitry Andricpublic: 5160b57cec5SDimitry Andric typedef wchar_t char_type; 5170b57cec5SDimitry Andric 5180b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5190b57cec5SDimitry Andric explicit ctype(size_t __refs = 0) 5200b57cec5SDimitry Andric : locale::facet(__refs) {} 5210b57cec5SDimitry Andric 5220b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5230b57cec5SDimitry Andric bool is(mask __m, char_type __c) const 5240b57cec5SDimitry Andric { 5250b57cec5SDimitry Andric return do_is(__m, __c); 5260b57cec5SDimitry Andric } 5270b57cec5SDimitry Andric 5280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5290b57cec5SDimitry Andric const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const 5300b57cec5SDimitry Andric { 5310b57cec5SDimitry Andric return do_is(__low, __high, __vec); 5320b57cec5SDimitry Andric } 5330b57cec5SDimitry Andric 5340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5350b57cec5SDimitry Andric const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const 5360b57cec5SDimitry Andric { 5370b57cec5SDimitry Andric return do_scan_is(__m, __low, __high); 5380b57cec5SDimitry Andric } 5390b57cec5SDimitry Andric 5400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5410b57cec5SDimitry Andric const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const 5420b57cec5SDimitry Andric { 5430b57cec5SDimitry Andric return do_scan_not(__m, __low, __high); 5440b57cec5SDimitry Andric } 5450b57cec5SDimitry Andric 5460b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5470b57cec5SDimitry Andric char_type toupper(char_type __c) const 5480b57cec5SDimitry Andric { 5490b57cec5SDimitry Andric return do_toupper(__c); 5500b57cec5SDimitry Andric } 5510b57cec5SDimitry Andric 5520b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5530b57cec5SDimitry Andric const char_type* toupper(char_type* __low, const char_type* __high) const 5540b57cec5SDimitry Andric { 5550b57cec5SDimitry Andric return do_toupper(__low, __high); 5560b57cec5SDimitry Andric } 5570b57cec5SDimitry Andric 5580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5590b57cec5SDimitry Andric char_type tolower(char_type __c) const 5600b57cec5SDimitry Andric { 5610b57cec5SDimitry Andric return do_tolower(__c); 5620b57cec5SDimitry Andric } 5630b57cec5SDimitry Andric 5640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5650b57cec5SDimitry Andric const char_type* tolower(char_type* __low, const char_type* __high) const 5660b57cec5SDimitry Andric { 5670b57cec5SDimitry Andric return do_tolower(__low, __high); 5680b57cec5SDimitry Andric } 5690b57cec5SDimitry Andric 5700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5710b57cec5SDimitry Andric char_type widen(char __c) const 5720b57cec5SDimitry Andric { 5730b57cec5SDimitry Andric return do_widen(__c); 5740b57cec5SDimitry Andric } 5750b57cec5SDimitry Andric 5760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5770b57cec5SDimitry Andric const char* widen(const char* __low, const char* __high, char_type* __to) const 5780b57cec5SDimitry Andric { 5790b57cec5SDimitry Andric return do_widen(__low, __high, __to); 5800b57cec5SDimitry Andric } 5810b57cec5SDimitry Andric 5820b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5830b57cec5SDimitry Andric char narrow(char_type __c, char __dfault) const 5840b57cec5SDimitry Andric { 5850b57cec5SDimitry Andric return do_narrow(__c, __dfault); 5860b57cec5SDimitry Andric } 5870b57cec5SDimitry Andric 5880b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5890b57cec5SDimitry Andric const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const 5900b57cec5SDimitry Andric { 5910b57cec5SDimitry Andric return do_narrow(__low, __high, __dfault, __to); 5920b57cec5SDimitry Andric } 5930b57cec5SDimitry Andric 5940b57cec5SDimitry Andric static locale::id id; 5950b57cec5SDimitry Andric 5960b57cec5SDimitry Andricprotected: 597bdd1243dSDimitry Andric ~ctype() override; 5980b57cec5SDimitry Andric virtual bool do_is(mask __m, char_type __c) const; 5990b57cec5SDimitry Andric virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; 6000b57cec5SDimitry Andric virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; 6010b57cec5SDimitry Andric virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; 6020b57cec5SDimitry Andric virtual char_type do_toupper(char_type) const; 6030b57cec5SDimitry Andric virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; 6040b57cec5SDimitry Andric virtual char_type do_tolower(char_type) const; 6050b57cec5SDimitry Andric virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; 6060b57cec5SDimitry Andric virtual char_type do_widen(char) const; 6070b57cec5SDimitry Andric virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; 6080b57cec5SDimitry Andric virtual char do_narrow(char_type, char __dfault) const; 6090b57cec5SDimitry Andric virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; 6100b57cec5SDimitry Andric}; 611349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 6120b57cec5SDimitry Andric 6130b57cec5SDimitry Andrictemplate <> 614*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype<char> 6150b57cec5SDimitry Andric : public locale::facet, public ctype_base 6160b57cec5SDimitry Andric{ 6170b57cec5SDimitry Andric const mask* __tab_; 6180b57cec5SDimitry Andric bool __del_; 6190b57cec5SDimitry Andricpublic: 6200b57cec5SDimitry Andric typedef char char_type; 6210b57cec5SDimitry Andric 622e8d8bef9SDimitry Andric explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0); 6230b57cec5SDimitry Andric 6240b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6250b57cec5SDimitry Andric bool is(mask __m, char_type __c) const 6260b57cec5SDimitry Andric { 6270b57cec5SDimitry Andric return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false; 6280b57cec5SDimitry Andric } 6290b57cec5SDimitry Andric 6300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6310b57cec5SDimitry Andric const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const 6320b57cec5SDimitry Andric { 6330b57cec5SDimitry Andric for (; __low != __high; ++__low, ++__vec) 6340b57cec5SDimitry Andric *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0; 6350b57cec5SDimitry Andric return __low; 6360b57cec5SDimitry Andric } 6370b57cec5SDimitry Andric 6380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6390b57cec5SDimitry Andric const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const 6400b57cec5SDimitry Andric { 6410b57cec5SDimitry Andric for (; __low != __high; ++__low) 6420b57cec5SDimitry Andric if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)) 6430b57cec5SDimitry Andric break; 6440b57cec5SDimitry Andric return __low; 6450b57cec5SDimitry Andric } 6460b57cec5SDimitry Andric 6470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6480b57cec5SDimitry Andric const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const 6490b57cec5SDimitry Andric { 6500b57cec5SDimitry Andric for (; __low != __high; ++__low) 651bdd1243dSDimitry Andric if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m)) 6520b57cec5SDimitry Andric break; 6530b57cec5SDimitry Andric return __low; 6540b57cec5SDimitry Andric } 6550b57cec5SDimitry Andric 6560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6570b57cec5SDimitry Andric char_type toupper(char_type __c) const 6580b57cec5SDimitry Andric { 6590b57cec5SDimitry Andric return do_toupper(__c); 6600b57cec5SDimitry Andric } 6610b57cec5SDimitry Andric 6620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6630b57cec5SDimitry Andric const char_type* toupper(char_type* __low, const char_type* __high) const 6640b57cec5SDimitry Andric { 6650b57cec5SDimitry Andric return do_toupper(__low, __high); 6660b57cec5SDimitry Andric } 6670b57cec5SDimitry Andric 6680b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6690b57cec5SDimitry Andric char_type tolower(char_type __c) const 6700b57cec5SDimitry Andric { 6710b57cec5SDimitry Andric return do_tolower(__c); 6720b57cec5SDimitry Andric } 6730b57cec5SDimitry Andric 6740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6750b57cec5SDimitry Andric const char_type* tolower(char_type* __low, const char_type* __high) const 6760b57cec5SDimitry Andric { 6770b57cec5SDimitry Andric return do_tolower(__low, __high); 6780b57cec5SDimitry Andric } 6790b57cec5SDimitry Andric 6800b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6810b57cec5SDimitry Andric char_type widen(char __c) const 6820b57cec5SDimitry Andric { 6830b57cec5SDimitry Andric return do_widen(__c); 6840b57cec5SDimitry Andric } 6850b57cec5SDimitry Andric 6860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6870b57cec5SDimitry Andric const char* widen(const char* __low, const char* __high, char_type* __to) const 6880b57cec5SDimitry Andric { 6890b57cec5SDimitry Andric return do_widen(__low, __high, __to); 6900b57cec5SDimitry Andric } 6910b57cec5SDimitry Andric 6920b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6930b57cec5SDimitry Andric char narrow(char_type __c, char __dfault) const 6940b57cec5SDimitry Andric { 6950b57cec5SDimitry Andric return do_narrow(__c, __dfault); 6960b57cec5SDimitry Andric } 6970b57cec5SDimitry Andric 6980b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6990b57cec5SDimitry Andric const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const 7000b57cec5SDimitry Andric { 7010b57cec5SDimitry Andric return do_narrow(__low, __high, __dfault, __to); 7020b57cec5SDimitry Andric } 7030b57cec5SDimitry Andric 7040b57cec5SDimitry Andric static locale::id id; 7050b57cec5SDimitry Andric 7060b57cec5SDimitry Andric#ifdef _CACHED_RUNES 7070b57cec5SDimitry Andric static const size_t table_size = _CACHED_RUNES; 7080b57cec5SDimitry Andric#else 7090b57cec5SDimitry Andric static const size_t table_size = 256; // FIXME: Don't hardcode this. 7100b57cec5SDimitry Andric#endif 7110b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY const mask* table() const _NOEXCEPT {return __tab_;} 7120b57cec5SDimitry Andric static const mask* classic_table() _NOEXCEPT; 7130b57cec5SDimitry Andric#if defined(__GLIBC__) || defined(__EMSCRIPTEN__) 7140b57cec5SDimitry Andric static const int* __classic_upper_table() _NOEXCEPT; 7150b57cec5SDimitry Andric static const int* __classic_lower_table() _NOEXCEPT; 7160b57cec5SDimitry Andric#endif 7170b57cec5SDimitry Andric#if defined(__NetBSD__) 7180b57cec5SDimitry Andric static const short* __classic_upper_table() _NOEXCEPT; 7190b57cec5SDimitry Andric static const short* __classic_lower_table() _NOEXCEPT; 7200b57cec5SDimitry Andric#endif 72104eeddc0SDimitry Andric#if defined(__MVS__) 72204eeddc0SDimitry Andric static const unsigned short* __classic_upper_table() _NOEXCEPT; 72304eeddc0SDimitry Andric static const unsigned short* __classic_lower_table() _NOEXCEPT; 72404eeddc0SDimitry Andric#endif 7250b57cec5SDimitry Andric 7260b57cec5SDimitry Andricprotected: 727bdd1243dSDimitry Andric ~ctype() override; 7280b57cec5SDimitry Andric virtual char_type do_toupper(char_type __c) const; 7290b57cec5SDimitry Andric virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; 7300b57cec5SDimitry Andric virtual char_type do_tolower(char_type __c) const; 7310b57cec5SDimitry Andric virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; 7320b57cec5SDimitry Andric virtual char_type do_widen(char __c) const; 7330b57cec5SDimitry Andric virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const; 7340b57cec5SDimitry Andric virtual char do_narrow(char_type __c, char __dfault) const; 7350b57cec5SDimitry Andric virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const; 7360b57cec5SDimitry Andric}; 7370b57cec5SDimitry Andric 7380b57cec5SDimitry Andric// template <class CharT> class ctype_byname; 7390b57cec5SDimitry Andric 7400b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname; 7410b57cec5SDimitry Andric 7420b57cec5SDimitry Andrictemplate <> 743*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> 7440b57cec5SDimitry Andric : public ctype<char> 7450b57cec5SDimitry Andric{ 746bdd1243dSDimitry Andric locale_t __l_; 7470b57cec5SDimitry Andric 7480b57cec5SDimitry Andricpublic: 7490b57cec5SDimitry Andric explicit ctype_byname(const char*, size_t = 0); 7500b57cec5SDimitry Andric explicit ctype_byname(const string&, size_t = 0); 7510b57cec5SDimitry Andric 7520b57cec5SDimitry Andricprotected: 753bdd1243dSDimitry Andric ~ctype_byname() override; 754bdd1243dSDimitry Andric char_type do_toupper(char_type) const override; 755bdd1243dSDimitry Andric const char_type* do_toupper(char_type* __low, const char_type* __high) const override; 756bdd1243dSDimitry Andric char_type do_tolower(char_type) const override; 757bdd1243dSDimitry Andric const char_type* do_tolower(char_type* __low, const char_type* __high) const override; 7580b57cec5SDimitry Andric}; 7590b57cec5SDimitry Andric 760349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 7610b57cec5SDimitry Andrictemplate <> 762*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> 7630b57cec5SDimitry Andric : public ctype<wchar_t> 7640b57cec5SDimitry Andric{ 765bdd1243dSDimitry Andric locale_t __l_; 7660b57cec5SDimitry Andric 7670b57cec5SDimitry Andricpublic: 7680b57cec5SDimitry Andric explicit ctype_byname(const char*, size_t = 0); 7690b57cec5SDimitry Andric explicit ctype_byname(const string&, size_t = 0); 7700b57cec5SDimitry Andric 7710b57cec5SDimitry Andricprotected: 772bdd1243dSDimitry Andric ~ctype_byname() override; 773bdd1243dSDimitry Andric bool do_is(mask __m, char_type __c) const override; 774bdd1243dSDimitry Andric const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const override; 775bdd1243dSDimitry Andric const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const override; 776bdd1243dSDimitry Andric const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const override; 777bdd1243dSDimitry Andric char_type do_toupper(char_type) const override; 778bdd1243dSDimitry Andric const char_type* do_toupper(char_type* __low, const char_type* __high) const override; 779bdd1243dSDimitry Andric char_type do_tolower(char_type) const override; 780bdd1243dSDimitry Andric const char_type* do_tolower(char_type* __low, const char_type* __high) const override; 781bdd1243dSDimitry Andric char_type do_widen(char) const override; 782bdd1243dSDimitry Andric const char* do_widen(const char* __low, const char* __high, char_type* __dest) const override; 783bdd1243dSDimitry Andric char do_narrow(char_type, char __dfault) const override; 784bdd1243dSDimitry Andric const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override; 7850b57cec5SDimitry Andric}; 786349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 7870b57cec5SDimitry Andric 7880b57cec5SDimitry Andrictemplate <class _CharT> 7890b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 7900b57cec5SDimitry Andricbool 7910b57cec5SDimitry Andricisspace(_CharT __c, const locale& __loc) 7920b57cec5SDimitry Andric{ 793bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); 7940b57cec5SDimitry Andric} 7950b57cec5SDimitry Andric 7960b57cec5SDimitry Andrictemplate <class _CharT> 7970b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 7980b57cec5SDimitry Andricbool 7990b57cec5SDimitry Andricisprint(_CharT __c, const locale& __loc) 8000b57cec5SDimitry Andric{ 801bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); 8020b57cec5SDimitry Andric} 8030b57cec5SDimitry Andric 8040b57cec5SDimitry Andrictemplate <class _CharT> 8050b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8060b57cec5SDimitry Andricbool 8070b57cec5SDimitry Andriciscntrl(_CharT __c, const locale& __loc) 8080b57cec5SDimitry Andric{ 809bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); 8100b57cec5SDimitry Andric} 8110b57cec5SDimitry Andric 8120b57cec5SDimitry Andrictemplate <class _CharT> 8130b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8140b57cec5SDimitry Andricbool 8150b57cec5SDimitry Andricisupper(_CharT __c, const locale& __loc) 8160b57cec5SDimitry Andric{ 817bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); 8180b57cec5SDimitry Andric} 8190b57cec5SDimitry Andric 8200b57cec5SDimitry Andrictemplate <class _CharT> 8210b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8220b57cec5SDimitry Andricbool 8230b57cec5SDimitry Andricislower(_CharT __c, const locale& __loc) 8240b57cec5SDimitry Andric{ 825bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); 8260b57cec5SDimitry Andric} 8270b57cec5SDimitry Andric 8280b57cec5SDimitry Andrictemplate <class _CharT> 8290b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8300b57cec5SDimitry Andricbool 8310b57cec5SDimitry Andricisalpha(_CharT __c, const locale& __loc) 8320b57cec5SDimitry Andric{ 833bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); 8340b57cec5SDimitry Andric} 8350b57cec5SDimitry Andric 8360b57cec5SDimitry Andrictemplate <class _CharT> 8370b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8380b57cec5SDimitry Andricbool 8390b57cec5SDimitry Andricisdigit(_CharT __c, const locale& __loc) 8400b57cec5SDimitry Andric{ 841bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); 8420b57cec5SDimitry Andric} 8430b57cec5SDimitry Andric 8440b57cec5SDimitry Andrictemplate <class _CharT> 8450b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8460b57cec5SDimitry Andricbool 8470b57cec5SDimitry Andricispunct(_CharT __c, const locale& __loc) 8480b57cec5SDimitry Andric{ 849bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); 8500b57cec5SDimitry Andric} 8510b57cec5SDimitry Andric 8520b57cec5SDimitry Andrictemplate <class _CharT> 8530b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8540b57cec5SDimitry Andricbool 8550b57cec5SDimitry Andricisxdigit(_CharT __c, const locale& __loc) 8560b57cec5SDimitry Andric{ 857bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); 8580b57cec5SDimitry Andric} 8590b57cec5SDimitry Andric 8600b57cec5SDimitry Andrictemplate <class _CharT> 8610b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8620b57cec5SDimitry Andricbool 8630b57cec5SDimitry Andricisalnum(_CharT __c, const locale& __loc) 8640b57cec5SDimitry Andric{ 865bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); 8660b57cec5SDimitry Andric} 8670b57cec5SDimitry Andric 8680b57cec5SDimitry Andrictemplate <class _CharT> 8690b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8700b57cec5SDimitry Andricbool 8710b57cec5SDimitry Andricisgraph(_CharT __c, const locale& __loc) 8720b57cec5SDimitry Andric{ 873bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); 8740b57cec5SDimitry Andric} 8750b57cec5SDimitry Andric 8760b57cec5SDimitry Andrictemplate <class _CharT> 877*06c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) { 878*06c3fb27SDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c); 879*06c3fb27SDimitry Andric} 880*06c3fb27SDimitry Andric 881*06c3fb27SDimitry Andrictemplate <class _CharT> 8820b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8830b57cec5SDimitry Andric_CharT 8840b57cec5SDimitry Andrictoupper(_CharT __c, const locale& __loc) 8850b57cec5SDimitry Andric{ 886bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).toupper(__c); 8870b57cec5SDimitry Andric} 8880b57cec5SDimitry Andric 8890b57cec5SDimitry Andrictemplate <class _CharT> 8900b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 8910b57cec5SDimitry Andric_CharT 8920b57cec5SDimitry Andrictolower(_CharT __c, const locale& __loc) 8930b57cec5SDimitry Andric{ 894bdd1243dSDimitry Andric return std::use_facet<ctype<_CharT> >(__loc).tolower(__c); 8950b57cec5SDimitry Andric} 8960b57cec5SDimitry Andric 8970b57cec5SDimitry Andric// codecvt_base 8980b57cec5SDimitry Andric 899*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt_base 9000b57cec5SDimitry Andric{ 9010b57cec5SDimitry Andricpublic: 9020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY codecvt_base() {} 9030b57cec5SDimitry Andric enum result {ok, partial, error, noconv}; 9040b57cec5SDimitry Andric}; 9050b57cec5SDimitry Andric 9060b57cec5SDimitry Andric// template <class internT, class externT, class stateT> class codecvt; 9070b57cec5SDimitry Andric 9080b57cec5SDimitry Andrictemplate <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt; 9090b57cec5SDimitry Andric 9100b57cec5SDimitry Andric// template <> class codecvt<char, char, mbstate_t> 9110b57cec5SDimitry Andric 9120b57cec5SDimitry Andrictemplate <> 913*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<char, char, mbstate_t> 9140b57cec5SDimitry Andric : public locale::facet, 9150b57cec5SDimitry Andric public codecvt_base 9160b57cec5SDimitry Andric{ 9170b57cec5SDimitry Andricpublic: 9180b57cec5SDimitry Andric typedef char intern_type; 9190b57cec5SDimitry Andric typedef char extern_type; 9200b57cec5SDimitry Andric typedef mbstate_t state_type; 9210b57cec5SDimitry Andric 9220b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9230b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0) 9240b57cec5SDimitry Andric : locale::facet(__refs) {} 9250b57cec5SDimitry Andric 9260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9270b57cec5SDimitry Andric result out(state_type& __st, 9280b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 9290b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 9300b57cec5SDimitry Andric { 9310b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 9320b57cec5SDimitry Andric } 9330b57cec5SDimitry Andric 9340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9350b57cec5SDimitry Andric result unshift(state_type& __st, 9360b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 9370b57cec5SDimitry Andric { 9380b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 9390b57cec5SDimitry Andric } 9400b57cec5SDimitry Andric 9410b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9420b57cec5SDimitry Andric result in(state_type& __st, 9430b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 9440b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 9450b57cec5SDimitry Andric { 9460b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 9470b57cec5SDimitry Andric } 9480b57cec5SDimitry Andric 9490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9500b57cec5SDimitry Andric int encoding() const _NOEXCEPT 9510b57cec5SDimitry Andric { 9520b57cec5SDimitry Andric return do_encoding(); 9530b57cec5SDimitry Andric } 9540b57cec5SDimitry Andric 9550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9560b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 9570b57cec5SDimitry Andric { 9580b57cec5SDimitry Andric return do_always_noconv(); 9590b57cec5SDimitry Andric } 9600b57cec5SDimitry Andric 9610b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9620b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 9630b57cec5SDimitry Andric { 9640b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 9650b57cec5SDimitry Andric } 9660b57cec5SDimitry Andric 9670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9680b57cec5SDimitry Andric int max_length() const _NOEXCEPT 9690b57cec5SDimitry Andric { 9700b57cec5SDimitry Andric return do_max_length(); 9710b57cec5SDimitry Andric } 9720b57cec5SDimitry Andric 9730b57cec5SDimitry Andric static locale::id id; 9740b57cec5SDimitry Andric 9750b57cec5SDimitry Andricprotected: 9760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 9770b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 9780b57cec5SDimitry Andric : locale::facet(__refs) {} 9790b57cec5SDimitry Andric 980bdd1243dSDimitry Andric ~codecvt() override; 9810b57cec5SDimitry Andric 9820b57cec5SDimitry Andric virtual result do_out(state_type& __st, 9830b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 9840b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 9850b57cec5SDimitry Andric virtual result do_in(state_type& __st, 9860b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 9870b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 9880b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 9890b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 9900b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 9910b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 9920b57cec5SDimitry Andric virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 9930b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 9940b57cec5SDimitry Andric}; 9950b57cec5SDimitry Andric 9960b57cec5SDimitry Andric// template <> class codecvt<wchar_t, char, mbstate_t> 9970b57cec5SDimitry Andric 998349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 9990b57cec5SDimitry Andrictemplate <> 1000*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> 10010b57cec5SDimitry Andric : public locale::facet, 10020b57cec5SDimitry Andric public codecvt_base 10030b57cec5SDimitry Andric{ 1004bdd1243dSDimitry Andric locale_t __l_; 10050b57cec5SDimitry Andricpublic: 10060b57cec5SDimitry Andric typedef wchar_t intern_type; 10070b57cec5SDimitry Andric typedef char extern_type; 10080b57cec5SDimitry Andric typedef mbstate_t state_type; 10090b57cec5SDimitry Andric 10100b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0); 10110b57cec5SDimitry Andric 10120b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10130b57cec5SDimitry Andric result out(state_type& __st, 10140b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 10150b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 10160b57cec5SDimitry Andric { 10170b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 10180b57cec5SDimitry Andric } 10190b57cec5SDimitry Andric 10200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10210b57cec5SDimitry Andric result unshift(state_type& __st, 10220b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 10230b57cec5SDimitry Andric { 10240b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 10250b57cec5SDimitry Andric } 10260b57cec5SDimitry Andric 10270b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10280b57cec5SDimitry Andric result in(state_type& __st, 10290b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 10300b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 10310b57cec5SDimitry Andric { 10320b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 10330b57cec5SDimitry Andric } 10340b57cec5SDimitry Andric 10350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10360b57cec5SDimitry Andric int encoding() const _NOEXCEPT 10370b57cec5SDimitry Andric { 10380b57cec5SDimitry Andric return do_encoding(); 10390b57cec5SDimitry Andric } 10400b57cec5SDimitry Andric 10410b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10420b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 10430b57cec5SDimitry Andric { 10440b57cec5SDimitry Andric return do_always_noconv(); 10450b57cec5SDimitry Andric } 10460b57cec5SDimitry Andric 10470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10480b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 10490b57cec5SDimitry Andric { 10500b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 10510b57cec5SDimitry Andric } 10520b57cec5SDimitry Andric 10530b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10540b57cec5SDimitry Andric int max_length() const _NOEXCEPT 10550b57cec5SDimitry Andric { 10560b57cec5SDimitry Andric return do_max_length(); 10570b57cec5SDimitry Andric } 10580b57cec5SDimitry Andric 10590b57cec5SDimitry Andric static locale::id id; 10600b57cec5SDimitry Andric 10610b57cec5SDimitry Andricprotected: 10620b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0); 10630b57cec5SDimitry Andric 1064bdd1243dSDimitry Andric ~codecvt() override; 10650b57cec5SDimitry Andric 10660b57cec5SDimitry Andric virtual result do_out(state_type& __st, 10670b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 10680b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 10690b57cec5SDimitry Andric virtual result do_in(state_type& __st, 10700b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 10710b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 10720b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 10730b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 10740b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 10750b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 10760b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 10770b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 10780b57cec5SDimitry Andric}; 1079349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 10800b57cec5SDimitry Andric 1081e8d8bef9SDimitry Andric// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20 10820b57cec5SDimitry Andric 10830b57cec5SDimitry Andrictemplate <> 1084*06c3fb27SDimitry Andricclass _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char, mbstate_t> 10850b57cec5SDimitry Andric : public locale::facet, 10860b57cec5SDimitry Andric public codecvt_base 10870b57cec5SDimitry Andric{ 10880b57cec5SDimitry Andricpublic: 10890b57cec5SDimitry Andric typedef char16_t intern_type; 10900b57cec5SDimitry Andric typedef char extern_type; 10910b57cec5SDimitry Andric typedef mbstate_t state_type; 10920b57cec5SDimitry Andric 10930b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10940b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0) 10950b57cec5SDimitry Andric : locale::facet(__refs) {} 10960b57cec5SDimitry Andric 10970b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 10980b57cec5SDimitry Andric result out(state_type& __st, 10990b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 11000b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 11010b57cec5SDimitry Andric { 11020b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 11030b57cec5SDimitry Andric } 11040b57cec5SDimitry Andric 11050b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11060b57cec5SDimitry Andric result unshift(state_type& __st, 11070b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 11080b57cec5SDimitry Andric { 11090b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 11100b57cec5SDimitry Andric } 11110b57cec5SDimitry Andric 11120b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11130b57cec5SDimitry Andric result in(state_type& __st, 11140b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 11150b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 11160b57cec5SDimitry Andric { 11170b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 11180b57cec5SDimitry Andric } 11190b57cec5SDimitry Andric 11200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11210b57cec5SDimitry Andric int encoding() const _NOEXCEPT 11220b57cec5SDimitry Andric { 11230b57cec5SDimitry Andric return do_encoding(); 11240b57cec5SDimitry Andric } 11250b57cec5SDimitry Andric 11260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11270b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 11280b57cec5SDimitry Andric { 11290b57cec5SDimitry Andric return do_always_noconv(); 11300b57cec5SDimitry Andric } 11310b57cec5SDimitry Andric 11320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11330b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 11340b57cec5SDimitry Andric { 11350b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 11360b57cec5SDimitry Andric } 11370b57cec5SDimitry Andric 11380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11390b57cec5SDimitry Andric int max_length() const _NOEXCEPT 11400b57cec5SDimitry Andric { 11410b57cec5SDimitry Andric return do_max_length(); 11420b57cec5SDimitry Andric } 11430b57cec5SDimitry Andric 11440b57cec5SDimitry Andric static locale::id id; 11450b57cec5SDimitry Andric 11460b57cec5SDimitry Andricprotected: 11470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 11480b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 11490b57cec5SDimitry Andric : locale::facet(__refs) {} 11500b57cec5SDimitry Andric 1151bdd1243dSDimitry Andric ~codecvt() override; 11520b57cec5SDimitry Andric 11530b57cec5SDimitry Andric virtual result do_out(state_type& __st, 11540b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 11550b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 11560b57cec5SDimitry Andric virtual result do_in(state_type& __st, 11570b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 11580b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 11590b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 11600b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 11610b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 11620b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 11630b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 11640b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 11650b57cec5SDimitry Andric}; 11660b57cec5SDimitry Andric 1167fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T 1168e8d8bef9SDimitry Andric 1169e8d8bef9SDimitry Andric// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20 11700b57cec5SDimitry Andric 11710b57cec5SDimitry Andrictemplate <> 1172*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char8_t, mbstate_t> 1173e8d8bef9SDimitry Andric : public locale::facet, 1174e8d8bef9SDimitry Andric public codecvt_base 1175e8d8bef9SDimitry Andric{ 1176e8d8bef9SDimitry Andricpublic: 1177e8d8bef9SDimitry Andric typedef char16_t intern_type; 1178e8d8bef9SDimitry Andric typedef char8_t extern_type; 1179e8d8bef9SDimitry Andric typedef mbstate_t state_type; 1180e8d8bef9SDimitry Andric 1181e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1182e8d8bef9SDimitry Andric explicit codecvt(size_t __refs = 0) 1183e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1184e8d8bef9SDimitry Andric 1185e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1186e8d8bef9SDimitry Andric result out(state_type& __st, 1187e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1188e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1189e8d8bef9SDimitry Andric { 1190e8d8bef9SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1191e8d8bef9SDimitry Andric } 1192e8d8bef9SDimitry Andric 1193e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1194e8d8bef9SDimitry Andric result unshift(state_type& __st, 1195e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1196e8d8bef9SDimitry Andric { 1197e8d8bef9SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 1198e8d8bef9SDimitry Andric } 1199e8d8bef9SDimitry Andric 1200e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1201e8d8bef9SDimitry Andric result in(state_type& __st, 1202e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1203e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 1204e8d8bef9SDimitry Andric { 1205e8d8bef9SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1206e8d8bef9SDimitry Andric } 1207e8d8bef9SDimitry Andric 1208e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1209e8d8bef9SDimitry Andric int encoding() const _NOEXCEPT 1210e8d8bef9SDimitry Andric { 1211e8d8bef9SDimitry Andric return do_encoding(); 1212e8d8bef9SDimitry Andric } 1213e8d8bef9SDimitry Andric 1214e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1215e8d8bef9SDimitry Andric bool always_noconv() const _NOEXCEPT 1216e8d8bef9SDimitry Andric { 1217e8d8bef9SDimitry Andric return do_always_noconv(); 1218e8d8bef9SDimitry Andric } 1219e8d8bef9SDimitry Andric 1220e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1221e8d8bef9SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 1222e8d8bef9SDimitry Andric { 1223e8d8bef9SDimitry Andric return do_length(__st, __frm, __end, __mx); 1224e8d8bef9SDimitry Andric } 1225e8d8bef9SDimitry Andric 1226e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1227e8d8bef9SDimitry Andric int max_length() const _NOEXCEPT 1228e8d8bef9SDimitry Andric { 1229e8d8bef9SDimitry Andric return do_max_length(); 1230e8d8bef9SDimitry Andric } 1231e8d8bef9SDimitry Andric 1232e8d8bef9SDimitry Andric static locale::id id; 1233e8d8bef9SDimitry Andric 1234e8d8bef9SDimitry Andricprotected: 1235e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1236e8d8bef9SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 1237e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1238e8d8bef9SDimitry Andric 1239bdd1243dSDimitry Andric ~codecvt() override; 1240e8d8bef9SDimitry Andric 1241e8d8bef9SDimitry Andric virtual result do_out(state_type& __st, 1242e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1243e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1244e8d8bef9SDimitry Andric virtual result do_in(state_type& __st, 1245e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1246e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1247e8d8bef9SDimitry Andric virtual result do_unshift(state_type& __st, 1248e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1249e8d8bef9SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1250e8d8bef9SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1251e8d8bef9SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 1252e8d8bef9SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1253e8d8bef9SDimitry Andric}; 1254e8d8bef9SDimitry Andric 1255e8d8bef9SDimitry Andric#endif 1256e8d8bef9SDimitry Andric 1257e8d8bef9SDimitry Andric// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20 1258e8d8bef9SDimitry Andric 1259e8d8bef9SDimitry Andrictemplate <> 1260*06c3fb27SDimitry Andricclass _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char, mbstate_t> 12610b57cec5SDimitry Andric : public locale::facet, 12620b57cec5SDimitry Andric public codecvt_base 12630b57cec5SDimitry Andric{ 12640b57cec5SDimitry Andricpublic: 12650b57cec5SDimitry Andric typedef char32_t intern_type; 12660b57cec5SDimitry Andric typedef char extern_type; 12670b57cec5SDimitry Andric typedef mbstate_t state_type; 12680b57cec5SDimitry Andric 12690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12700b57cec5SDimitry Andric explicit codecvt(size_t __refs = 0) 12710b57cec5SDimitry Andric : locale::facet(__refs) {} 12720b57cec5SDimitry Andric 12730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12740b57cec5SDimitry Andric result out(state_type& __st, 12750b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 12760b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 12770b57cec5SDimitry Andric { 12780b57cec5SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 12790b57cec5SDimitry Andric } 12800b57cec5SDimitry Andric 12810b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12820b57cec5SDimitry Andric result unshift(state_type& __st, 12830b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 12840b57cec5SDimitry Andric { 12850b57cec5SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 12860b57cec5SDimitry Andric } 12870b57cec5SDimitry Andric 12880b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12890b57cec5SDimitry Andric result in(state_type& __st, 12900b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 12910b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 12920b57cec5SDimitry Andric { 12930b57cec5SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 12940b57cec5SDimitry Andric } 12950b57cec5SDimitry Andric 12960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 12970b57cec5SDimitry Andric int encoding() const _NOEXCEPT 12980b57cec5SDimitry Andric { 12990b57cec5SDimitry Andric return do_encoding(); 13000b57cec5SDimitry Andric } 13010b57cec5SDimitry Andric 13020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13030b57cec5SDimitry Andric bool always_noconv() const _NOEXCEPT 13040b57cec5SDimitry Andric { 13050b57cec5SDimitry Andric return do_always_noconv(); 13060b57cec5SDimitry Andric } 13070b57cec5SDimitry Andric 13080b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13090b57cec5SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 13100b57cec5SDimitry Andric { 13110b57cec5SDimitry Andric return do_length(__st, __frm, __end, __mx); 13120b57cec5SDimitry Andric } 13130b57cec5SDimitry Andric 13140b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13150b57cec5SDimitry Andric int max_length() const _NOEXCEPT 13160b57cec5SDimitry Andric { 13170b57cec5SDimitry Andric return do_max_length(); 13180b57cec5SDimitry Andric } 13190b57cec5SDimitry Andric 13200b57cec5SDimitry Andric static locale::id id; 13210b57cec5SDimitry Andric 13220b57cec5SDimitry Andricprotected: 13230b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 13240b57cec5SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 13250b57cec5SDimitry Andric : locale::facet(__refs) {} 13260b57cec5SDimitry Andric 1327bdd1243dSDimitry Andric ~codecvt() override; 13280b57cec5SDimitry Andric 13290b57cec5SDimitry Andric virtual result do_out(state_type& __st, 13300b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 13310b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 13320b57cec5SDimitry Andric virtual result do_in(state_type& __st, 13330b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 13340b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 13350b57cec5SDimitry Andric virtual result do_unshift(state_type& __st, 13360b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 13370b57cec5SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 13380b57cec5SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 13390b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 13400b57cec5SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 13410b57cec5SDimitry Andric}; 13420b57cec5SDimitry Andric 1343fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T 1344e8d8bef9SDimitry Andric 1345e8d8bef9SDimitry Andric// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20 1346e8d8bef9SDimitry Andric 1347e8d8bef9SDimitry Andrictemplate <> 1348*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char8_t, mbstate_t> 1349e8d8bef9SDimitry Andric : public locale::facet, 1350e8d8bef9SDimitry Andric public codecvt_base 1351e8d8bef9SDimitry Andric{ 1352e8d8bef9SDimitry Andricpublic: 1353e8d8bef9SDimitry Andric typedef char32_t intern_type; 1354e8d8bef9SDimitry Andric typedef char8_t extern_type; 1355e8d8bef9SDimitry Andric typedef mbstate_t state_type; 1356e8d8bef9SDimitry Andric 1357e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1358e8d8bef9SDimitry Andric explicit codecvt(size_t __refs = 0) 1359e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1360e8d8bef9SDimitry Andric 1361e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1362e8d8bef9SDimitry Andric result out(state_type& __st, 1363e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1364e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1365e8d8bef9SDimitry Andric { 1366e8d8bef9SDimitry Andric return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1367e8d8bef9SDimitry Andric } 1368e8d8bef9SDimitry Andric 1369e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1370e8d8bef9SDimitry Andric result unshift(state_type& __st, 1371e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const 1372e8d8bef9SDimitry Andric { 1373e8d8bef9SDimitry Andric return do_unshift(__st, __to, __to_end, __to_nxt); 1374e8d8bef9SDimitry Andric } 1375e8d8bef9SDimitry Andric 1376e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1377e8d8bef9SDimitry Andric result in(state_type& __st, 1378e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1379e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const 1380e8d8bef9SDimitry Andric { 1381e8d8bef9SDimitry Andric return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); 1382e8d8bef9SDimitry Andric } 1383e8d8bef9SDimitry Andric 1384e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1385e8d8bef9SDimitry Andric int encoding() const _NOEXCEPT 1386e8d8bef9SDimitry Andric { 1387e8d8bef9SDimitry Andric return do_encoding(); 1388e8d8bef9SDimitry Andric } 1389e8d8bef9SDimitry Andric 1390e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1391e8d8bef9SDimitry Andric bool always_noconv() const _NOEXCEPT 1392e8d8bef9SDimitry Andric { 1393e8d8bef9SDimitry Andric return do_always_noconv(); 1394e8d8bef9SDimitry Andric } 1395e8d8bef9SDimitry Andric 1396e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1397e8d8bef9SDimitry Andric int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const 1398e8d8bef9SDimitry Andric { 1399e8d8bef9SDimitry Andric return do_length(__st, __frm, __end, __mx); 1400e8d8bef9SDimitry Andric } 1401e8d8bef9SDimitry Andric 1402e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1403e8d8bef9SDimitry Andric int max_length() const _NOEXCEPT 1404e8d8bef9SDimitry Andric { 1405e8d8bef9SDimitry Andric return do_max_length(); 1406e8d8bef9SDimitry Andric } 1407e8d8bef9SDimitry Andric 1408e8d8bef9SDimitry Andric static locale::id id; 1409e8d8bef9SDimitry Andric 1410e8d8bef9SDimitry Andricprotected: 1411e8d8bef9SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1412e8d8bef9SDimitry Andric explicit codecvt(const char*, size_t __refs = 0) 1413e8d8bef9SDimitry Andric : locale::facet(__refs) {} 1414e8d8bef9SDimitry Andric 1415bdd1243dSDimitry Andric ~codecvt() override; 1416e8d8bef9SDimitry Andric 1417e8d8bef9SDimitry Andric virtual result do_out(state_type& __st, 1418e8d8bef9SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1419e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1420e8d8bef9SDimitry Andric virtual result do_in(state_type& __st, 1421e8d8bef9SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1422e8d8bef9SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1423e8d8bef9SDimitry Andric virtual result do_unshift(state_type& __st, 1424e8d8bef9SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1425e8d8bef9SDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1426e8d8bef9SDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1427e8d8bef9SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; 1428e8d8bef9SDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1429e8d8bef9SDimitry Andric}; 1430e8d8bef9SDimitry Andric 1431e8d8bef9SDimitry Andric#endif 1432e8d8bef9SDimitry Andric 14330b57cec5SDimitry Andric// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname 14340b57cec5SDimitry Andric 14350b57cec5SDimitry Andrictemplate <class _InternT, class _ExternT, class _StateT> 14360b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_byname 14370b57cec5SDimitry Andric : public codecvt<_InternT, _ExternT, _StateT> 14380b57cec5SDimitry Andric{ 14390b57cec5SDimitry Andricpublic: 14400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14410b57cec5SDimitry Andric explicit codecvt_byname(const char* __nm, size_t __refs = 0) 14420b57cec5SDimitry Andric : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} 14430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14440b57cec5SDimitry Andric explicit codecvt_byname(const string& __nm, size_t __refs = 0) 14450b57cec5SDimitry Andric : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {} 14460b57cec5SDimitry Andricprotected: 1447bdd1243dSDimitry Andric ~codecvt_byname() override; 14480b57cec5SDimitry Andric}; 14490b57cec5SDimitry Andric 1450e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 14510b57cec5SDimitry Andrictemplate <class _InternT, class _ExternT, class _StateT> 14520b57cec5SDimitry Andriccodecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() 14530b57cec5SDimitry Andric{ 14540b57cec5SDimitry Andric} 1455e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 14560b57cec5SDimitry Andric 145781ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>; 1458349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 145981ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; 1460349cc55cSDimitry Andric#endif 146181ad6265SDimitry Andricextern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 146281ad6265SDimitry Andricextern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 1463fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T 146481ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 146581ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 1466e8d8bef9SDimitry Andric#endif 14670b57cec5SDimitry Andric 14680b57cec5SDimitry Andrictemplate <size_t _Np> 14690b57cec5SDimitry Andricstruct __narrow_to_utf8 14700b57cec5SDimitry Andric{ 14710b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 14720b57cec5SDimitry Andric _OutputIterator 14730b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const; 14740b57cec5SDimitry Andric}; 14750b57cec5SDimitry Andric 14760b57cec5SDimitry Andrictemplate <> 14770b57cec5SDimitry Andricstruct __narrow_to_utf8<8> 14780b57cec5SDimitry Andric{ 14790b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 14800b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14810b57cec5SDimitry Andric _OutputIterator 14820b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const 14830b57cec5SDimitry Andric { 14840b57cec5SDimitry Andric for (; __wb < __we; ++__wb, ++__s) 14850b57cec5SDimitry Andric *__s = *__wb; 14860b57cec5SDimitry Andric return __s; 14870b57cec5SDimitry Andric } 14880b57cec5SDimitry Andric}; 14890b57cec5SDimitry Andric 1490e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 14910b57cec5SDimitry Andrictemplate <> 1492*06c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> 14930b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 14940b57cec5SDimitry Andric{ 14950b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14960b57cec5SDimitry Andric __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {} 1497e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 14980b57cec5SDimitry Andric 1499bdd1243dSDimitry Andric ~__narrow_to_utf8() override; 15000b57cec5SDimitry Andric 15010b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 15020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15030b57cec5SDimitry Andric _OutputIterator 15040b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const 15050b57cec5SDimitry Andric { 15060b57cec5SDimitry Andric result __r = ok; 15070b57cec5SDimitry Andric mbstate_t __mb; 15080b57cec5SDimitry Andric while (__wb < __we && __r != error) 15090b57cec5SDimitry Andric { 15100b57cec5SDimitry Andric const int __sz = 32; 15110b57cec5SDimitry Andric char __buf[__sz]; 15120b57cec5SDimitry Andric char* __bn; 15130b57cec5SDimitry Andric const char16_t* __wn = (const char16_t*)__wb; 15140b57cec5SDimitry Andric __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, 15150b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 15160b57cec5SDimitry Andric if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) 15170b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 15180b57cec5SDimitry Andric for (const char* __p = __buf; __p < __bn; ++__p, ++__s) 15190b57cec5SDimitry Andric *__s = *__p; 15200b57cec5SDimitry Andric __wb = (const _CharT*)__wn; 15210b57cec5SDimitry Andric } 15220b57cec5SDimitry Andric return __s; 15230b57cec5SDimitry Andric } 15240b57cec5SDimitry Andric}; 15250b57cec5SDimitry Andric 1526e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 15270b57cec5SDimitry Andrictemplate <> 1528*06c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> 15290b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 15300b57cec5SDimitry Andric{ 15310b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15320b57cec5SDimitry Andric __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {} 1533e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 15340b57cec5SDimitry Andric 1535bdd1243dSDimitry Andric ~__narrow_to_utf8() override; 15360b57cec5SDimitry Andric 15370b57cec5SDimitry Andric template <class _OutputIterator, class _CharT> 15380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15390b57cec5SDimitry Andric _OutputIterator 15400b57cec5SDimitry Andric operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const 15410b57cec5SDimitry Andric { 15420b57cec5SDimitry Andric result __r = ok; 15430b57cec5SDimitry Andric mbstate_t __mb; 15440b57cec5SDimitry Andric while (__wb < __we && __r != error) 15450b57cec5SDimitry Andric { 15460b57cec5SDimitry Andric const int __sz = 32; 15470b57cec5SDimitry Andric char __buf[__sz]; 15480b57cec5SDimitry Andric char* __bn; 15490b57cec5SDimitry Andric const char32_t* __wn = (const char32_t*)__wb; 15500b57cec5SDimitry Andric __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, 15510b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 15520b57cec5SDimitry Andric if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) 15530b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 15540b57cec5SDimitry Andric for (const char* __p = __buf; __p < __bn; ++__p, ++__s) 15550b57cec5SDimitry Andric *__s = *__p; 15560b57cec5SDimitry Andric __wb = (const _CharT*)__wn; 15570b57cec5SDimitry Andric } 15580b57cec5SDimitry Andric return __s; 15590b57cec5SDimitry Andric } 15600b57cec5SDimitry Andric}; 15610b57cec5SDimitry Andric 15620b57cec5SDimitry Andrictemplate <size_t _Np> 15630b57cec5SDimitry Andricstruct __widen_from_utf8 15640b57cec5SDimitry Andric{ 15650b57cec5SDimitry Andric template <class _OutputIterator> 15660b57cec5SDimitry Andric _OutputIterator 15670b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const; 15680b57cec5SDimitry Andric}; 15690b57cec5SDimitry Andric 15700b57cec5SDimitry Andrictemplate <> 15710b57cec5SDimitry Andricstruct __widen_from_utf8<8> 15720b57cec5SDimitry Andric{ 15730b57cec5SDimitry Andric template <class _OutputIterator> 15740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15750b57cec5SDimitry Andric _OutputIterator 15760b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const 15770b57cec5SDimitry Andric { 15780b57cec5SDimitry Andric for (; __nb < __ne; ++__nb, ++__s) 15790b57cec5SDimitry Andric *__s = *__nb; 15800b57cec5SDimitry Andric return __s; 15810b57cec5SDimitry Andric } 15820b57cec5SDimitry Andric}; 15830b57cec5SDimitry Andric 1584e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 15850b57cec5SDimitry Andrictemplate <> 1586*06c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> 15870b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 15880b57cec5SDimitry Andric{ 15890b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15900b57cec5SDimitry Andric __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {} 1591e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 15920b57cec5SDimitry Andric 1593bdd1243dSDimitry Andric ~__widen_from_utf8() override; 15940b57cec5SDimitry Andric 15950b57cec5SDimitry Andric template <class _OutputIterator> 15960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 15970b57cec5SDimitry Andric _OutputIterator 15980b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const 15990b57cec5SDimitry Andric { 16000b57cec5SDimitry Andric result __r = ok; 16010b57cec5SDimitry Andric mbstate_t __mb; 16020b57cec5SDimitry Andric while (__nb < __ne && __r != error) 16030b57cec5SDimitry Andric { 16040b57cec5SDimitry Andric const int __sz = 32; 16050b57cec5SDimitry Andric char16_t __buf[__sz]; 16060b57cec5SDimitry Andric char16_t* __bn; 16070b57cec5SDimitry Andric const char* __nn = __nb; 16080b57cec5SDimitry Andric __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, 16090b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 16100b57cec5SDimitry Andric if (__r == codecvt_base::error || __nn == __nb) 16110b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 16120b57cec5SDimitry Andric for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) 1613e8d8bef9SDimitry Andric *__s = *__p; 16140b57cec5SDimitry Andric __nb = __nn; 16150b57cec5SDimitry Andric } 16160b57cec5SDimitry Andric return __s; 16170b57cec5SDimitry Andric } 16180b57cec5SDimitry Andric}; 16190b57cec5SDimitry Andric 1620e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 16210b57cec5SDimitry Andrictemplate <> 1622*06c3fb27SDimitry Andricstruct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> 16230b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 16240b57cec5SDimitry Andric{ 16250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16260b57cec5SDimitry Andric __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {} 1627e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 16280b57cec5SDimitry Andric 1629bdd1243dSDimitry Andric ~__widen_from_utf8() override; 16300b57cec5SDimitry Andric 16310b57cec5SDimitry Andric template <class _OutputIterator> 16320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 16330b57cec5SDimitry Andric _OutputIterator 16340b57cec5SDimitry Andric operator()(_OutputIterator __s, const char* __nb, const char* __ne) const 16350b57cec5SDimitry Andric { 16360b57cec5SDimitry Andric result __r = ok; 16370b57cec5SDimitry Andric mbstate_t __mb; 16380b57cec5SDimitry Andric while (__nb < __ne && __r != error) 16390b57cec5SDimitry Andric { 16400b57cec5SDimitry Andric const int __sz = 32; 16410b57cec5SDimitry Andric char32_t __buf[__sz]; 16420b57cec5SDimitry Andric char32_t* __bn; 16430b57cec5SDimitry Andric const char* __nn = __nb; 16440b57cec5SDimitry Andric __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, 16450b57cec5SDimitry Andric __buf, __buf+__sz, __bn); 16460b57cec5SDimitry Andric if (__r == codecvt_base::error || __nn == __nb) 16470b57cec5SDimitry Andric __throw_runtime_error("locale not supported"); 16480b57cec5SDimitry Andric for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) 1649e8d8bef9SDimitry Andric *__s = *__p; 16500b57cec5SDimitry Andric __nb = __nn; 16510b57cec5SDimitry Andric } 16520b57cec5SDimitry Andric return __s; 16530b57cec5SDimitry Andric } 16540b57cec5SDimitry Andric}; 16550b57cec5SDimitry Andric 16560b57cec5SDimitry Andric// template <class charT> class numpunct 16570b57cec5SDimitry Andric 16580b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct; 16590b57cec5SDimitry Andric 16600b57cec5SDimitry Andrictemplate <> 1661*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct<char> 16620b57cec5SDimitry Andric : public locale::facet 16630b57cec5SDimitry Andric{ 16640b57cec5SDimitry Andricpublic: 16650b57cec5SDimitry Andric typedef char char_type; 16660b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 16670b57cec5SDimitry Andric 16680b57cec5SDimitry Andric explicit numpunct(size_t __refs = 0); 16690b57cec5SDimitry Andric 16700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();} 16710b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();} 16720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();} 16730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();} 16740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();} 16750b57cec5SDimitry Andric 16760b57cec5SDimitry Andric static locale::id id; 16770b57cec5SDimitry Andric 16780b57cec5SDimitry Andricprotected: 1679bdd1243dSDimitry Andric ~numpunct() override; 16800b57cec5SDimitry Andric virtual char_type do_decimal_point() const; 16810b57cec5SDimitry Andric virtual char_type do_thousands_sep() const; 16820b57cec5SDimitry Andric virtual string do_grouping() const; 16830b57cec5SDimitry Andric virtual string_type do_truename() const; 16840b57cec5SDimitry Andric virtual string_type do_falsename() const; 16850b57cec5SDimitry Andric 16860b57cec5SDimitry Andric char_type __decimal_point_; 16870b57cec5SDimitry Andric char_type __thousands_sep_; 16880b57cec5SDimitry Andric string __grouping_; 16890b57cec5SDimitry Andric}; 16900b57cec5SDimitry Andric 1691349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 16920b57cec5SDimitry Andrictemplate <> 1693*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> 16940b57cec5SDimitry Andric : public locale::facet 16950b57cec5SDimitry Andric{ 16960b57cec5SDimitry Andricpublic: 16970b57cec5SDimitry Andric typedef wchar_t char_type; 16980b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 16990b57cec5SDimitry Andric 17000b57cec5SDimitry Andric explicit numpunct(size_t __refs = 0); 17010b57cec5SDimitry Andric 17020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();} 17030b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();} 17040b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();} 17050b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();} 17060b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();} 17070b57cec5SDimitry Andric 17080b57cec5SDimitry Andric static locale::id id; 17090b57cec5SDimitry Andric 17100b57cec5SDimitry Andricprotected: 1711bdd1243dSDimitry Andric ~numpunct() override; 17120b57cec5SDimitry Andric virtual char_type do_decimal_point() const; 17130b57cec5SDimitry Andric virtual char_type do_thousands_sep() const; 17140b57cec5SDimitry Andric virtual string do_grouping() const; 17150b57cec5SDimitry Andric virtual string_type do_truename() const; 17160b57cec5SDimitry Andric virtual string_type do_falsename() const; 17170b57cec5SDimitry Andric 17180b57cec5SDimitry Andric char_type __decimal_point_; 17190b57cec5SDimitry Andric char_type __thousands_sep_; 17200b57cec5SDimitry Andric string __grouping_; 17210b57cec5SDimitry Andric}; 1722349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 17230b57cec5SDimitry Andric 17240b57cec5SDimitry Andric// template <class charT> class numpunct_byname 17250b57cec5SDimitry Andric 17260b57cec5SDimitry Andrictemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname; 17270b57cec5SDimitry Andric 17280b57cec5SDimitry Andrictemplate <> 1729*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> 17300b57cec5SDimitry Andric: public numpunct<char> 17310b57cec5SDimitry Andric{ 17320b57cec5SDimitry Andricpublic: 17330b57cec5SDimitry Andric typedef char char_type; 17340b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 17350b57cec5SDimitry Andric 17360b57cec5SDimitry Andric explicit numpunct_byname(const char* __nm, size_t __refs = 0); 17370b57cec5SDimitry Andric explicit numpunct_byname(const string& __nm, size_t __refs = 0); 17380b57cec5SDimitry Andric 17390b57cec5SDimitry Andricprotected: 1740bdd1243dSDimitry Andric ~numpunct_byname() override; 17410b57cec5SDimitry Andric 17420b57cec5SDimitry Andricprivate: 17430b57cec5SDimitry Andric void __init(const char*); 17440b57cec5SDimitry Andric}; 17450b57cec5SDimitry Andric 1746349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 17470b57cec5SDimitry Andrictemplate <> 1748*06c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> 17490b57cec5SDimitry Andric: public numpunct<wchar_t> 17500b57cec5SDimitry Andric{ 17510b57cec5SDimitry Andricpublic: 17520b57cec5SDimitry Andric typedef wchar_t char_type; 17530b57cec5SDimitry Andric typedef basic_string<char_type> string_type; 17540b57cec5SDimitry Andric 17550b57cec5SDimitry Andric explicit numpunct_byname(const char* __nm, size_t __refs = 0); 17560b57cec5SDimitry Andric explicit numpunct_byname(const string& __nm, size_t __refs = 0); 17570b57cec5SDimitry Andric 17580b57cec5SDimitry Andricprotected: 1759bdd1243dSDimitry Andric ~numpunct_byname() override; 17600b57cec5SDimitry Andric 17610b57cec5SDimitry Andricprivate: 17620b57cec5SDimitry Andric void __init(const char*); 17630b57cec5SDimitry Andric}; 1764349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 17650b57cec5SDimitry Andric 17660b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 17670b57cec5SDimitry Andric 17680b57cec5SDimitry Andric#endif // _LIBCPP___LOCALE 1769