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 660b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 670b57cec5SDimitry Andric 6881ad6265SDimitry Andricenum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode 690b57cec5SDimitry Andric{ 700b57cec5SDimitry Andric consume_header = 4, 710b57cec5SDimitry Andric generate_header = 2, 720b57cec5SDimitry Andric little_endian = 1 730b57cec5SDimitry Andric}; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric// codecvt_utf8 760b57cec5SDimitry Andric 770b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8; 780b57cec5SDimitry Andric 79349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 800b57cec5SDimitry Andrictemplate <> 810b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t> 820b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 830b57cec5SDimitry Andric{ 84*bdd1243dSDimitry Andric unsigned long __maxcode_; 8581ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 86*bdd1243dSDimitry Andric codecvt_mode __mode_; 8781ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 880b57cec5SDimitry Andricpublic: 890b57cec5SDimitry Andric typedef wchar_t intern_type; 900b57cec5SDimitry Andric typedef char extern_type; 910b57cec5SDimitry Andric typedef mbstate_t state_type; 920b57cec5SDimitry Andric 9381ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 940b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 95753f127fSDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, 96753f127fSDimitry Andric codecvt_mode __mode) 97*bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 98*bdd1243dSDimitry Andric __mode_(__mode) {} 9981ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 1000b57cec5SDimitry Andricprotected: 101*bdd1243dSDimitry Andric result do_out(state_type& __st, 1020b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 103*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 104*bdd1243dSDimitry Andric result do_in(state_type& __st, 1050b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 106*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 107*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 108*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 109*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 110*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 111*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 112*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 1130b57cec5SDimitry Andric}; 114349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 1150b57cec5SDimitry Andric 116e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1170b57cec5SDimitry Andrictemplate <> 1180b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t> 1190b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 1200b57cec5SDimitry Andric{ 121*bdd1243dSDimitry Andric unsigned long __maxcode_; 122*bdd1243dSDimitry Andric codecvt_mode __mode_; 1230b57cec5SDimitry Andricpublic: 1240b57cec5SDimitry Andric typedef char16_t intern_type; 1250b57cec5SDimitry Andric typedef char extern_type; 1260b57cec5SDimitry Andric typedef mbstate_t state_type; 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 129753f127fSDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, 130753f127fSDimitry Andric codecvt_mode __mode) 131*bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 132*bdd1243dSDimitry Andric __mode_(__mode) {} 133e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 134e8d8bef9SDimitry Andric 1350b57cec5SDimitry Andricprotected: 136*bdd1243dSDimitry Andric result do_out(state_type& __st, 1370b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 138*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 139*bdd1243dSDimitry Andric result do_in(state_type& __st, 1400b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 141*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 142*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 143*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 144*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 145*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 146*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 147*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 1480b57cec5SDimitry Andric}; 1490b57cec5SDimitry Andric 150e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1510b57cec5SDimitry Andrictemplate <> 1520b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t> 1530b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 1540b57cec5SDimitry Andric{ 155*bdd1243dSDimitry Andric unsigned long __maxcode_; 156*bdd1243dSDimitry Andric codecvt_mode __mode_; 1570b57cec5SDimitry Andricpublic: 1580b57cec5SDimitry Andric typedef char32_t intern_type; 1590b57cec5SDimitry Andric typedef char extern_type; 1600b57cec5SDimitry Andric typedef mbstate_t state_type; 1610b57cec5SDimitry Andric 1620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 163753f127fSDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, 164753f127fSDimitry Andric codecvt_mode __mode) 165*bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 166*bdd1243dSDimitry Andric __mode_(__mode) {} 167e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 168e8d8bef9SDimitry Andric 1690b57cec5SDimitry Andricprotected: 170*bdd1243dSDimitry Andric result do_out(state_type& __st, 1710b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 172*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 173*bdd1243dSDimitry Andric result do_in(state_type& __st, 1740b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 175*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 176*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 177*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 178*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 179*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 180*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 181*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 1820b57cec5SDimitry Andric}; 1830b57cec5SDimitry Andric 18481ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1850b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 1860b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 18781ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 1880b57cec5SDimitry Andric : public __codecvt_utf8<_Elem> 1890b57cec5SDimitry Andric{ 1900b57cec5SDimitry Andricpublic: 1910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1920b57cec5SDimitry Andric explicit codecvt_utf8(size_t __refs = 0) 1930b57cec5SDimitry Andric : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {} 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1960b57cec5SDimitry Andric ~codecvt_utf8() {} 1970b57cec5SDimitry Andric}; 19881ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 1990b57cec5SDimitry Andric 2000b57cec5SDimitry Andric// codecvt_utf16 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andrictemplate <class _Elem, bool _LittleEndian> class __codecvt_utf16; 2030b57cec5SDimitry Andric 204349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 2050b57cec5SDimitry Andrictemplate <> 2060b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false> 2070b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 2080b57cec5SDimitry Andric{ 209*bdd1243dSDimitry Andric unsigned long __maxcode_; 21081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 211*bdd1243dSDimitry Andric codecvt_mode __mode_; 21281ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2130b57cec5SDimitry Andricpublic: 2140b57cec5SDimitry Andric typedef wchar_t intern_type; 2150b57cec5SDimitry Andric typedef char extern_type; 2160b57cec5SDimitry Andric typedef mbstate_t state_type; 2170b57cec5SDimitry Andric 21881ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 2190b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 220753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 221753f127fSDimitry Andric codecvt_mode __mode) 222*bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 223*bdd1243dSDimitry Andric __mode_(__mode) {} 22481ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2250b57cec5SDimitry Andricprotected: 226*bdd1243dSDimitry Andric result do_out(state_type& __st, 2270b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 228*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 229*bdd1243dSDimitry Andric result do_in(state_type& __st, 2300b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 231*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 232*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 233*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 234*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 235*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 236*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 237*bdd1243dSDimitry Andric size_t __mx) const override; 238*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 2390b57cec5SDimitry Andric}; 2400b57cec5SDimitry Andric 2410b57cec5SDimitry Andrictemplate <> 2420b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true> 2430b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 2440b57cec5SDimitry Andric{ 245*bdd1243dSDimitry Andric unsigned long __maxcode_; 24681ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 247*bdd1243dSDimitry Andric codecvt_mode __mode_; 24881ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2490b57cec5SDimitry Andricpublic: 2500b57cec5SDimitry Andric typedef wchar_t intern_type; 2510b57cec5SDimitry Andric typedef char extern_type; 2520b57cec5SDimitry Andric typedef mbstate_t state_type; 2530b57cec5SDimitry Andric 25481ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 2550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 256753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 257753f127fSDimitry Andric codecvt_mode __mode) 258*bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 259*bdd1243dSDimitry Andric __mode_(__mode) {} 26081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 2610b57cec5SDimitry Andricprotected: 262*bdd1243dSDimitry Andric result do_out(state_type& __st, 2630b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 264*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 265*bdd1243dSDimitry Andric result do_in(state_type& __st, 2660b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 267*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 268*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 269*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 270*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 271*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 272*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 273*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 2740b57cec5SDimitry Andric}; 275349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 2760b57cec5SDimitry Andric 277e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 2780b57cec5SDimitry Andrictemplate <> 2790b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false> 2800b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 2810b57cec5SDimitry Andric{ 282*bdd1243dSDimitry Andric unsigned long __maxcode_; 283*bdd1243dSDimitry Andric codecvt_mode __mode_; 2840b57cec5SDimitry Andricpublic: 2850b57cec5SDimitry Andric typedef char16_t intern_type; 2860b57cec5SDimitry Andric typedef char extern_type; 2870b57cec5SDimitry Andric typedef mbstate_t state_type; 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 290753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 291753f127fSDimitry Andric codecvt_mode __mode) 292*bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 293*bdd1243dSDimitry Andric __mode_(__mode) {} 294e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 295e8d8bef9SDimitry Andric 2960b57cec5SDimitry Andricprotected: 297*bdd1243dSDimitry Andric result do_out(state_type& __st, 2980b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 299*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 300*bdd1243dSDimitry Andric result do_in(state_type& __st, 3010b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 302*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 303*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 304*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 305*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 306*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 307*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 308*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 3090b57cec5SDimitry Andric}; 3100b57cec5SDimitry Andric 311e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3120b57cec5SDimitry Andrictemplate <> 3130b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true> 3140b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 3150b57cec5SDimitry Andric{ 316*bdd1243dSDimitry Andric unsigned long __maxcode_; 317*bdd1243dSDimitry Andric codecvt_mode __mode_; 3180b57cec5SDimitry Andricpublic: 3190b57cec5SDimitry Andric typedef char16_t intern_type; 3200b57cec5SDimitry Andric typedef char extern_type; 3210b57cec5SDimitry Andric typedef mbstate_t state_type; 3220b57cec5SDimitry Andric 3230b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 324753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 325753f127fSDimitry Andric codecvt_mode __mode) 326*bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 327*bdd1243dSDimitry Andric __mode_(__mode) {} 328e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 329e8d8bef9SDimitry Andric 3300b57cec5SDimitry Andricprotected: 331*bdd1243dSDimitry Andric result do_out(state_type& __st, 3320b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 333*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 334*bdd1243dSDimitry Andric result do_in(state_type& __st, 3350b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 336*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 337*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 338*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 339*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 340*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 341*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 342*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 3430b57cec5SDimitry Andric}; 3440b57cec5SDimitry Andric 345e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3460b57cec5SDimitry Andrictemplate <> 3470b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false> 3480b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 3490b57cec5SDimitry Andric{ 350*bdd1243dSDimitry Andric unsigned long __maxcode_; 351*bdd1243dSDimitry Andric codecvt_mode __mode_; 3520b57cec5SDimitry Andricpublic: 3530b57cec5SDimitry Andric typedef char32_t intern_type; 3540b57cec5SDimitry Andric typedef char extern_type; 3550b57cec5SDimitry Andric typedef mbstate_t state_type; 3560b57cec5SDimitry Andric 3570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 358753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 359753f127fSDimitry Andric codecvt_mode __mode) 360*bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 361*bdd1243dSDimitry Andric __mode_(__mode) {} 362e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 363e8d8bef9SDimitry Andric 3640b57cec5SDimitry Andricprotected: 365*bdd1243dSDimitry Andric result do_out(state_type& __st, 3660b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 367*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 368*bdd1243dSDimitry Andric result do_in(state_type& __st, 3690b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 370*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 371*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 372*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 373*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 374*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 375*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 376*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 3770b57cec5SDimitry Andric}; 3780b57cec5SDimitry Andric 379e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3800b57cec5SDimitry Andrictemplate <> 3810b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true> 3820b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 3830b57cec5SDimitry Andric{ 384*bdd1243dSDimitry Andric unsigned long __maxcode_; 385*bdd1243dSDimitry Andric codecvt_mode __mode_; 3860b57cec5SDimitry Andricpublic: 3870b57cec5SDimitry Andric typedef char32_t intern_type; 3880b57cec5SDimitry Andric typedef char extern_type; 3890b57cec5SDimitry Andric typedef mbstate_t state_type; 3900b57cec5SDimitry Andric 3910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 392753f127fSDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, 393753f127fSDimitry Andric codecvt_mode __mode) 394*bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 395*bdd1243dSDimitry Andric __mode_(__mode) {} 396e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 397e8d8bef9SDimitry Andric 3980b57cec5SDimitry Andricprotected: 399*bdd1243dSDimitry Andric result do_out(state_type& __st, 4000b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 401*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 402*bdd1243dSDimitry Andric result do_in(state_type& __st, 4030b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 404*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 405*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 406*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 407*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 408*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 409*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 410*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 4110b57cec5SDimitry Andric}; 4120b57cec5SDimitry Andric 41381ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 4140b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 4150b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 41681ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 4170b57cec5SDimitry Andric : public __codecvt_utf16<_Elem, _Mode & little_endian> 4180b57cec5SDimitry Andric{ 4190b57cec5SDimitry Andricpublic: 4200b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4210b57cec5SDimitry Andric explicit codecvt_utf16(size_t __refs = 0) 4220b57cec5SDimitry Andric : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} 4230b57cec5SDimitry Andric 4240b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4250b57cec5SDimitry Andric ~codecvt_utf16() {} 4260b57cec5SDimitry Andric}; 42781ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 4280b57cec5SDimitry Andric 4290b57cec5SDimitry Andric// codecvt_utf8_utf16 4300b57cec5SDimitry Andric 4310b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8_utf16; 4320b57cec5SDimitry Andric 433349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 4340b57cec5SDimitry Andrictemplate <> 4350b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t> 4360b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 4370b57cec5SDimitry Andric{ 438*bdd1243dSDimitry Andric unsigned long __maxcode_; 43981ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 440*bdd1243dSDimitry Andric codecvt_mode __mode_; 44181ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 4420b57cec5SDimitry Andricpublic: 4430b57cec5SDimitry Andric typedef wchar_t intern_type; 4440b57cec5SDimitry Andric typedef char extern_type; 4450b57cec5SDimitry Andric typedef mbstate_t state_type; 4460b57cec5SDimitry Andric 44781ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 4480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 449753f127fSDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, 450753f127fSDimitry Andric codecvt_mode __mode) 451*bdd1243dSDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 452*bdd1243dSDimitry Andric __mode_(__mode) {} 45381ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 4540b57cec5SDimitry Andricprotected: 455*bdd1243dSDimitry Andric result do_out(state_type& __st, 4560b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 457*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 458*bdd1243dSDimitry Andric result do_in(state_type& __st, 4590b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 460*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 461*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 462*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 463*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 464*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 465*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 466*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 4670b57cec5SDimitry Andric}; 468349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 4690b57cec5SDimitry Andric 470e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 4710b57cec5SDimitry Andrictemplate <> 4720b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t> 4730b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 4740b57cec5SDimitry Andric{ 475*bdd1243dSDimitry Andric unsigned long __maxcode_; 476*bdd1243dSDimitry Andric codecvt_mode __mode_; 4770b57cec5SDimitry Andricpublic: 4780b57cec5SDimitry Andric typedef char32_t intern_type; 4790b57cec5SDimitry Andric typedef char extern_type; 4800b57cec5SDimitry Andric typedef mbstate_t state_type; 4810b57cec5SDimitry Andric 4820b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 483753f127fSDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, 484753f127fSDimitry Andric codecvt_mode __mode) 485*bdd1243dSDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 486*bdd1243dSDimitry Andric __mode_(__mode) {} 487e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 488e8d8bef9SDimitry Andric 4890b57cec5SDimitry Andricprotected: 490*bdd1243dSDimitry Andric result do_out(state_type& __st, 4910b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 492*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 493*bdd1243dSDimitry Andric result do_in(state_type& __st, 4940b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 495*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 496*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 497*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 498*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 499*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 500*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 501*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 5020b57cec5SDimitry Andric}; 5030b57cec5SDimitry Andric 504e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 5050b57cec5SDimitry Andrictemplate <> 5060b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t> 5070b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 5080b57cec5SDimitry Andric{ 509*bdd1243dSDimitry Andric unsigned long __maxcode_; 510*bdd1243dSDimitry Andric codecvt_mode __mode_; 5110b57cec5SDimitry Andricpublic: 5120b57cec5SDimitry Andric typedef char16_t intern_type; 5130b57cec5SDimitry Andric typedef char extern_type; 5140b57cec5SDimitry Andric typedef mbstate_t state_type; 5150b57cec5SDimitry Andric 5160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 517753f127fSDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, 518753f127fSDimitry Andric codecvt_mode __mode) 519*bdd1243dSDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), 520*bdd1243dSDimitry Andric __mode_(__mode) {} 521e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 522e8d8bef9SDimitry Andric 5230b57cec5SDimitry Andricprotected: 524*bdd1243dSDimitry Andric result do_out(state_type& __st, 5250b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 526*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 527*bdd1243dSDimitry Andric result do_in(state_type& __st, 5280b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 529*bdd1243dSDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override; 530*bdd1243dSDimitry Andric result do_unshift(state_type& __st, 531*bdd1243dSDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override; 532*bdd1243dSDimitry Andric int do_encoding() const _NOEXCEPT override; 533*bdd1243dSDimitry Andric bool do_always_noconv() const _NOEXCEPT override; 534*bdd1243dSDimitry Andric int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; 535*bdd1243dSDimitry Andric int do_max_length() const _NOEXCEPT override; 5360b57cec5SDimitry Andric}; 5370b57cec5SDimitry Andric 53881ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 5390b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 5400b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 54181ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 5420b57cec5SDimitry Andric : public __codecvt_utf8_utf16<_Elem> 5430b57cec5SDimitry Andric{ 5440b57cec5SDimitry Andricpublic: 5450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5460b57cec5SDimitry Andric explicit codecvt_utf8_utf16(size_t __refs = 0) 5470b57cec5SDimitry Andric : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {} 5480b57cec5SDimitry Andric 5490b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5500b57cec5SDimitry Andric ~codecvt_utf8_utf16() {} 5510b57cec5SDimitry Andric}; 55281ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 5530b57cec5SDimitry Andric 5540b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 5550b57cec5SDimitry Andric 556*bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 557*bdd1243dSDimitry Andric# include <atomic> 558*bdd1243dSDimitry Andric# include <concepts> 559*bdd1243dSDimitry Andric# include <cstddef> 560*bdd1243dSDimitry Andric# include <cstdlib> 561*bdd1243dSDimitry Andric# include <cstring> 562*bdd1243dSDimitry Andric# include <initializer_list> 563*bdd1243dSDimitry Andric# include <iosfwd> 564*bdd1243dSDimitry Andric# include <limits> 565*bdd1243dSDimitry Andric# include <new> 566*bdd1243dSDimitry Andric# include <stdexcept> 567*bdd1243dSDimitry Andric# include <type_traits> 568*bdd1243dSDimitry Andric# include <typeinfo> 569*bdd1243dSDimitry Andric#endif 570*bdd1243dSDimitry Andric 5710b57cec5SDimitry Andric#endif // _LIBCPP_CODECVT 572