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 570b57cec5SDimitry Andric#include <__config> 580b57cec5SDimitry Andric#include <__locale> 59*04eeddc0SDimitry Andric#include <version> 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 620b57cec5SDimitry Andric#pragma GCC system_header 630b57cec5SDimitry Andric#endif 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 660b57cec5SDimitry Andric 670b57cec5SDimitry Andricenum codecvt_mode 680b57cec5SDimitry Andric{ 690b57cec5SDimitry Andric consume_header = 4, 700b57cec5SDimitry Andric generate_header = 2, 710b57cec5SDimitry Andric little_endian = 1 720b57cec5SDimitry Andric}; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric// codecvt_utf8 750b57cec5SDimitry Andric 760b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8; 770b57cec5SDimitry Andric 78349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 790b57cec5SDimitry Andrictemplate <> 800b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t> 810b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 820b57cec5SDimitry Andric{ 830b57cec5SDimitry Andric unsigned long _Maxcode_; 840b57cec5SDimitry Andric codecvt_mode _Mode_; 850b57cec5SDimitry Andricpublic: 860b57cec5SDimitry Andric typedef wchar_t intern_type; 870b57cec5SDimitry Andric typedef char extern_type; 880b57cec5SDimitry Andric typedef mbstate_t state_type; 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 910b57cec5SDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, 920b57cec5SDimitry Andric codecvt_mode _Mode) 930b57cec5SDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 940b57cec5SDimitry Andric _Mode_(_Mode) {} 950b57cec5SDimitry Andricprotected: 960b57cec5SDimitry Andric virtual result 970b57cec5SDimitry Andric do_out(state_type& __st, 980b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 990b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1000b57cec5SDimitry Andric virtual result 1010b57cec5SDimitry Andric do_in(state_type& __st, 1020b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1030b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1040b57cec5SDimitry Andric virtual result 1050b57cec5SDimitry Andric do_unshift(state_type& __st, 1060b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1079ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1089ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1090b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 1100b57cec5SDimitry Andric size_t __mx) const; 1119ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1120b57cec5SDimitry Andric}; 113349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 1140b57cec5SDimitry Andric 115e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1160b57cec5SDimitry Andrictemplate <> 1170b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t> 1180b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 1190b57cec5SDimitry Andric{ 1200b57cec5SDimitry Andric unsigned long _Maxcode_; 1210b57cec5SDimitry Andric codecvt_mode _Mode_; 1220b57cec5SDimitry Andricpublic: 1230b57cec5SDimitry Andric typedef char16_t intern_type; 1240b57cec5SDimitry Andric typedef char extern_type; 1250b57cec5SDimitry Andric typedef mbstate_t state_type; 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1280b57cec5SDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, 1290b57cec5SDimitry Andric codecvt_mode _Mode) 1300b57cec5SDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 1310b57cec5SDimitry Andric _Mode_(_Mode) {} 132e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 133e8d8bef9SDimitry Andric 1340b57cec5SDimitry Andricprotected: 1350b57cec5SDimitry Andric virtual result 1360b57cec5SDimitry Andric do_out(state_type& __st, 1370b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1380b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1390b57cec5SDimitry Andric virtual result 1400b57cec5SDimitry Andric do_in(state_type& __st, 1410b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1420b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1430b57cec5SDimitry Andric virtual result 1440b57cec5SDimitry Andric do_unshift(state_type& __st, 1450b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1469ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1479ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1480b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 1490b57cec5SDimitry Andric size_t __mx) const; 1509ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1510b57cec5SDimitry Andric}; 1520b57cec5SDimitry Andric 153e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 1540b57cec5SDimitry Andrictemplate <> 1550b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t> 1560b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 1570b57cec5SDimitry Andric{ 1580b57cec5SDimitry Andric unsigned long _Maxcode_; 1590b57cec5SDimitry Andric codecvt_mode _Mode_; 1600b57cec5SDimitry Andricpublic: 1610b57cec5SDimitry Andric typedef char32_t intern_type; 1620b57cec5SDimitry Andric typedef char extern_type; 1630b57cec5SDimitry Andric typedef mbstate_t state_type; 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1660b57cec5SDimitry Andric explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, 1670b57cec5SDimitry Andric codecvt_mode _Mode) 1680b57cec5SDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 1690b57cec5SDimitry Andric _Mode_(_Mode) {} 170e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 171e8d8bef9SDimitry Andric 1720b57cec5SDimitry Andricprotected: 1730b57cec5SDimitry Andric virtual result 1740b57cec5SDimitry Andric do_out(state_type& __st, 1750b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 1760b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1770b57cec5SDimitry Andric virtual result 1780b57cec5SDimitry Andric do_in(state_type& __st, 1790b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 1800b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 1810b57cec5SDimitry Andric virtual result 1820b57cec5SDimitry Andric do_unshift(state_type& __st, 1830b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 1849ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 1859ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 1860b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 1870b57cec5SDimitry Andric size_t __mx) const; 1889ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 1890b57cec5SDimitry Andric}; 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 1920b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 1930b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_utf8 1940b57cec5SDimitry Andric : public __codecvt_utf8<_Elem> 1950b57cec5SDimitry Andric{ 1960b57cec5SDimitry Andricpublic: 1970b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1980b57cec5SDimitry Andric explicit codecvt_utf8(size_t __refs = 0) 1990b57cec5SDimitry Andric : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {} 2000b57cec5SDimitry Andric 2010b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2020b57cec5SDimitry Andric ~codecvt_utf8() {} 2030b57cec5SDimitry Andric}; 2040b57cec5SDimitry Andric 2050b57cec5SDimitry Andric// codecvt_utf16 2060b57cec5SDimitry Andric 2070b57cec5SDimitry Andrictemplate <class _Elem, bool _LittleEndian> class __codecvt_utf16; 2080b57cec5SDimitry Andric 209349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 2100b57cec5SDimitry Andrictemplate <> 2110b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false> 2120b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 2130b57cec5SDimitry Andric{ 2140b57cec5SDimitry Andric unsigned long _Maxcode_; 2150b57cec5SDimitry Andric codecvt_mode _Mode_; 2160b57cec5SDimitry Andricpublic: 2170b57cec5SDimitry Andric typedef wchar_t intern_type; 2180b57cec5SDimitry Andric typedef char extern_type; 2190b57cec5SDimitry Andric typedef mbstate_t state_type; 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2220b57cec5SDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, 2230b57cec5SDimitry Andric codecvt_mode _Mode) 2240b57cec5SDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 2250b57cec5SDimitry Andric _Mode_(_Mode) {} 2260b57cec5SDimitry Andricprotected: 2270b57cec5SDimitry Andric virtual result 2280b57cec5SDimitry Andric do_out(state_type& __st, 2290b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 2300b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 2310b57cec5SDimitry Andric virtual result 2320b57cec5SDimitry Andric do_in(state_type& __st, 2330b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 2340b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 2350b57cec5SDimitry Andric virtual result 2360b57cec5SDimitry Andric do_unshift(state_type& __st, 2370b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 2389ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 2399ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 2400b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 2410b57cec5SDimitry Andric size_t __mx) const; 2429ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 2430b57cec5SDimitry Andric}; 2440b57cec5SDimitry Andric 2450b57cec5SDimitry Andrictemplate <> 2460b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true> 2470b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 2480b57cec5SDimitry Andric{ 2490b57cec5SDimitry Andric unsigned long _Maxcode_; 2500b57cec5SDimitry Andric codecvt_mode _Mode_; 2510b57cec5SDimitry Andricpublic: 2520b57cec5SDimitry Andric typedef wchar_t intern_type; 2530b57cec5SDimitry Andric typedef char extern_type; 2540b57cec5SDimitry Andric typedef mbstate_t state_type; 2550b57cec5SDimitry Andric 2560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2570b57cec5SDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, 2580b57cec5SDimitry Andric codecvt_mode _Mode) 2590b57cec5SDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 2600b57cec5SDimitry Andric _Mode_(_Mode) {} 2610b57cec5SDimitry Andricprotected: 2620b57cec5SDimitry Andric virtual result 2630b57cec5SDimitry Andric do_out(state_type& __st, 2640b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 2650b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 2660b57cec5SDimitry Andric virtual result 2670b57cec5SDimitry Andric do_in(state_type& __st, 2680b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 2690b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 2700b57cec5SDimitry Andric virtual result 2710b57cec5SDimitry Andric do_unshift(state_type& __st, 2720b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 2739ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 2749ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 2750b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 2760b57cec5SDimitry Andric size_t __mx) const; 2779ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 2780b57cec5SDimitry Andric}; 279349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 2800b57cec5SDimitry Andric 281e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 2820b57cec5SDimitry Andrictemplate <> 2830b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false> 2840b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 2850b57cec5SDimitry Andric{ 2860b57cec5SDimitry Andric unsigned long _Maxcode_; 2870b57cec5SDimitry Andric codecvt_mode _Mode_; 2880b57cec5SDimitry Andricpublic: 2890b57cec5SDimitry Andric typedef char16_t intern_type; 2900b57cec5SDimitry Andric typedef char extern_type; 2910b57cec5SDimitry Andric typedef mbstate_t state_type; 2920b57cec5SDimitry Andric 2930b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2940b57cec5SDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, 2950b57cec5SDimitry Andric codecvt_mode _Mode) 2960b57cec5SDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 2970b57cec5SDimitry Andric _Mode_(_Mode) {} 298e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 299e8d8bef9SDimitry Andric 3000b57cec5SDimitry Andricprotected: 3010b57cec5SDimitry Andric virtual result 3020b57cec5SDimitry Andric do_out(state_type& __st, 3030b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 3040b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 3050b57cec5SDimitry Andric virtual result 3060b57cec5SDimitry Andric do_in(state_type& __st, 3070b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 3080b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 3090b57cec5SDimitry Andric virtual result 3100b57cec5SDimitry Andric do_unshift(state_type& __st, 3110b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 3129ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 3139ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 3140b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 3150b57cec5SDimitry Andric size_t __mx) const; 3169ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 3170b57cec5SDimitry Andric}; 3180b57cec5SDimitry Andric 319e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3200b57cec5SDimitry Andrictemplate <> 3210b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true> 3220b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 3230b57cec5SDimitry Andric{ 3240b57cec5SDimitry Andric unsigned long _Maxcode_; 3250b57cec5SDimitry Andric codecvt_mode _Mode_; 3260b57cec5SDimitry Andricpublic: 3270b57cec5SDimitry Andric typedef char16_t intern_type; 3280b57cec5SDimitry Andric typedef char extern_type; 3290b57cec5SDimitry Andric typedef mbstate_t state_type; 3300b57cec5SDimitry Andric 3310b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3320b57cec5SDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, 3330b57cec5SDimitry Andric codecvt_mode _Mode) 3340b57cec5SDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 3350b57cec5SDimitry Andric _Mode_(_Mode) {} 336e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 337e8d8bef9SDimitry Andric 3380b57cec5SDimitry Andricprotected: 3390b57cec5SDimitry Andric virtual result 3400b57cec5SDimitry Andric do_out(state_type& __st, 3410b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 3420b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 3430b57cec5SDimitry Andric virtual result 3440b57cec5SDimitry Andric do_in(state_type& __st, 3450b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 3460b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 3470b57cec5SDimitry Andric virtual result 3480b57cec5SDimitry Andric do_unshift(state_type& __st, 3490b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 3509ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 3519ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 3520b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 3530b57cec5SDimitry Andric size_t __mx) const; 3549ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 3550b57cec5SDimitry Andric}; 3560b57cec5SDimitry Andric 357e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3580b57cec5SDimitry Andrictemplate <> 3590b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false> 3600b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 3610b57cec5SDimitry Andric{ 3620b57cec5SDimitry Andric unsigned long _Maxcode_; 3630b57cec5SDimitry Andric codecvt_mode _Mode_; 3640b57cec5SDimitry Andricpublic: 3650b57cec5SDimitry Andric typedef char32_t intern_type; 3660b57cec5SDimitry Andric typedef char extern_type; 3670b57cec5SDimitry Andric typedef mbstate_t state_type; 3680b57cec5SDimitry Andric 3690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3700b57cec5SDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, 3710b57cec5SDimitry Andric codecvt_mode _Mode) 3720b57cec5SDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 3730b57cec5SDimitry Andric _Mode_(_Mode) {} 374e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 375e8d8bef9SDimitry Andric 3760b57cec5SDimitry Andricprotected: 3770b57cec5SDimitry Andric virtual result 3780b57cec5SDimitry Andric do_out(state_type& __st, 3790b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 3800b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 3810b57cec5SDimitry Andric virtual result 3820b57cec5SDimitry Andric do_in(state_type& __st, 3830b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 3840b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 3850b57cec5SDimitry Andric virtual result 3860b57cec5SDimitry Andric do_unshift(state_type& __st, 3870b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 3889ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 3899ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 3900b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 3910b57cec5SDimitry Andric size_t __mx) const; 3929ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 3930b57cec5SDimitry Andric}; 3940b57cec5SDimitry Andric 395e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 3960b57cec5SDimitry Andrictemplate <> 3970b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true> 3980b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 3990b57cec5SDimitry Andric{ 4000b57cec5SDimitry Andric unsigned long _Maxcode_; 4010b57cec5SDimitry Andric codecvt_mode _Mode_; 4020b57cec5SDimitry Andricpublic: 4030b57cec5SDimitry Andric typedef char32_t intern_type; 4040b57cec5SDimitry Andric typedef char extern_type; 4050b57cec5SDimitry Andric typedef mbstate_t state_type; 4060b57cec5SDimitry Andric 4070b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4080b57cec5SDimitry Andric explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, 4090b57cec5SDimitry Andric codecvt_mode _Mode) 4100b57cec5SDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 4110b57cec5SDimitry Andric _Mode_(_Mode) {} 412e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 413e8d8bef9SDimitry Andric 4140b57cec5SDimitry Andricprotected: 4150b57cec5SDimitry Andric virtual result 4160b57cec5SDimitry Andric do_out(state_type& __st, 4170b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 4180b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 4190b57cec5SDimitry Andric virtual result 4200b57cec5SDimitry Andric do_in(state_type& __st, 4210b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 4220b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 4230b57cec5SDimitry Andric virtual result 4240b57cec5SDimitry Andric do_unshift(state_type& __st, 4250b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 4269ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 4279ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 4280b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 4290b57cec5SDimitry Andric size_t __mx) const; 4309ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 4310b57cec5SDimitry Andric}; 4320b57cec5SDimitry Andric 4330b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 4340b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 4350b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_utf16 4360b57cec5SDimitry Andric : public __codecvt_utf16<_Elem, _Mode & little_endian> 4370b57cec5SDimitry Andric{ 4380b57cec5SDimitry Andricpublic: 4390b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4400b57cec5SDimitry Andric explicit codecvt_utf16(size_t __refs = 0) 4410b57cec5SDimitry Andric : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {} 4420b57cec5SDimitry Andric 4430b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4440b57cec5SDimitry Andric ~codecvt_utf16() {} 4450b57cec5SDimitry Andric}; 4460b57cec5SDimitry Andric 4470b57cec5SDimitry Andric// codecvt_utf8_utf16 4480b57cec5SDimitry Andric 4490b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8_utf16; 4500b57cec5SDimitry Andric 451349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 4520b57cec5SDimitry Andrictemplate <> 4530b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t> 4540b57cec5SDimitry Andric : public codecvt<wchar_t, char, mbstate_t> 4550b57cec5SDimitry Andric{ 4560b57cec5SDimitry Andric unsigned long _Maxcode_; 4570b57cec5SDimitry Andric codecvt_mode _Mode_; 4580b57cec5SDimitry Andricpublic: 4590b57cec5SDimitry Andric typedef wchar_t intern_type; 4600b57cec5SDimitry Andric typedef char extern_type; 4610b57cec5SDimitry Andric typedef mbstate_t state_type; 4620b57cec5SDimitry Andric 4630b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4640b57cec5SDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, 4650b57cec5SDimitry Andric codecvt_mode _Mode) 4660b57cec5SDimitry Andric : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 4670b57cec5SDimitry Andric _Mode_(_Mode) {} 4680b57cec5SDimitry Andricprotected: 4690b57cec5SDimitry Andric virtual result 4700b57cec5SDimitry Andric do_out(state_type& __st, 4710b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 4720b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 4730b57cec5SDimitry Andric virtual result 4740b57cec5SDimitry Andric do_in(state_type& __st, 4750b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 4760b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 4770b57cec5SDimitry Andric virtual result 4780b57cec5SDimitry Andric do_unshift(state_type& __st, 4790b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 4809ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 4819ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 4820b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 4830b57cec5SDimitry Andric size_t __mx) const; 4849ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 4850b57cec5SDimitry Andric}; 486349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS 4870b57cec5SDimitry Andric 488e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 4890b57cec5SDimitry Andrictemplate <> 4900b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t> 4910b57cec5SDimitry Andric : public codecvt<char32_t, char, mbstate_t> 4920b57cec5SDimitry Andric{ 4930b57cec5SDimitry Andric unsigned long _Maxcode_; 4940b57cec5SDimitry Andric codecvt_mode _Mode_; 4950b57cec5SDimitry Andricpublic: 4960b57cec5SDimitry Andric typedef char32_t intern_type; 4970b57cec5SDimitry Andric typedef char extern_type; 4980b57cec5SDimitry Andric typedef mbstate_t state_type; 4990b57cec5SDimitry Andric 5000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5010b57cec5SDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, 5020b57cec5SDimitry Andric codecvt_mode _Mode) 5030b57cec5SDimitry Andric : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 5040b57cec5SDimitry Andric _Mode_(_Mode) {} 505e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 506e8d8bef9SDimitry Andric 5070b57cec5SDimitry Andricprotected: 5080b57cec5SDimitry Andric virtual result 5090b57cec5SDimitry Andric do_out(state_type& __st, 5100b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 5110b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 5120b57cec5SDimitry Andric virtual result 5130b57cec5SDimitry Andric do_in(state_type& __st, 5140b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 5150b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 5160b57cec5SDimitry Andric virtual result 5170b57cec5SDimitry Andric do_unshift(state_type& __st, 5180b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 5199ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 5209ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 5210b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 5220b57cec5SDimitry Andric size_t __mx) const; 5239ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 5240b57cec5SDimitry Andric}; 5250b57cec5SDimitry Andric 526e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH 5270b57cec5SDimitry Andrictemplate <> 5280b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t> 5290b57cec5SDimitry Andric : public codecvt<char16_t, char, mbstate_t> 5300b57cec5SDimitry Andric{ 5310b57cec5SDimitry Andric unsigned long _Maxcode_; 5320b57cec5SDimitry Andric codecvt_mode _Mode_; 5330b57cec5SDimitry Andricpublic: 5340b57cec5SDimitry Andric typedef char16_t intern_type; 5350b57cec5SDimitry Andric typedef char extern_type; 5360b57cec5SDimitry Andric typedef mbstate_t state_type; 5370b57cec5SDimitry Andric 5380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5390b57cec5SDimitry Andric explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, 5400b57cec5SDimitry Andric codecvt_mode _Mode) 5410b57cec5SDimitry Andric : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), 5420b57cec5SDimitry Andric _Mode_(_Mode) {} 543e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP 544e8d8bef9SDimitry Andric 5450b57cec5SDimitry Andricprotected: 5460b57cec5SDimitry Andric virtual result 5470b57cec5SDimitry Andric do_out(state_type& __st, 5480b57cec5SDimitry Andric const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, 5490b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 5500b57cec5SDimitry Andric virtual result 5510b57cec5SDimitry Andric do_in(state_type& __st, 5520b57cec5SDimitry Andric const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, 5530b57cec5SDimitry Andric intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; 5540b57cec5SDimitry Andric virtual result 5550b57cec5SDimitry Andric do_unshift(state_type& __st, 5560b57cec5SDimitry Andric extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; 5579ec406dcSDimitry Andric virtual int do_encoding() const _NOEXCEPT; 5589ec406dcSDimitry Andric virtual bool do_always_noconv() const _NOEXCEPT; 5590b57cec5SDimitry Andric virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, 5600b57cec5SDimitry Andric size_t __mx) const; 5619ec406dcSDimitry Andric virtual int do_max_length() const _NOEXCEPT; 5620b57cec5SDimitry Andric}; 5630b57cec5SDimitry Andric 5640b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, 5650b57cec5SDimitry Andric codecvt_mode _Mode = (codecvt_mode)0> 5660b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16 5670b57cec5SDimitry Andric : public __codecvt_utf8_utf16<_Elem> 5680b57cec5SDimitry Andric{ 5690b57cec5SDimitry Andricpublic: 5700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5710b57cec5SDimitry Andric explicit codecvt_utf8_utf16(size_t __refs = 0) 5720b57cec5SDimitry Andric : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {} 5730b57cec5SDimitry Andric 5740b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5750b57cec5SDimitry Andric ~codecvt_utf8_utf16() {} 5760b57cec5SDimitry Andric}; 5770b57cec5SDimitry Andric 5780b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 5790b57cec5SDimitry Andric 5800b57cec5SDimitry Andric#endif // _LIBCPP_CODECVT 581