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
66c9157d92SDimitry Andric#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
67c9157d92SDimitry Andric
680b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
690b57cec5SDimitry Andric
70*e710425bSDimitry Andricenum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_header = 2, little_endian = 1 };
710b57cec5SDimitry Andric
720b57cec5SDimitry Andric// codecvt_utf8
730b57cec5SDimitry Andric
74*e710425bSDimitry Andrictemplate <class _Elem>
75*e710425bSDimitry Andricclass __codecvt_utf8;
760b57cec5SDimitry Andric
77349cc55cSDimitry Andric#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
780b57cec5SDimitry Andrictemplate <>
79*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {
80bdd1243dSDimitry Andric  unsigned long __maxcode_;
8181ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
82bdd1243dSDimitry Andric  codecvt_mode __mode_;
8381ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
84*e710425bSDimitry Andric
850b57cec5SDimitry Andricpublic:
860b57cec5SDimitry Andric  typedef wchar_t intern_type;
870b57cec5SDimitry Andric  typedef char extern_type;
880b57cec5SDimitry Andric  typedef mbstate_t state_type;
890b57cec5SDimitry Andric
9081ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
91*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
92*e710425bSDimitry Andric      : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
9381ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
94*e710425bSDimitry Andric
950b57cec5SDimitry Andricprotected:
96bdd1243dSDimitry Andric  result do_out(state_type& __st,
97*e710425bSDimitry Andric                const intern_type* __frm,
98*e710425bSDimitry Andric                const intern_type* __frm_end,
99*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
100*e710425bSDimitry Andric                extern_type* __to,
101*e710425bSDimitry Andric                extern_type* __to_end,
102*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
103bdd1243dSDimitry Andric  result do_in(state_type& __st,
104*e710425bSDimitry Andric               const extern_type* __frm,
105*e710425bSDimitry Andric               const extern_type* __frm_end,
106*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
107*e710425bSDimitry Andric               intern_type* __to,
108*e710425bSDimitry Andric               intern_type* __to_end,
109*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
110*e710425bSDimitry Andric  result do_unshift(state_type& __st, 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 <>
120*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<char16_t> : public codecvt<char16_t, char, mbstate_t> {
121bdd1243dSDimitry Andric  unsigned long __maxcode_;
122bdd1243dSDimitry Andric  codecvt_mode __mode_;
123*e710425bSDimitry Andric
1240b57cec5SDimitry Andricpublic:
1250b57cec5SDimitry Andric  typedef char16_t intern_type;
1260b57cec5SDimitry Andric  typedef char extern_type;
1270b57cec5SDimitry Andric  typedef mbstate_t state_type;
1280b57cec5SDimitry Andric
129*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
130*e710425bSDimitry Andric      : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
131e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
132e8d8bef9SDimitry Andric
1330b57cec5SDimitry Andricprotected:
134bdd1243dSDimitry Andric  result do_out(state_type& __st,
135*e710425bSDimitry Andric                const intern_type* __frm,
136*e710425bSDimitry Andric                const intern_type* __frm_end,
137*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
138*e710425bSDimitry Andric                extern_type* __to,
139*e710425bSDimitry Andric                extern_type* __to_end,
140*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
141bdd1243dSDimitry Andric  result do_in(state_type& __st,
142*e710425bSDimitry Andric               const extern_type* __frm,
143*e710425bSDimitry Andric               const extern_type* __frm_end,
144*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
145*e710425bSDimitry Andric               intern_type* __to,
146*e710425bSDimitry Andric               intern_type* __to_end,
147*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
148*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
149bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
150bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
151bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
152bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
1530b57cec5SDimitry Andric};
1540b57cec5SDimitry Andric
155e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1560b57cec5SDimitry Andrictemplate <>
157*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<char32_t> : public codecvt<char32_t, char, mbstate_t> {
158bdd1243dSDimitry Andric  unsigned long __maxcode_;
159bdd1243dSDimitry Andric  codecvt_mode __mode_;
160*e710425bSDimitry Andric
1610b57cec5SDimitry Andricpublic:
1620b57cec5SDimitry Andric  typedef char32_t intern_type;
1630b57cec5SDimitry Andric  typedef char extern_type;
1640b57cec5SDimitry Andric  typedef mbstate_t state_type;
1650b57cec5SDimitry Andric
166*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
167*e710425bSDimitry Andric      : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
168e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
169e8d8bef9SDimitry Andric
1700b57cec5SDimitry Andricprotected:
171bdd1243dSDimitry Andric  result do_out(state_type& __st,
172*e710425bSDimitry Andric                const intern_type* __frm,
173*e710425bSDimitry Andric                const intern_type* __frm_end,
174*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
175*e710425bSDimitry Andric                extern_type* __to,
176*e710425bSDimitry Andric                extern_type* __to_end,
177*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
178bdd1243dSDimitry Andric  result do_in(state_type& __st,
179*e710425bSDimitry Andric               const extern_type* __frm,
180*e710425bSDimitry Andric               const extern_type* __frm_end,
181*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
182*e710425bSDimitry Andric               intern_type* __to,
183*e710425bSDimitry Andric               intern_type* __to_end,
184*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
185*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
186bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
187bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
188bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
189bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
1900b57cec5SDimitry Andric};
1910b57cec5SDimitry Andric
19281ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
193*e710425bSDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
194*e710425bSDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 : public __codecvt_utf8<_Elem> {
1950b57cec5SDimitry Andricpublic:
196*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
1970b57cec5SDimitry Andric
198*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~codecvt_utf8() {}
1990b57cec5SDimitry Andric};
20081ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric// codecvt_utf16
2030b57cec5SDimitry Andric
204*e710425bSDimitry Andrictemplate <class _Elem, bool _LittleEndian>
205*e710425bSDimitry Andricclass __codecvt_utf16;
2060b57cec5SDimitry Andric
207349cc55cSDimitry Andric#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2080b57cec5SDimitry Andrictemplate <>
209*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> {
210bdd1243dSDimitry Andric  unsigned long __maxcode_;
21181ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
212bdd1243dSDimitry Andric  codecvt_mode __mode_;
21381ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
214*e710425bSDimitry Andric
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*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
222*e710425bSDimitry Andric      : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
22381ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
224*e710425bSDimitry Andric
2250b57cec5SDimitry Andricprotected:
226bdd1243dSDimitry Andric  result do_out(state_type& __st,
227*e710425bSDimitry Andric                const intern_type* __frm,
228*e710425bSDimitry Andric                const intern_type* __frm_end,
229*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
230*e710425bSDimitry Andric                extern_type* __to,
231*e710425bSDimitry Andric                extern_type* __to_end,
232*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
233bdd1243dSDimitry Andric  result do_in(state_type& __st,
234*e710425bSDimitry Andric               const extern_type* __frm,
235*e710425bSDimitry Andric               const extern_type* __frm_end,
236*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
237*e710425bSDimitry Andric               intern_type* __to,
238*e710425bSDimitry Andric               intern_type* __to_end,
239*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
240*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
241bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
242bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
243*e710425bSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
244bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
2450b57cec5SDimitry Andric};
2460b57cec5SDimitry Andric
2470b57cec5SDimitry Andrictemplate <>
248*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, true> : public codecvt<wchar_t, char, mbstate_t> {
249bdd1243dSDimitry Andric  unsigned long __maxcode_;
25081ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
251bdd1243dSDimitry Andric  codecvt_mode __mode_;
25281ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
253*e710425bSDimitry Andric
2540b57cec5SDimitry Andricpublic:
2550b57cec5SDimitry Andric  typedef wchar_t intern_type;
2560b57cec5SDimitry Andric  typedef char extern_type;
2570b57cec5SDimitry Andric  typedef mbstate_t state_type;
2580b57cec5SDimitry Andric
25981ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
260*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
261*e710425bSDimitry Andric      : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
26281ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
263*e710425bSDimitry Andric
2640b57cec5SDimitry Andricprotected:
265bdd1243dSDimitry Andric  result do_out(state_type& __st,
266*e710425bSDimitry Andric                const intern_type* __frm,
267*e710425bSDimitry Andric                const intern_type* __frm_end,
268*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
269*e710425bSDimitry Andric                extern_type* __to,
270*e710425bSDimitry Andric                extern_type* __to_end,
271*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
272bdd1243dSDimitry Andric  result do_in(state_type& __st,
273*e710425bSDimitry Andric               const extern_type* __frm,
274*e710425bSDimitry Andric               const extern_type* __frm_end,
275*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
276*e710425bSDimitry Andric               intern_type* __to,
277*e710425bSDimitry Andric               intern_type* __to_end,
278*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
279*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
280bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
281bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
282bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
283bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
2840b57cec5SDimitry Andric};
285349cc55cSDimitry Andric#  endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
2860b57cec5SDimitry Andric
287e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2880b57cec5SDimitry Andrictemplate <>
289*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char16_t, false> : public codecvt<char16_t, char, mbstate_t> {
290bdd1243dSDimitry Andric  unsigned long __maxcode_;
291bdd1243dSDimitry Andric  codecvt_mode __mode_;
292*e710425bSDimitry Andric
2930b57cec5SDimitry Andricpublic:
2940b57cec5SDimitry Andric  typedef char16_t intern_type;
2950b57cec5SDimitry Andric  typedef char extern_type;
2960b57cec5SDimitry Andric  typedef mbstate_t state_type;
2970b57cec5SDimitry Andric
298*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
299*e710425bSDimitry Andric      : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
300e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
301e8d8bef9SDimitry Andric
3020b57cec5SDimitry Andricprotected:
303bdd1243dSDimitry Andric  result do_out(state_type& __st,
304*e710425bSDimitry Andric                const intern_type* __frm,
305*e710425bSDimitry Andric                const intern_type* __frm_end,
306*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
307*e710425bSDimitry Andric                extern_type* __to,
308*e710425bSDimitry Andric                extern_type* __to_end,
309*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
310bdd1243dSDimitry Andric  result do_in(state_type& __st,
311*e710425bSDimitry Andric               const extern_type* __frm,
312*e710425bSDimitry Andric               const extern_type* __frm_end,
313*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
314*e710425bSDimitry Andric               intern_type* __to,
315*e710425bSDimitry Andric               intern_type* __to_end,
316*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
317*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
318bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
319bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
320bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
321bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
3220b57cec5SDimitry Andric};
3230b57cec5SDimitry Andric
324e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3250b57cec5SDimitry Andrictemplate <>
326*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char16_t, true> : public codecvt<char16_t, char, mbstate_t> {
327bdd1243dSDimitry Andric  unsigned long __maxcode_;
328bdd1243dSDimitry Andric  codecvt_mode __mode_;
329*e710425bSDimitry Andric
3300b57cec5SDimitry Andricpublic:
3310b57cec5SDimitry Andric  typedef char16_t intern_type;
3320b57cec5SDimitry Andric  typedef char extern_type;
3330b57cec5SDimitry Andric  typedef mbstate_t state_type;
3340b57cec5SDimitry Andric
335*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
336*e710425bSDimitry Andric      : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
337e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
338e8d8bef9SDimitry Andric
3390b57cec5SDimitry Andricprotected:
340bdd1243dSDimitry Andric  result do_out(state_type& __st,
341*e710425bSDimitry Andric                const intern_type* __frm,
342*e710425bSDimitry Andric                const intern_type* __frm_end,
343*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
344*e710425bSDimitry Andric                extern_type* __to,
345*e710425bSDimitry Andric                extern_type* __to_end,
346*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
347bdd1243dSDimitry Andric  result do_in(state_type& __st,
348*e710425bSDimitry Andric               const extern_type* __frm,
349*e710425bSDimitry Andric               const extern_type* __frm_end,
350*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
351*e710425bSDimitry Andric               intern_type* __to,
352*e710425bSDimitry Andric               intern_type* __to_end,
353*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
354*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
355bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
356bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
357bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
358bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
3590b57cec5SDimitry Andric};
3600b57cec5SDimitry Andric
361e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3620b57cec5SDimitry Andrictemplate <>
363*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char32_t, false> : public codecvt<char32_t, char, mbstate_t> {
364bdd1243dSDimitry Andric  unsigned long __maxcode_;
365bdd1243dSDimitry Andric  codecvt_mode __mode_;
366*e710425bSDimitry Andric
3670b57cec5SDimitry Andricpublic:
3680b57cec5SDimitry Andric  typedef char32_t intern_type;
3690b57cec5SDimitry Andric  typedef char extern_type;
3700b57cec5SDimitry Andric  typedef mbstate_t state_type;
3710b57cec5SDimitry Andric
372*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
373*e710425bSDimitry Andric      : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
374e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
375e8d8bef9SDimitry Andric
3760b57cec5SDimitry Andricprotected:
377bdd1243dSDimitry Andric  result do_out(state_type& __st,
378*e710425bSDimitry Andric                const intern_type* __frm,
379*e710425bSDimitry Andric                const intern_type* __frm_end,
380*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
381*e710425bSDimitry Andric                extern_type* __to,
382*e710425bSDimitry Andric                extern_type* __to_end,
383*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
384bdd1243dSDimitry Andric  result do_in(state_type& __st,
385*e710425bSDimitry Andric               const extern_type* __frm,
386*e710425bSDimitry Andric               const extern_type* __frm_end,
387*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
388*e710425bSDimitry Andric               intern_type* __to,
389*e710425bSDimitry Andric               intern_type* __to_end,
390*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
391*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
392bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
393bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
394bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
395bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
3960b57cec5SDimitry Andric};
3970b57cec5SDimitry Andric
398e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3990b57cec5SDimitry Andrictemplate <>
400*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<char32_t, true> : public codecvt<char32_t, char, mbstate_t> {
401bdd1243dSDimitry Andric  unsigned long __maxcode_;
402bdd1243dSDimitry Andric  codecvt_mode __mode_;
403*e710425bSDimitry Andric
4040b57cec5SDimitry Andricpublic:
4050b57cec5SDimitry Andric  typedef char32_t intern_type;
4060b57cec5SDimitry Andric  typedef char extern_type;
4070b57cec5SDimitry Andric  typedef mbstate_t state_type;
4080b57cec5SDimitry Andric
409*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
410*e710425bSDimitry Andric      : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
411e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
412e8d8bef9SDimitry Andric
4130b57cec5SDimitry Andricprotected:
414bdd1243dSDimitry Andric  result do_out(state_type& __st,
415*e710425bSDimitry Andric                const intern_type* __frm,
416*e710425bSDimitry Andric                const intern_type* __frm_end,
417*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
418*e710425bSDimitry Andric                extern_type* __to,
419*e710425bSDimitry Andric                extern_type* __to_end,
420*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
421bdd1243dSDimitry Andric  result do_in(state_type& __st,
422*e710425bSDimitry Andric               const extern_type* __frm,
423*e710425bSDimitry Andric               const extern_type* __frm_end,
424*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
425*e710425bSDimitry Andric               intern_type* __to,
426*e710425bSDimitry Andric               intern_type* __to_end,
427*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
428*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
429bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
430bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
431bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
432bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
4330b57cec5SDimitry Andric};
4340b57cec5SDimitry Andric
43581ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
436*e710425bSDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
43781ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16
438*e710425bSDimitry Andric    : public __codecvt_utf16<_Elem, _Mode & little_endian> {
4390b57cec5SDimitry Andricpublic:
440*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0)
4410b57cec5SDimitry Andric      : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
4420b57cec5SDimitry Andric
443*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~codecvt_utf16() {}
4440b57cec5SDimitry Andric};
44581ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
4460b57cec5SDimitry Andric
4470b57cec5SDimitry Andric// codecvt_utf8_utf16
4480b57cec5SDimitry Andric
449*e710425bSDimitry Andrictemplate <class _Elem>
450*e710425bSDimitry Andricclass __codecvt_utf8_utf16;
4510b57cec5SDimitry Andric
452349cc55cSDimitry Andric#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4530b57cec5SDimitry Andrictemplate <>
454*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {
455bdd1243dSDimitry Andric  unsigned long __maxcode_;
45681ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
457bdd1243dSDimitry Andric  codecvt_mode __mode_;
45881ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
459*e710425bSDimitry Andric
4600b57cec5SDimitry Andricpublic:
4610b57cec5SDimitry Andric  typedef wchar_t intern_type;
4620b57cec5SDimitry Andric  typedef char extern_type;
4630b57cec5SDimitry Andric  typedef mbstate_t state_type;
4640b57cec5SDimitry Andric
46581ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_PUSH
466*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
467*e710425bSDimitry Andric      : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
46881ad6265SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
469*e710425bSDimitry Andric
4700b57cec5SDimitry Andricprotected:
471bdd1243dSDimitry Andric  result do_out(state_type& __st,
472*e710425bSDimitry Andric                const intern_type* __frm,
473*e710425bSDimitry Andric                const intern_type* __frm_end,
474*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
475*e710425bSDimitry Andric                extern_type* __to,
476*e710425bSDimitry Andric                extern_type* __to_end,
477*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
478bdd1243dSDimitry Andric  result do_in(state_type& __st,
479*e710425bSDimitry Andric               const extern_type* __frm,
480*e710425bSDimitry Andric               const extern_type* __frm_end,
481*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
482*e710425bSDimitry Andric               intern_type* __to,
483*e710425bSDimitry Andric               intern_type* __to_end,
484*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
485*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
486bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
487bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
488bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
489bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
4900b57cec5SDimitry Andric};
491349cc55cSDimitry Andric#  endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
4920b57cec5SDimitry Andric
493e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4940b57cec5SDimitry Andrictemplate <>
495*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<char32_t> : public codecvt<char32_t, char, mbstate_t> {
496bdd1243dSDimitry Andric  unsigned long __maxcode_;
497bdd1243dSDimitry Andric  codecvt_mode __mode_;
498*e710425bSDimitry Andric
4990b57cec5SDimitry Andricpublic:
5000b57cec5SDimitry Andric  typedef char32_t intern_type;
5010b57cec5SDimitry Andric  typedef char extern_type;
5020b57cec5SDimitry Andric  typedef mbstate_t state_type;
5030b57cec5SDimitry Andric
504*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
505*e710425bSDimitry Andric      : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
506e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
507e8d8bef9SDimitry Andric
5080b57cec5SDimitry Andricprotected:
509bdd1243dSDimitry Andric  result do_out(state_type& __st,
510*e710425bSDimitry Andric                const intern_type* __frm,
511*e710425bSDimitry Andric                const intern_type* __frm_end,
512*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
513*e710425bSDimitry Andric                extern_type* __to,
514*e710425bSDimitry Andric                extern_type* __to_end,
515*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
516bdd1243dSDimitry Andric  result do_in(state_type& __st,
517*e710425bSDimitry Andric               const extern_type* __frm,
518*e710425bSDimitry Andric               const extern_type* __frm_end,
519*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
520*e710425bSDimitry Andric               intern_type* __to,
521*e710425bSDimitry Andric               intern_type* __to_end,
522*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
523*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
524bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
525bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
526bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
527bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
5280b57cec5SDimitry Andric};
5290b57cec5SDimitry Andric
530e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
5310b57cec5SDimitry Andrictemplate <>
532*e710425bSDimitry Andricclass _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<char16_t> : public codecvt<char16_t, char, mbstate_t> {
533bdd1243dSDimitry Andric  unsigned long __maxcode_;
534bdd1243dSDimitry Andric  codecvt_mode __mode_;
535*e710425bSDimitry Andric
5360b57cec5SDimitry Andricpublic:
5370b57cec5SDimitry Andric  typedef char16_t intern_type;
5380b57cec5SDimitry Andric  typedef char extern_type;
5390b57cec5SDimitry Andric  typedef mbstate_t state_type;
5400b57cec5SDimitry Andric
541*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, codecvt_mode __mode)
542*e710425bSDimitry Andric      : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode), __mode_(__mode) {}
543e8d8bef9SDimitry Andric  _LIBCPP_SUPPRESS_DEPRECATED_POP
544e8d8bef9SDimitry Andric
5450b57cec5SDimitry Andricprotected:
546bdd1243dSDimitry Andric  result do_out(state_type& __st,
547*e710425bSDimitry Andric                const intern_type* __frm,
548*e710425bSDimitry Andric                const intern_type* __frm_end,
549*e710425bSDimitry Andric                const intern_type*& __frm_nxt,
550*e710425bSDimitry Andric                extern_type* __to,
551*e710425bSDimitry Andric                extern_type* __to_end,
552*e710425bSDimitry Andric                extern_type*& __to_nxt) const override;
553bdd1243dSDimitry Andric  result do_in(state_type& __st,
554*e710425bSDimitry Andric               const extern_type* __frm,
555*e710425bSDimitry Andric               const extern_type* __frm_end,
556*e710425bSDimitry Andric               const extern_type*& __frm_nxt,
557*e710425bSDimitry Andric               intern_type* __to,
558*e710425bSDimitry Andric               intern_type* __to_end,
559*e710425bSDimitry Andric               intern_type*& __to_nxt) const override;
560*e710425bSDimitry Andric  result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
561bdd1243dSDimitry Andric  int do_encoding() const _NOEXCEPT override;
562bdd1243dSDimitry Andric  bool do_always_noconv() const _NOEXCEPT override;
563bdd1243dSDimitry Andric  int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
564bdd1243dSDimitry Andric  int do_max_length() const _NOEXCEPT override;
5650b57cec5SDimitry Andric};
5660b57cec5SDimitry Andric
56781ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
568*e710425bSDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
569*e710425bSDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> {
5700b57cec5SDimitry Andricpublic:
571*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8_utf16(size_t __refs = 0)
5720b57cec5SDimitry Andric      : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
5730b57cec5SDimitry Andric
574*e710425bSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ~codecvt_utf8_utf16() {}
5750b57cec5SDimitry Andric};
57681ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
5770b57cec5SDimitry Andric
5780b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
5790b57cec5SDimitry Andric
580c9157d92SDimitry Andric#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
581c9157d92SDimitry Andric
582bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
583bdd1243dSDimitry Andric#  include <atomic>
584bdd1243dSDimitry Andric#  include <concepts>
585bdd1243dSDimitry Andric#  include <cstddef>
586bdd1243dSDimitry Andric#  include <cstdlib>
587bdd1243dSDimitry Andric#  include <cstring>
588bdd1243dSDimitry Andric#  include <initializer_list>
589bdd1243dSDimitry Andric#  include <iosfwd>
590bdd1243dSDimitry Andric#  include <limits>
591c9157d92SDimitry Andric#  include <mutex>
592bdd1243dSDimitry Andric#  include <new>
593bdd1243dSDimitry Andric#  include <stdexcept>
594bdd1243dSDimitry Andric#  include <type_traits>
595bdd1243dSDimitry Andric#  include <typeinfo>
596bdd1243dSDimitry Andric#endif
597bdd1243dSDimitry Andric
5980b57cec5SDimitry Andric#endif // _LIBCPP_CODECVT
599