10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry 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_CODECVT 110b57cec5SDimitry Andric#define _LIBCPP_CODECVT 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric codecvt synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std 170b57cec5SDimitry Andric{ 180b57cec5SDimitry Andric 190b57cec5SDimitry Andricenum codecvt_mode 200b57cec5SDimitry Andric{ 210b57cec5SDimitry Andric consume_header = 4, 220b57cec5SDimitry Andric generate_header = 2, 230b57cec5SDimitry Andric little_endian = 1 240b57cec5SDimitry Andric}; 250b57cec5SDimitry Andric 260b57cec5SDimitry Andrictemplate <class Elem, unsigned long Maxcode = 0x10ffff, 270b57cec5SDimitry Andric codecvt_mode Mode = (codecvt_mode)0> 280b57cec5SDimitry Andricclass codecvt_utf8 290b57cec5SDimitry Andric : public codecvt<Elem, char, mbstate_t> 300b57cec5SDimitry Andric{ 310b57cec5SDimitry Andric explicit codecvt_utf8(size_t refs = 0); 320b57cec5SDimitry Andric ~codecvt_utf8(); 330b57cec5SDimitry Andric}; 340b57cec5SDimitry Andric 350b57cec5SDimitry Andrictemplate <class Elem, unsigned long Maxcode = 0x10ffff, 360b57cec5SDimitry Andric codecvt_mode Mode = (codecvt_mode)0> 370b57cec5SDimitry Andricclass codecvt_utf16 380b57cec5SDimitry Andric : public codecvt<Elem, char, mbstate_t> 390b57cec5SDimitry Andric{ 400b57cec5SDimitry Andric explicit codecvt_utf16(size_t refs = 0); 410b57cec5SDimitry Andric ~codecvt_utf16(); 420b57cec5SDimitry Andric}; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andrictemplate <class Elem, unsigned long Maxcode = 0x10ffff, 450b57cec5SDimitry Andric codecvt_mode Mode = (codecvt_mode)0> 460b57cec5SDimitry Andricclass codecvt_utf8_utf16 470b57cec5SDimitry Andric : public codecvt<Elem, char, mbstate_t> 480b57cec5SDimitry Andric{ 490b57cec5SDimitry Andric explicit codecvt_utf8_utf16(size_t refs = 0); 500b57cec5SDimitry Andric ~codecvt_utf8_utf16(); 510b57cec5SDimitry Andric}; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric} // std 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric*/ 560b57cec5SDimitry Andric 5781ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 580b57cec5SDimitry Andric#include <__config> 590b57cec5SDimitry Andric#include <__locale> 6004eeddc0SDimitry Andric#include <version> 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 630b57cec5SDimitry Andric# pragma GCC system_header 640b57cec5SDimitry Andric#endif 650b57cec5SDimitry Andric 66*5f757f3fSDimitry Andric#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) 67*5f757f3fSDimitry Andric 680b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 690b57cec5SDimitry Andric 7081ad6265SDimitry Andricenum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode 710b57cec5SDimitry Andric{ 720b57cec5SDimitry Andric consume_header = 4, 730b57cec5SDimitry Andric generate_header = 2, 740b57cec5SDimitry Andric little_endian = 1 750b57cec5SDimitry Andric}; 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric// codecvt_utf8 780b57cec5SDimitry Andric 790b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8; 800b57cec5SDimitry Andric 81349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 820b57cec5SDimitry Andrictemplate <> 8306c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> 840b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 850b57cec5SDimitry Andric{ 86bdd1243dSDimitry Andric unsigned long __maxcode_; 8781ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 88bdd1243dSDimitry Andric codecvt_mode __mode_; 8981ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 900b57cec5SDimitry Andricpublic: 910b57cec5SDimitry Andric typedef wchar_t intern_type; 920b57cec5SDimitry Andric typedef char extern_type; 930b57cec5SDimitry Andric typedef mbstate_t state_type; 940b57cec5SDimitry Andric 9581ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 96*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 97753f127fSDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, 98753f127fSDimitry Andric codecvt_mode __mode) 99bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 100bdd1243dSDimitry Andric __mode_(__mode) {} 10181ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 1020b57cec5SDimitry Andricprotected: 103bdd1243dSDimitry Andric result do_out(state_type& __st, 1040b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 105bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 106bdd1243dSDimitry Andric result do_in(state_type& __st, 1070b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 108bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 109bdd1243dSDimitry Andric result do_unshift(state_type& __st, 110bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 111bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 112bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 113bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 114bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 1150b57cec5SDimitry Andric}; 116349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 1170b57cec5SDimitry Andric 118e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1190b57cec5SDimitry Andrictemplate <> 12006c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<char16_t> 1210b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 1220b57cec5SDimitry Andric{ 123bdd1243dSDimitry Andric unsigned long __maxcode_; 124bdd1243dSDimitry Andric codecvt_mode __mode_; 1250b57cec5SDimitry Andricpublic: 1260b57cec5SDimitry Andric typedef char16_t intern_type; 1270b57cec5SDimitry Andric typedef char extern_type; 1280b57cec5SDimitry Andric typedef mbstate_t state_type; 1290b57cec5SDimitry Andric 130*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 131753f127fSDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, 132753f127fSDimitry Andric codecvt_mode __mode) 133bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 134bdd1243dSDimitry Andric __mode_(__mode) {} 135e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 136e8d8bef9SDimitry Andric 1370b57cec5SDimitry Andricprotected: 138bdd1243dSDimitry Andric result do_out(state_type& __st, 1390b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 140bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 141bdd1243dSDimitry Andric result do_in(state_type& __st, 1420b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 143bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 144bdd1243dSDimitry Andric result do_unshift(state_type& __st, 145bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 146bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 147bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 148bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 149bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 1500b57cec5SDimitry Andric}; 1510b57cec5SDimitry Andric 152e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1530b57cec5SDimitry Andrictemplate <> 15406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<char32_t> 1550b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 1560b57cec5SDimitry Andric{ 157bdd1243dSDimitry Andric unsigned long __maxcode_; 158bdd1243dSDimitry Andric codecvt_mode __mode_; 1590b57cec5SDimitry Andricpublic: 1600b57cec5SDimitry Andric typedef char32_t intern_type; 1610b57cec5SDimitry Andric typedef char extern_type; 1620b57cec5SDimitry Andric typedef mbstate_t state_type; 1630b57cec5SDimitry Andric 164*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 165753f127fSDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, 166753f127fSDimitry Andric codecvt_mode __mode) 167bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 168bdd1243dSDimitry Andric __mode_(__mode) {} 169e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 170e8d8bef9SDimitry Andric 1710b57cec5SDimitry Andricprotected: 172bdd1243dSDimitry Andric result do_out(state_type& __st, 1730b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 174bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 175bdd1243dSDimitry Andric result do_in(state_type& __st, 1760b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 177bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 178bdd1243dSDimitry Andric result do_unshift(state_type& __st, 179bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 180bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 181bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 182bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 183bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 1840b57cec5SDimitry Andric}; 1850b57cec5SDimitry Andric 18681ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1870b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 1880b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 18981ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 1900b57cec5SDimitry Andric : public __codecvt_utf8<_Elem> 1910b57cec5SDimitry Andric{ 1920b57cec5SDimitry Andricpublic: 193*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1940b57cec5SDimitry Andric explicit codecvt_utf8(size_t __refs = 0) 1950b57cec5SDimitry Andric : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {} 1960b57cec5SDimitry Andric 197*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 1980b57cec5SDimitry Andric ~codecvt_utf8() {} 1990b57cec5SDimitry Andric}; 20081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric// codecvt_utf16 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andrictemplate <class _Elem, bool _LittleEndian> class __codecvt_utf16; 2050b57cec5SDimitry Andric 206349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 2070b57cec5SDimitry Andrictemplate <> 20806c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> 2090b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 2100b57cec5SDimitry Andric{ 211bdd1243dSDimitry Andric unsigned long __maxcode_; 21281ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 213bdd1243dSDimitry Andric codecvt_mode __mode_; 21481ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2150b57cec5SDimitry Andricpublic: 2160b57cec5SDimitry Andric typedef wchar_t intern_type; 2170b57cec5SDimitry Andric typedef char extern_type; 2180b57cec5SDimitry Andric typedef mbstate_t state_type; 2190b57cec5SDimitry Andric 22081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 221*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 222753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 223753f127fSDimitry Andric codecvt_mode __mode) 224bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 225bdd1243dSDimitry Andric __mode_(__mode) {} 22681ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2270b57cec5SDimitry Andricprotected: 228bdd1243dSDimitry Andric result do_out(state_type& __st, 2290b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 230bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 231bdd1243dSDimitry Andric result do_in(state_type& __st, 2320b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 233bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 234bdd1243dSDimitry Andric result do_unshift(state_type& __st, 235bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 236bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 237bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 238bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 239bdd1243dSDimitry Andric size_t __mx) const override; 240bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 2410b57cec5SDimitry Andric}; 2420b57cec5SDimitry Andric 2430b57cec5SDimitry Andrictemplate <> 24406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, true> 2450b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 2460b57cec5SDimitry Andric{ 247bdd1243dSDimitry Andric unsigned long __maxcode_; 24881ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 249bdd1243dSDimitry Andric codecvt_mode __mode_; 25081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2510b57cec5SDimitry Andricpublic: 2520b57cec5SDimitry Andric typedef wchar_t intern_type; 2530b57cec5SDimitry Andric typedef char extern_type; 2540b57cec5SDimitry Andric typedef mbstate_t state_type; 2550b57cec5SDimitry Andric 25681ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 257*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 258753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 259753f127fSDimitry Andric codecvt_mode __mode) 260bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 261bdd1243dSDimitry Andric __mode_(__mode) {} 26281ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2630b57cec5SDimitry Andricprotected: 264bdd1243dSDimitry Andric result do_out(state_type& __st, 2650b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 266bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 267bdd1243dSDimitry Andric result do_in(state_type& __st, 2680b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 269bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 270bdd1243dSDimitry Andric result do_unshift(state_type& __st, 271bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 272bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 273bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 274bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 275bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 2760b57cec5SDimitry Andric}; 277349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 2780b57cec5SDimitry Andric 279e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 2800b57cec5SDimitry Andrictemplate <> 28106c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char16_t, false> 2820b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 2830b57cec5SDimitry Andric{ 284bdd1243dSDimitry Andric unsigned long __maxcode_; 285bdd1243dSDimitry Andric codecvt_mode __mode_; 2860b57cec5SDimitry Andricpublic: 2870b57cec5SDimitry Andric typedef char16_t intern_type; 2880b57cec5SDimitry Andric typedef char extern_type; 2890b57cec5SDimitry Andric typedef mbstate_t state_type; 2900b57cec5SDimitry Andric 291*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 292753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 293753f127fSDimitry Andric codecvt_mode __mode) 294bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 295bdd1243dSDimitry Andric __mode_(__mode) {} 296e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 297e8d8bef9SDimitry Andric 2980b57cec5SDimitry Andricprotected: 299bdd1243dSDimitry Andric result do_out(state_type& __st, 3000b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 301bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 302bdd1243dSDimitry Andric result do_in(state_type& __st, 3030b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 304bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 305bdd1243dSDimitry Andric result do_unshift(state_type& __st, 306bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 307bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 308bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 309bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 310bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 3110b57cec5SDimitry Andric}; 3120b57cec5SDimitry Andric 313e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3140b57cec5SDimitry Andrictemplate <> 31506c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char16_t, true> 3160b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 3170b57cec5SDimitry Andric{ 318bdd1243dSDimitry Andric unsigned long __maxcode_; 319bdd1243dSDimitry Andric codecvt_mode __mode_; 3200b57cec5SDimitry Andricpublic: 3210b57cec5SDimitry Andric typedef char16_t intern_type; 3220b57cec5SDimitry Andric typedef char extern_type; 3230b57cec5SDimitry Andric typedef mbstate_t state_type; 3240b57cec5SDimitry Andric 325*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 326753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 327753f127fSDimitry Andric codecvt_mode __mode) 328bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 329bdd1243dSDimitry Andric __mode_(__mode) {} 330e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 331e8d8bef9SDimitry Andric 3320b57cec5SDimitry Andricprotected: 333bdd1243dSDimitry Andric result do_out(state_type& __st, 3340b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 335bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 336bdd1243dSDimitry Andric result do_in(state_type& __st, 3370b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 338bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 339bdd1243dSDimitry Andric result do_unshift(state_type& __st, 340bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 341bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 342bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 343bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 344bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 3450b57cec5SDimitry Andric}; 3460b57cec5SDimitry Andric 347e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3480b57cec5SDimitry Andrictemplate <> 34906c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char32_t, false> 3500b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 3510b57cec5SDimitry Andric{ 352bdd1243dSDimitry Andric unsigned long __maxcode_; 353bdd1243dSDimitry Andric codecvt_mode __mode_; 3540b57cec5SDimitry Andricpublic: 3550b57cec5SDimitry Andric typedef char32_t intern_type; 3560b57cec5SDimitry Andric typedef char extern_type; 3570b57cec5SDimitry Andric typedef mbstate_t state_type; 3580b57cec5SDimitry Andric 359*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 360753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 361753f127fSDimitry Andric codecvt_mode __mode) 362bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 363bdd1243dSDimitry Andric __mode_(__mode) {} 364e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 365e8d8bef9SDimitry Andric 3660b57cec5SDimitry Andricprotected: 367bdd1243dSDimitry Andric result do_out(state_type& __st, 3680b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 369bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 370bdd1243dSDimitry Andric result do_in(state_type& __st, 3710b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 372bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 373bdd1243dSDimitry Andric result do_unshift(state_type& __st, 374bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 375bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 376bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 377bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 378bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 3790b57cec5SDimitry Andric}; 3800b57cec5SDimitry Andric 381e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3820b57cec5SDimitry Andrictemplate <> 38306c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char32_t, true> 3840b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 3850b57cec5SDimitry Andric{ 386bdd1243dSDimitry Andric unsigned long __maxcode_; 387bdd1243dSDimitry Andric codecvt_mode __mode_; 3880b57cec5SDimitry Andricpublic: 3890b57cec5SDimitry Andric typedef char32_t intern_type; 3900b57cec5SDimitry Andric typedef char extern_type; 3910b57cec5SDimitry Andric typedef mbstate_t state_type; 3920b57cec5SDimitry Andric 393*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 394753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 395753f127fSDimitry Andric codecvt_mode __mode) 396bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 397bdd1243dSDimitry Andric __mode_(__mode) {} 398e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 399e8d8bef9SDimitry Andric 4000b57cec5SDimitry Andricprotected: 401bdd1243dSDimitry Andric result do_out(state_type& __st, 4020b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 403bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 404bdd1243dSDimitry Andric result do_in(state_type& __st, 4050b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 406bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 407bdd1243dSDimitry Andric result do_unshift(state_type& __st, 408bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 409bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 410bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 411bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 412bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 4130b57cec5SDimitry Andric}; 4140b57cec5SDimitry Andric 41581ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 4160b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 4170b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 41881ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 4190b57cec5SDimitry Andric : public __codecvt_utf16<_Elem, _Mode & little_endian> 4200b57cec5SDimitry Andric{ 4210b57cec5SDimitry Andricpublic: 422*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4230b57cec5SDimitry Andric explicit codecvt_utf16(size_t __refs = 0) 4240b57cec5SDimitry Andric : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} 4250b57cec5SDimitry Andric 426*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4270b57cec5SDimitry Andric ~codecvt_utf16() {} 4280b57cec5SDimitry Andric}; 42981ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 4300b57cec5SDimitry Andric 4310b57cec5SDimitry Andric// codecvt_utf8_utf16 4320b57cec5SDimitry Andric 4330b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8_utf16; 4340b57cec5SDimitry Andric 435349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 4360b57cec5SDimitry Andrictemplate <> 43706c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> 4380b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 4390b57cec5SDimitry Andric{ 440bdd1243dSDimitry Andric unsigned long __maxcode_; 44181ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 442bdd1243dSDimitry Andric codecvt_mode __mode_; 44381ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 4440b57cec5SDimitry Andricpublic: 4450b57cec5SDimitry Andric typedef wchar_t intern_type; 4460b57cec5SDimitry Andric typedef char extern_type; 4470b57cec5SDimitry Andric typedef mbstate_t state_type; 4480b57cec5SDimitry Andric 44981ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 450*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 451753f127fSDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, 452753f127fSDimitry Andric codecvt_mode __mode) 453bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 454bdd1243dSDimitry Andric __mode_(__mode) {} 45581ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 4560b57cec5SDimitry Andricprotected: 457bdd1243dSDimitry Andric result do_out(state_type& __st, 4580b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 459bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 460bdd1243dSDimitry Andric result do_in(state_type& __st, 4610b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 462bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 463bdd1243dSDimitry Andric result do_unshift(state_type& __st, 464bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 465bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 466bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 467bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 468bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 4690b57cec5SDimitry Andric}; 470349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 4710b57cec5SDimitry Andric 472e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 4730b57cec5SDimitry Andrictemplate <> 47406c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<char32_t> 4750b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 4760b57cec5SDimitry Andric{ 477bdd1243dSDimitry Andric unsigned long __maxcode_; 478bdd1243dSDimitry Andric codecvt_mode __mode_; 4790b57cec5SDimitry Andricpublic: 4800b57cec5SDimitry Andric typedef char32_t intern_type; 4810b57cec5SDimitry Andric typedef char extern_type; 4820b57cec5SDimitry Andric typedef mbstate_t state_type; 4830b57cec5SDimitry Andric 484*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 485753f127fSDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, 486753f127fSDimitry Andric codecvt_mode __mode) 487bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 488bdd1243dSDimitry Andric __mode_(__mode) {} 489e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 490e8d8bef9SDimitry Andric 4910b57cec5SDimitry Andricprotected: 492bdd1243dSDimitry Andric result do_out(state_type& __st, 4930b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 494bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 495bdd1243dSDimitry Andric result do_in(state_type& __st, 4960b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 497bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 498bdd1243dSDimitry Andric result do_unshift(state_type& __st, 499bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 500bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 501bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 502bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 503bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 5040b57cec5SDimitry Andric}; 5050b57cec5SDimitry Andric 506e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 5070b57cec5SDimitry Andrictemplate <> 50806c3fb27SDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<char16_t> 5090b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 5100b57cec5SDimitry Andric{ 511bdd1243dSDimitry Andric unsigned long __maxcode_; 512bdd1243dSDimitry Andric codecvt_mode __mode_; 5130b57cec5SDimitry Andricpublic: 5140b57cec5SDimitry Andric typedef char16_t intern_type; 5150b57cec5SDimitry Andric typedef char extern_type; 5160b57cec5SDimitry Andric typedef mbstate_t state_type; 5170b57cec5SDimitry Andric 518*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 519753f127fSDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, 520753f127fSDimitry Andric codecvt_mode __mode) 521bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 522bdd1243dSDimitry Andric __mode_(__mode) {} 523e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 524e8d8bef9SDimitry Andric 5250b57cec5SDimitry Andricprotected: 526bdd1243dSDimitry Andric result do_out(state_type& __st, 5270b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 528bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 529bdd1243dSDimitry Andric result do_in(state_type& __st, 5300b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 531bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 532bdd1243dSDimitry Andric result do_unshift(state_type& __st, 533bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 534bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 535bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 536bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 537bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 5380b57cec5SDimitry Andric}; 5390b57cec5SDimitry Andric 54081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 5410b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 5420b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 54381ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 5440b57cec5SDimitry Andric : public __codecvt_utf8_utf16<_Elem> 5450b57cec5SDimitry Andric{ 5460b57cec5SDimitry Andricpublic: 547*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5480b57cec5SDimitry Andric explicit codecvt_utf8_utf16(size_t __refs = 0) 5490b57cec5SDimitry Andric : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {} 5500b57cec5SDimitry Andric 551*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5520b57cec5SDimitry Andric ~codecvt_utf8_utf16() {} 5530b57cec5SDimitry Andric}; 55481ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 5550b57cec5SDimitry Andric 5560b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 5570b57cec5SDimitry Andric 558*5f757f3fSDimitry Andric#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) 559*5f757f3fSDimitry Andric 560bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 561bdd1243dSDimitry Andric# include <atomic> 562bdd1243dSDimitry Andric# include <concepts> 563bdd1243dSDimitry Andric# include <cstddef> 564bdd1243dSDimitry Andric# include <cstdlib> 565bdd1243dSDimitry Andric# include <cstring> 566bdd1243dSDimitry Andric# include <initializer_list> 567bdd1243dSDimitry Andric# include <iosfwd> 568bdd1243dSDimitry Andric# include <limits> 569*5f757f3fSDimitry Andric# include <mutex> 570bdd1243dSDimitry Andric# include <new> 571bdd1243dSDimitry Andric# include <stdexcept> 572bdd1243dSDimitry Andric# include <type_traits> 573bdd1243dSDimitry Andric# include <typeinfo> 574bdd1243dSDimitry Andric#endif 575bdd1243dSDimitry Andric 5760b57cec5SDimitry Andric#endif // _LIBCPP_CODECVT 577