xref: /freebsd/contrib/llvm-project/libcxx/include/codecvt (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
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
57*81ad6265SDimitry 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
68*81ad6265SDimitry 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{
840b57cec5SDimitry Andric    unsigned long _Maxcode_;
85*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
860b57cec5SDimitry Andric    codecvt_mode _Mode_;
87*81ad6265SDimitry 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
93*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
950b57cec5SDimitry Andric    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
960b57cec5SDimitry Andric                            codecvt_mode _Mode)
970b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
980b57cec5SDimitry Andric          _Mode_(_Mode) {}
99*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
1000b57cec5SDimitry Andricprotected:
1010b57cec5SDimitry Andric    virtual result
1020b57cec5SDimitry Andric        do_out(state_type& __st,
1030b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1040b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1050b57cec5SDimitry Andric    virtual result
1060b57cec5SDimitry Andric        do_in(state_type& __st,
1070b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1080b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1090b57cec5SDimitry Andric    virtual result
1100b57cec5SDimitry Andric        do_unshift(state_type& __st,
1110b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1129ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
1139ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
1140b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
1150b57cec5SDimitry Andric                          size_t __mx) const;
1169ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
1170b57cec5SDimitry Andric};
118349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
1190b57cec5SDimitry Andric
120e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1210b57cec5SDimitry Andrictemplate <>
1220b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
1230b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
1240b57cec5SDimitry Andric{
1250b57cec5SDimitry Andric    unsigned long _Maxcode_;
1260b57cec5SDimitry Andric    codecvt_mode _Mode_;
1270b57cec5SDimitry Andricpublic:
1280b57cec5SDimitry Andric    typedef char16_t  intern_type;
1290b57cec5SDimitry Andric    typedef char      extern_type;
1300b57cec5SDimitry Andric    typedef mbstate_t state_type;
1310b57cec5SDimitry Andric
1320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1330b57cec5SDimitry Andric    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
1340b57cec5SDimitry Andric                            codecvt_mode _Mode)
1350b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
1360b57cec5SDimitry Andric          _Mode_(_Mode) {}
137e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
138e8d8bef9SDimitry Andric
1390b57cec5SDimitry Andricprotected:
1400b57cec5SDimitry Andric    virtual result
1410b57cec5SDimitry Andric        do_out(state_type& __st,
1420b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1430b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1440b57cec5SDimitry Andric    virtual result
1450b57cec5SDimitry Andric        do_in(state_type& __st,
1460b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1470b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1480b57cec5SDimitry Andric    virtual result
1490b57cec5SDimitry Andric        do_unshift(state_type& __st,
1500b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1519ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
1529ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
1530b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
1540b57cec5SDimitry Andric                          size_t __mx) const;
1559ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
1560b57cec5SDimitry Andric};
1570b57cec5SDimitry Andric
158e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1590b57cec5SDimitry Andrictemplate <>
1600b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
1610b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
1620b57cec5SDimitry Andric{
1630b57cec5SDimitry Andric    unsigned long _Maxcode_;
1640b57cec5SDimitry Andric    codecvt_mode _Mode_;
1650b57cec5SDimitry Andricpublic:
1660b57cec5SDimitry Andric    typedef char32_t  intern_type;
1670b57cec5SDimitry Andric    typedef char      extern_type;
1680b57cec5SDimitry Andric    typedef mbstate_t state_type;
1690b57cec5SDimitry Andric
1700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1710b57cec5SDimitry Andric    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
1720b57cec5SDimitry Andric                            codecvt_mode _Mode)
1730b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
1740b57cec5SDimitry Andric          _Mode_(_Mode) {}
175e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
176e8d8bef9SDimitry Andric
1770b57cec5SDimitry Andricprotected:
1780b57cec5SDimitry Andric    virtual result
1790b57cec5SDimitry Andric        do_out(state_type& __st,
1800b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1810b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1820b57cec5SDimitry Andric    virtual result
1830b57cec5SDimitry Andric        do_in(state_type& __st,
1840b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1850b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1860b57cec5SDimitry Andric    virtual result
1870b57cec5SDimitry Andric        do_unshift(state_type& __st,
1880b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1899ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
1909ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
1910b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
1920b57cec5SDimitry Andric                          size_t __mx) const;
1939ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
1940b57cec5SDimitry Andric};
1950b57cec5SDimitry Andric
196*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1970b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
1980b57cec5SDimitry Andric          codecvt_mode _Mode = (codecvt_mode)0>
199*81ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8
2000b57cec5SDimitry Andric    : public __codecvt_utf8<_Elem>
2010b57cec5SDimitry Andric{
2020b57cec5SDimitry Andricpublic:
2030b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2040b57cec5SDimitry Andric    explicit codecvt_utf8(size_t __refs = 0)
2050b57cec5SDimitry Andric        : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
2060b57cec5SDimitry Andric
2070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2080b57cec5SDimitry Andric    ~codecvt_utf8() {}
2090b57cec5SDimitry Andric};
210*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
2110b57cec5SDimitry Andric
2120b57cec5SDimitry Andric// codecvt_utf16
2130b57cec5SDimitry Andric
2140b57cec5SDimitry Andrictemplate <class _Elem, bool _LittleEndian> class __codecvt_utf16;
2150b57cec5SDimitry Andric
216349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2170b57cec5SDimitry Andrictemplate <>
2180b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
2190b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
2200b57cec5SDimitry Andric{
2210b57cec5SDimitry Andric    unsigned long _Maxcode_;
222*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2230b57cec5SDimitry Andric    codecvt_mode _Mode_;
224*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
2250b57cec5SDimitry Andricpublic:
2260b57cec5SDimitry Andric    typedef wchar_t   intern_type;
2270b57cec5SDimitry Andric    typedef char      extern_type;
2280b57cec5SDimitry Andric    typedef mbstate_t state_type;
2290b57cec5SDimitry Andric
230*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2320b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
2330b57cec5SDimitry Andric                            codecvt_mode _Mode)
2340b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
2350b57cec5SDimitry Andric          _Mode_(_Mode) {}
236*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
2370b57cec5SDimitry Andricprotected:
2380b57cec5SDimitry Andric    virtual result
2390b57cec5SDimitry Andric        do_out(state_type& __st,
2400b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
2410b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2420b57cec5SDimitry Andric    virtual result
2430b57cec5SDimitry Andric        do_in(state_type& __st,
2440b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
2450b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
2460b57cec5SDimitry Andric    virtual result
2470b57cec5SDimitry Andric        do_unshift(state_type& __st,
2480b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2499ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
2509ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
2510b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
2520b57cec5SDimitry Andric                          size_t __mx) const;
2539ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
2540b57cec5SDimitry Andric};
2550b57cec5SDimitry Andric
2560b57cec5SDimitry Andrictemplate <>
2570b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
2580b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
2590b57cec5SDimitry Andric{
2600b57cec5SDimitry Andric    unsigned long _Maxcode_;
261*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2620b57cec5SDimitry Andric    codecvt_mode _Mode_;
263*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
2640b57cec5SDimitry Andricpublic:
2650b57cec5SDimitry Andric    typedef wchar_t   intern_type;
2660b57cec5SDimitry Andric    typedef char      extern_type;
2670b57cec5SDimitry Andric    typedef mbstate_t state_type;
2680b57cec5SDimitry Andric
269*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2710b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
2720b57cec5SDimitry Andric                            codecvt_mode _Mode)
2730b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
2740b57cec5SDimitry Andric          _Mode_(_Mode) {}
275*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
2760b57cec5SDimitry Andricprotected:
2770b57cec5SDimitry Andric    virtual result
2780b57cec5SDimitry Andric        do_out(state_type& __st,
2790b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
2800b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2810b57cec5SDimitry Andric    virtual result
2820b57cec5SDimitry Andric        do_in(state_type& __st,
2830b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
2840b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
2850b57cec5SDimitry Andric    virtual result
2860b57cec5SDimitry Andric        do_unshift(state_type& __st,
2870b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2889ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
2899ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
2900b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
2910b57cec5SDimitry Andric                          size_t __mx) const;
2929ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
2930b57cec5SDimitry Andric};
294349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
2950b57cec5SDimitry Andric
296e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2970b57cec5SDimitry Andrictemplate <>
2980b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
2990b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
3000b57cec5SDimitry Andric{
3010b57cec5SDimitry Andric    unsigned long _Maxcode_;
3020b57cec5SDimitry Andric    codecvt_mode _Mode_;
3030b57cec5SDimitry Andricpublic:
3040b57cec5SDimitry Andric    typedef char16_t  intern_type;
3050b57cec5SDimitry Andric    typedef char      extern_type;
3060b57cec5SDimitry Andric    typedef mbstate_t state_type;
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3090b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
3100b57cec5SDimitry Andric                            codecvt_mode _Mode)
3110b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
3120b57cec5SDimitry Andric          _Mode_(_Mode) {}
313e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
314e8d8bef9SDimitry Andric
3150b57cec5SDimitry Andricprotected:
3160b57cec5SDimitry Andric    virtual result
3170b57cec5SDimitry Andric        do_out(state_type& __st,
3180b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
3190b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3200b57cec5SDimitry Andric    virtual result
3210b57cec5SDimitry Andric        do_in(state_type& __st,
3220b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
3230b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
3240b57cec5SDimitry Andric    virtual result
3250b57cec5SDimitry Andric        do_unshift(state_type& __st,
3260b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3279ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
3289ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
3290b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
3300b57cec5SDimitry Andric                          size_t __mx) const;
3319ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
3320b57cec5SDimitry Andric};
3330b57cec5SDimitry Andric
334e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3350b57cec5SDimitry Andrictemplate <>
3360b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
3370b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
3380b57cec5SDimitry Andric{
3390b57cec5SDimitry Andric    unsigned long _Maxcode_;
3400b57cec5SDimitry Andric    codecvt_mode _Mode_;
3410b57cec5SDimitry Andricpublic:
3420b57cec5SDimitry Andric    typedef char16_t  intern_type;
3430b57cec5SDimitry Andric    typedef char      extern_type;
3440b57cec5SDimitry Andric    typedef mbstate_t state_type;
3450b57cec5SDimitry Andric
3460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3470b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
3480b57cec5SDimitry Andric                            codecvt_mode _Mode)
3490b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
3500b57cec5SDimitry Andric          _Mode_(_Mode) {}
351e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
352e8d8bef9SDimitry Andric
3530b57cec5SDimitry Andricprotected:
3540b57cec5SDimitry Andric    virtual result
3550b57cec5SDimitry Andric        do_out(state_type& __st,
3560b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
3570b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3580b57cec5SDimitry Andric    virtual result
3590b57cec5SDimitry Andric        do_in(state_type& __st,
3600b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
3610b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
3620b57cec5SDimitry Andric    virtual result
3630b57cec5SDimitry Andric        do_unshift(state_type& __st,
3640b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3659ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
3669ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
3670b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
3680b57cec5SDimitry Andric                          size_t __mx) const;
3699ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
3700b57cec5SDimitry Andric};
3710b57cec5SDimitry Andric
372e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3730b57cec5SDimitry Andrictemplate <>
3740b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
3750b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
3760b57cec5SDimitry Andric{
3770b57cec5SDimitry Andric    unsigned long _Maxcode_;
3780b57cec5SDimitry Andric    codecvt_mode _Mode_;
3790b57cec5SDimitry Andricpublic:
3800b57cec5SDimitry Andric    typedef char32_t  intern_type;
3810b57cec5SDimitry Andric    typedef char      extern_type;
3820b57cec5SDimitry Andric    typedef mbstate_t state_type;
3830b57cec5SDimitry Andric
3840b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3850b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
3860b57cec5SDimitry Andric                            codecvt_mode _Mode)
3870b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
3880b57cec5SDimitry Andric          _Mode_(_Mode) {}
389e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
390e8d8bef9SDimitry Andric
3910b57cec5SDimitry Andricprotected:
3920b57cec5SDimitry Andric    virtual result
3930b57cec5SDimitry Andric        do_out(state_type& __st,
3940b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
3950b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3960b57cec5SDimitry Andric    virtual result
3970b57cec5SDimitry Andric        do_in(state_type& __st,
3980b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
3990b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
4000b57cec5SDimitry Andric    virtual result
4010b57cec5SDimitry Andric        do_unshift(state_type& __st,
4020b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4039ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
4049ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
4050b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
4060b57cec5SDimitry Andric                          size_t __mx) const;
4079ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
4080b57cec5SDimitry Andric};
4090b57cec5SDimitry Andric
410e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4110b57cec5SDimitry Andrictemplate <>
4120b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
4130b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
4140b57cec5SDimitry Andric{
4150b57cec5SDimitry Andric    unsigned long _Maxcode_;
4160b57cec5SDimitry Andric    codecvt_mode _Mode_;
4170b57cec5SDimitry Andricpublic:
4180b57cec5SDimitry Andric    typedef char32_t  intern_type;
4190b57cec5SDimitry Andric    typedef char      extern_type;
4200b57cec5SDimitry Andric    typedef mbstate_t state_type;
4210b57cec5SDimitry Andric
4220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4230b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
4240b57cec5SDimitry Andric                            codecvt_mode _Mode)
4250b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
4260b57cec5SDimitry Andric          _Mode_(_Mode) {}
427e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
428e8d8bef9SDimitry Andric
4290b57cec5SDimitry Andricprotected:
4300b57cec5SDimitry Andric    virtual result
4310b57cec5SDimitry Andric        do_out(state_type& __st,
4320b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
4330b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4340b57cec5SDimitry Andric    virtual result
4350b57cec5SDimitry Andric        do_in(state_type& __st,
4360b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
4370b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
4380b57cec5SDimitry Andric    virtual result
4390b57cec5SDimitry Andric        do_unshift(state_type& __st,
4400b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4419ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
4429ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
4430b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
4440b57cec5SDimitry Andric                          size_t __mx) const;
4459ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
4460b57cec5SDimitry Andric};
4470b57cec5SDimitry Andric
448*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4490b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
4500b57cec5SDimitry Andric          codecvt_mode _Mode = (codecvt_mode)0>
451*81ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16
4520b57cec5SDimitry Andric    : public __codecvt_utf16<_Elem, _Mode & little_endian>
4530b57cec5SDimitry Andric{
4540b57cec5SDimitry Andricpublic:
4550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4560b57cec5SDimitry Andric    explicit codecvt_utf16(size_t __refs = 0)
4570b57cec5SDimitry Andric        : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
4580b57cec5SDimitry Andric
4590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4600b57cec5SDimitry Andric    ~codecvt_utf16() {}
4610b57cec5SDimitry Andric};
462*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
4630b57cec5SDimitry Andric
4640b57cec5SDimitry Andric// codecvt_utf8_utf16
4650b57cec5SDimitry Andric
4660b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8_utf16;
4670b57cec5SDimitry Andric
468349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4690b57cec5SDimitry Andrictemplate <>
4700b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
4710b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
4720b57cec5SDimitry Andric{
4730b57cec5SDimitry Andric    unsigned long _Maxcode_;
474*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4750b57cec5SDimitry Andric    codecvt_mode _Mode_;
476*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
4770b57cec5SDimitry Andricpublic:
4780b57cec5SDimitry Andric    typedef wchar_t   intern_type;
4790b57cec5SDimitry Andric    typedef char      extern_type;
4800b57cec5SDimitry Andric    typedef mbstate_t state_type;
4810b57cec5SDimitry Andric
482*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4840b57cec5SDimitry Andric    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
4850b57cec5SDimitry Andric                            codecvt_mode _Mode)
4860b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
4870b57cec5SDimitry Andric          _Mode_(_Mode) {}
488*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
4890b57cec5SDimitry Andricprotected:
4900b57cec5SDimitry Andric    virtual result
4910b57cec5SDimitry Andric        do_out(state_type& __st,
4920b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
4930b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4940b57cec5SDimitry Andric    virtual result
4950b57cec5SDimitry Andric        do_in(state_type& __st,
4960b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
4970b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
4980b57cec5SDimitry Andric    virtual result
4990b57cec5SDimitry Andric        do_unshift(state_type& __st,
5000b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5019ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
5029ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
5030b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
5040b57cec5SDimitry Andric                          size_t __mx) const;
5059ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
5060b57cec5SDimitry Andric};
507349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
5080b57cec5SDimitry Andric
509e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
5100b57cec5SDimitry Andrictemplate <>
5110b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
5120b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
5130b57cec5SDimitry Andric{
5140b57cec5SDimitry Andric    unsigned long _Maxcode_;
5150b57cec5SDimitry Andric    codecvt_mode _Mode_;
5160b57cec5SDimitry Andricpublic:
5170b57cec5SDimitry Andric    typedef char32_t  intern_type;
5180b57cec5SDimitry Andric    typedef char      extern_type;
5190b57cec5SDimitry Andric    typedef mbstate_t state_type;
5200b57cec5SDimitry Andric
5210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5220b57cec5SDimitry Andric    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
5230b57cec5SDimitry Andric                            codecvt_mode _Mode)
5240b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
5250b57cec5SDimitry Andric          _Mode_(_Mode) {}
526e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
527e8d8bef9SDimitry Andric
5280b57cec5SDimitry Andricprotected:
5290b57cec5SDimitry Andric    virtual result
5300b57cec5SDimitry Andric        do_out(state_type& __st,
5310b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
5320b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5330b57cec5SDimitry Andric    virtual result
5340b57cec5SDimitry Andric        do_in(state_type& __st,
5350b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
5360b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
5370b57cec5SDimitry Andric    virtual result
5380b57cec5SDimitry Andric        do_unshift(state_type& __st,
5390b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5409ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
5419ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
5420b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
5430b57cec5SDimitry Andric                          size_t __mx) const;
5449ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
5450b57cec5SDimitry Andric};
5460b57cec5SDimitry Andric
547e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
5480b57cec5SDimitry Andrictemplate <>
5490b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
5500b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
5510b57cec5SDimitry Andric{
5520b57cec5SDimitry Andric    unsigned long _Maxcode_;
5530b57cec5SDimitry Andric    codecvt_mode _Mode_;
5540b57cec5SDimitry Andricpublic:
5550b57cec5SDimitry Andric    typedef char16_t  intern_type;
5560b57cec5SDimitry Andric    typedef char      extern_type;
5570b57cec5SDimitry Andric    typedef mbstate_t state_type;
5580b57cec5SDimitry Andric
5590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5600b57cec5SDimitry Andric    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
5610b57cec5SDimitry Andric                            codecvt_mode _Mode)
5620b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
5630b57cec5SDimitry Andric          _Mode_(_Mode) {}
564e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
565e8d8bef9SDimitry Andric
5660b57cec5SDimitry Andricprotected:
5670b57cec5SDimitry Andric    virtual result
5680b57cec5SDimitry Andric        do_out(state_type& __st,
5690b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
5700b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5710b57cec5SDimitry Andric    virtual result
5720b57cec5SDimitry Andric        do_in(state_type& __st,
5730b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
5740b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
5750b57cec5SDimitry Andric    virtual result
5760b57cec5SDimitry Andric        do_unshift(state_type& __st,
5770b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5789ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
5799ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
5800b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
5810b57cec5SDimitry Andric                          size_t __mx) const;
5829ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
5830b57cec5SDimitry Andric};
5840b57cec5SDimitry Andric
585*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
5860b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
5870b57cec5SDimitry Andric          codecvt_mode _Mode = (codecvt_mode)0>
588*81ad6265SDimitry Andricclass _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16
5890b57cec5SDimitry Andric    : public __codecvt_utf8_utf16<_Elem>
5900b57cec5SDimitry Andric{
5910b57cec5SDimitry Andricpublic:
5920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5930b57cec5SDimitry Andric    explicit codecvt_utf8_utf16(size_t __refs = 0)
5940b57cec5SDimitry Andric        : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
5950b57cec5SDimitry Andric
5960b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5970b57cec5SDimitry Andric    ~codecvt_utf8_utf16() {}
5980b57cec5SDimitry Andric};
599*81ad6265SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
6000b57cec5SDimitry Andric
6010b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
6020b57cec5SDimitry Andric
6030b57cec5SDimitry Andric#endif // _LIBCPP_CODECVT
604