xref: /freebsd/contrib/llvm-project/libcxx/include/codecvt (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric// -*- C++ -*-
2*349cc55cSDimitry 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>
590b57cec5SDimitry Andric
600b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
610b57cec5SDimitry Andric#pragma GCC system_header
620b57cec5SDimitry Andric#endif
630b57cec5SDimitry Andric
640b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
650b57cec5SDimitry Andric
660b57cec5SDimitry Andricenum codecvt_mode
670b57cec5SDimitry Andric{
680b57cec5SDimitry Andric    consume_header = 4,
690b57cec5SDimitry Andric    generate_header = 2,
700b57cec5SDimitry Andric    little_endian = 1
710b57cec5SDimitry Andric};
720b57cec5SDimitry Andric
730b57cec5SDimitry Andric// codecvt_utf8
740b57cec5SDimitry Andric
750b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8;
760b57cec5SDimitry Andric
77*349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
780b57cec5SDimitry Andrictemplate <>
790b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
800b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
810b57cec5SDimitry Andric{
820b57cec5SDimitry Andric    unsigned long _Maxcode_;
830b57cec5SDimitry Andric    codecvt_mode _Mode_;
840b57cec5SDimitry Andricpublic:
850b57cec5SDimitry Andric    typedef wchar_t   intern_type;
860b57cec5SDimitry Andric    typedef char      extern_type;
870b57cec5SDimitry Andric    typedef mbstate_t state_type;
880b57cec5SDimitry Andric
890b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
900b57cec5SDimitry Andric    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
910b57cec5SDimitry Andric                            codecvt_mode _Mode)
920b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
930b57cec5SDimitry Andric          _Mode_(_Mode) {}
940b57cec5SDimitry Andricprotected:
950b57cec5SDimitry Andric    virtual result
960b57cec5SDimitry Andric        do_out(state_type& __st,
970b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
980b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
990b57cec5SDimitry Andric    virtual result
1000b57cec5SDimitry Andric        do_in(state_type& __st,
1010b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1020b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1030b57cec5SDimitry Andric    virtual result
1040b57cec5SDimitry Andric        do_unshift(state_type& __st,
1050b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1069ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
1079ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
1080b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
1090b57cec5SDimitry Andric                          size_t __mx) const;
1109ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
1110b57cec5SDimitry Andric};
112*349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
1130b57cec5SDimitry Andric
114e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1150b57cec5SDimitry Andrictemplate <>
1160b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
1170b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
1180b57cec5SDimitry Andric{
1190b57cec5SDimitry Andric    unsigned long _Maxcode_;
1200b57cec5SDimitry Andric    codecvt_mode _Mode_;
1210b57cec5SDimitry Andricpublic:
1220b57cec5SDimitry Andric    typedef char16_t  intern_type;
1230b57cec5SDimitry Andric    typedef char      extern_type;
1240b57cec5SDimitry Andric    typedef mbstate_t state_type;
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1270b57cec5SDimitry Andric    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
1280b57cec5SDimitry Andric                            codecvt_mode _Mode)
1290b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
1300b57cec5SDimitry Andric          _Mode_(_Mode) {}
131e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
132e8d8bef9SDimitry Andric
1330b57cec5SDimitry Andricprotected:
1340b57cec5SDimitry Andric    virtual result
1350b57cec5SDimitry Andric        do_out(state_type& __st,
1360b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1370b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1380b57cec5SDimitry Andric    virtual result
1390b57cec5SDimitry Andric        do_in(state_type& __st,
1400b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1410b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1420b57cec5SDimitry Andric    virtual result
1430b57cec5SDimitry Andric        do_unshift(state_type& __st,
1440b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1459ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
1469ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
1470b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
1480b57cec5SDimitry Andric                          size_t __mx) const;
1499ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
1500b57cec5SDimitry Andric};
1510b57cec5SDimitry Andric
152e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
1530b57cec5SDimitry Andrictemplate <>
1540b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
1550b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
1560b57cec5SDimitry Andric{
1570b57cec5SDimitry Andric    unsigned long _Maxcode_;
1580b57cec5SDimitry Andric    codecvt_mode _Mode_;
1590b57cec5SDimitry Andricpublic:
1600b57cec5SDimitry Andric    typedef char32_t  intern_type;
1610b57cec5SDimitry Andric    typedef char      extern_type;
1620b57cec5SDimitry Andric    typedef mbstate_t state_type;
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1650b57cec5SDimitry Andric    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
1660b57cec5SDimitry Andric                            codecvt_mode _Mode)
1670b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
1680b57cec5SDimitry Andric          _Mode_(_Mode) {}
169e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
170e8d8bef9SDimitry Andric
1710b57cec5SDimitry Andricprotected:
1720b57cec5SDimitry Andric    virtual result
1730b57cec5SDimitry Andric        do_out(state_type& __st,
1740b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1750b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1760b57cec5SDimitry Andric    virtual result
1770b57cec5SDimitry Andric        do_in(state_type& __st,
1780b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1790b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1800b57cec5SDimitry Andric    virtual result
1810b57cec5SDimitry Andric        do_unshift(state_type& __st,
1820b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1839ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
1849ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
1850b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
1860b57cec5SDimitry Andric                          size_t __mx) const;
1879ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
1880b57cec5SDimitry Andric};
1890b57cec5SDimitry Andric
1900b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
1910b57cec5SDimitry Andric          codecvt_mode _Mode = (codecvt_mode)0>
1920b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_utf8
1930b57cec5SDimitry Andric    : public __codecvt_utf8<_Elem>
1940b57cec5SDimitry Andric{
1950b57cec5SDimitry Andricpublic:
1960b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
1970b57cec5SDimitry Andric    explicit codecvt_utf8(size_t __refs = 0)
1980b57cec5SDimitry Andric        : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2010b57cec5SDimitry Andric    ~codecvt_utf8() {}
2020b57cec5SDimitry Andric};
2030b57cec5SDimitry Andric
2040b57cec5SDimitry Andric// codecvt_utf16
2050b57cec5SDimitry Andric
2060b57cec5SDimitry Andrictemplate <class _Elem, bool _LittleEndian> class __codecvt_utf16;
2070b57cec5SDimitry Andric
208*349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2090b57cec5SDimitry Andrictemplate <>
2100b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
2110b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
2120b57cec5SDimitry Andric{
2130b57cec5SDimitry Andric    unsigned long _Maxcode_;
2140b57cec5SDimitry Andric    codecvt_mode _Mode_;
2150b57cec5SDimitry Andricpublic:
2160b57cec5SDimitry Andric    typedef wchar_t   intern_type;
2170b57cec5SDimitry Andric    typedef char      extern_type;
2180b57cec5SDimitry Andric    typedef mbstate_t state_type;
2190b57cec5SDimitry Andric
2200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2210b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
2220b57cec5SDimitry Andric                            codecvt_mode _Mode)
2230b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
2240b57cec5SDimitry Andric          _Mode_(_Mode) {}
2250b57cec5SDimitry Andricprotected:
2260b57cec5SDimitry Andric    virtual result
2270b57cec5SDimitry Andric        do_out(state_type& __st,
2280b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
2290b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2300b57cec5SDimitry Andric    virtual result
2310b57cec5SDimitry Andric        do_in(state_type& __st,
2320b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
2330b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
2340b57cec5SDimitry Andric    virtual result
2350b57cec5SDimitry Andric        do_unshift(state_type& __st,
2360b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2379ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
2389ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
2390b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
2400b57cec5SDimitry Andric                          size_t __mx) const;
2419ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
2420b57cec5SDimitry Andric};
2430b57cec5SDimitry Andric
2440b57cec5SDimitry Andrictemplate <>
2450b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
2460b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
2470b57cec5SDimitry Andric{
2480b57cec5SDimitry Andric    unsigned long _Maxcode_;
2490b57cec5SDimitry Andric    codecvt_mode _Mode_;
2500b57cec5SDimitry Andricpublic:
2510b57cec5SDimitry Andric    typedef wchar_t   intern_type;
2520b57cec5SDimitry Andric    typedef char      extern_type;
2530b57cec5SDimitry Andric    typedef mbstate_t state_type;
2540b57cec5SDimitry Andric
2550b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2560b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
2570b57cec5SDimitry Andric                            codecvt_mode _Mode)
2580b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
2590b57cec5SDimitry Andric          _Mode_(_Mode) {}
2600b57cec5SDimitry Andricprotected:
2610b57cec5SDimitry Andric    virtual result
2620b57cec5SDimitry Andric        do_out(state_type& __st,
2630b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
2640b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2650b57cec5SDimitry Andric    virtual result
2660b57cec5SDimitry Andric        do_in(state_type& __st,
2670b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
2680b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
2690b57cec5SDimitry Andric    virtual result
2700b57cec5SDimitry Andric        do_unshift(state_type& __st,
2710b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
2729ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
2739ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
2740b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
2750b57cec5SDimitry Andric                          size_t __mx) const;
2769ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
2770b57cec5SDimitry Andric};
278*349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
2790b57cec5SDimitry Andric
280e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
2810b57cec5SDimitry Andrictemplate <>
2820b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
2830b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
2840b57cec5SDimitry Andric{
2850b57cec5SDimitry Andric    unsigned long _Maxcode_;
2860b57cec5SDimitry Andric    codecvt_mode _Mode_;
2870b57cec5SDimitry Andricpublic:
2880b57cec5SDimitry Andric    typedef char16_t  intern_type;
2890b57cec5SDimitry Andric    typedef char      extern_type;
2900b57cec5SDimitry Andric    typedef mbstate_t state_type;
2910b57cec5SDimitry Andric
2920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2930b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
2940b57cec5SDimitry Andric                            codecvt_mode _Mode)
2950b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
2960b57cec5SDimitry Andric          _Mode_(_Mode) {}
297e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
298e8d8bef9SDimitry Andric
2990b57cec5SDimitry Andricprotected:
3000b57cec5SDimitry Andric    virtual result
3010b57cec5SDimitry Andric        do_out(state_type& __st,
3020b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
3030b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3040b57cec5SDimitry Andric    virtual result
3050b57cec5SDimitry Andric        do_in(state_type& __st,
3060b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
3070b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
3080b57cec5SDimitry Andric    virtual result
3090b57cec5SDimitry Andric        do_unshift(state_type& __st,
3100b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3119ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
3129ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
3130b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
3140b57cec5SDimitry Andric                          size_t __mx) const;
3159ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
3160b57cec5SDimitry Andric};
3170b57cec5SDimitry Andric
318e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3190b57cec5SDimitry Andrictemplate <>
3200b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
3210b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
3220b57cec5SDimitry Andric{
3230b57cec5SDimitry Andric    unsigned long _Maxcode_;
3240b57cec5SDimitry Andric    codecvt_mode _Mode_;
3250b57cec5SDimitry Andricpublic:
3260b57cec5SDimitry Andric    typedef char16_t  intern_type;
3270b57cec5SDimitry Andric    typedef char      extern_type;
3280b57cec5SDimitry Andric    typedef mbstate_t state_type;
3290b57cec5SDimitry Andric
3300b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3310b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
3320b57cec5SDimitry Andric                            codecvt_mode _Mode)
3330b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
3340b57cec5SDimitry Andric          _Mode_(_Mode) {}
335e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
336e8d8bef9SDimitry Andric
3370b57cec5SDimitry Andricprotected:
3380b57cec5SDimitry Andric    virtual result
3390b57cec5SDimitry Andric        do_out(state_type& __st,
3400b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
3410b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3420b57cec5SDimitry Andric    virtual result
3430b57cec5SDimitry Andric        do_in(state_type& __st,
3440b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
3450b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
3460b57cec5SDimitry Andric    virtual result
3470b57cec5SDimitry Andric        do_unshift(state_type& __st,
3480b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3499ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
3509ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
3510b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
3520b57cec5SDimitry Andric                          size_t __mx) const;
3539ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
3540b57cec5SDimitry Andric};
3550b57cec5SDimitry Andric
356e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3570b57cec5SDimitry Andrictemplate <>
3580b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
3590b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
3600b57cec5SDimitry Andric{
3610b57cec5SDimitry Andric    unsigned long _Maxcode_;
3620b57cec5SDimitry Andric    codecvt_mode _Mode_;
3630b57cec5SDimitry Andricpublic:
3640b57cec5SDimitry Andric    typedef char32_t  intern_type;
3650b57cec5SDimitry Andric    typedef char      extern_type;
3660b57cec5SDimitry Andric    typedef mbstate_t state_type;
3670b57cec5SDimitry Andric
3680b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3690b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
3700b57cec5SDimitry Andric                            codecvt_mode _Mode)
3710b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
3720b57cec5SDimitry Andric          _Mode_(_Mode) {}
373e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
374e8d8bef9SDimitry Andric
3750b57cec5SDimitry Andricprotected:
3760b57cec5SDimitry Andric    virtual result
3770b57cec5SDimitry Andric        do_out(state_type& __st,
3780b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
3790b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3800b57cec5SDimitry Andric    virtual result
3810b57cec5SDimitry Andric        do_in(state_type& __st,
3820b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
3830b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
3840b57cec5SDimitry Andric    virtual result
3850b57cec5SDimitry Andric        do_unshift(state_type& __st,
3860b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
3879ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
3889ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
3890b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
3900b57cec5SDimitry Andric                          size_t __mx) const;
3919ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
3920b57cec5SDimitry Andric};
3930b57cec5SDimitry Andric
394e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3950b57cec5SDimitry Andrictemplate <>
3960b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
3970b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
3980b57cec5SDimitry Andric{
3990b57cec5SDimitry Andric    unsigned long _Maxcode_;
4000b57cec5SDimitry Andric    codecvt_mode _Mode_;
4010b57cec5SDimitry Andricpublic:
4020b57cec5SDimitry Andric    typedef char32_t  intern_type;
4030b57cec5SDimitry Andric    typedef char      extern_type;
4040b57cec5SDimitry Andric    typedef mbstate_t state_type;
4050b57cec5SDimitry Andric
4060b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4070b57cec5SDimitry Andric    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
4080b57cec5SDimitry Andric                            codecvt_mode _Mode)
4090b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
4100b57cec5SDimitry Andric          _Mode_(_Mode) {}
411e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
412e8d8bef9SDimitry Andric
4130b57cec5SDimitry Andricprotected:
4140b57cec5SDimitry Andric    virtual result
4150b57cec5SDimitry Andric        do_out(state_type& __st,
4160b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
4170b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4180b57cec5SDimitry Andric    virtual result
4190b57cec5SDimitry Andric        do_in(state_type& __st,
4200b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
4210b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
4220b57cec5SDimitry Andric    virtual result
4230b57cec5SDimitry Andric        do_unshift(state_type& __st,
4240b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4259ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
4269ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
4270b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
4280b57cec5SDimitry Andric                          size_t __mx) const;
4299ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
4300b57cec5SDimitry Andric};
4310b57cec5SDimitry Andric
4320b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
4330b57cec5SDimitry Andric          codecvt_mode _Mode = (codecvt_mode)0>
4340b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_utf16
4350b57cec5SDimitry Andric    : public __codecvt_utf16<_Elem, _Mode & little_endian>
4360b57cec5SDimitry Andric{
4370b57cec5SDimitry Andricpublic:
4380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4390b57cec5SDimitry Andric    explicit codecvt_utf16(size_t __refs = 0)
4400b57cec5SDimitry Andric        : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
4410b57cec5SDimitry Andric
4420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4430b57cec5SDimitry Andric    ~codecvt_utf16() {}
4440b57cec5SDimitry Andric};
4450b57cec5SDimitry Andric
4460b57cec5SDimitry Andric// codecvt_utf8_utf16
4470b57cec5SDimitry Andric
4480b57cec5SDimitry Andrictemplate <class _Elem> class __codecvt_utf8_utf16;
4490b57cec5SDimitry Andric
450*349cc55cSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4510b57cec5SDimitry Andrictemplate <>
4520b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
4530b57cec5SDimitry Andric    : public codecvt<wchar_t, char, mbstate_t>
4540b57cec5SDimitry Andric{
4550b57cec5SDimitry Andric    unsigned long _Maxcode_;
4560b57cec5SDimitry Andric    codecvt_mode _Mode_;
4570b57cec5SDimitry Andricpublic:
4580b57cec5SDimitry Andric    typedef wchar_t   intern_type;
4590b57cec5SDimitry Andric    typedef char      extern_type;
4600b57cec5SDimitry Andric    typedef mbstate_t state_type;
4610b57cec5SDimitry Andric
4620b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4630b57cec5SDimitry Andric    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
4640b57cec5SDimitry Andric                            codecvt_mode _Mode)
4650b57cec5SDimitry Andric        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
4660b57cec5SDimitry Andric          _Mode_(_Mode) {}
4670b57cec5SDimitry Andricprotected:
4680b57cec5SDimitry Andric    virtual result
4690b57cec5SDimitry Andric        do_out(state_type& __st,
4700b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
4710b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4720b57cec5SDimitry Andric    virtual result
4730b57cec5SDimitry Andric        do_in(state_type& __st,
4740b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
4750b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
4760b57cec5SDimitry Andric    virtual result
4770b57cec5SDimitry Andric        do_unshift(state_type& __st,
4780b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
4799ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
4809ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
4810b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
4820b57cec5SDimitry Andric                          size_t __mx) const;
4839ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
4840b57cec5SDimitry Andric};
485*349cc55cSDimitry Andric#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
4860b57cec5SDimitry Andric
487e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4880b57cec5SDimitry Andrictemplate <>
4890b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
4900b57cec5SDimitry Andric    : public codecvt<char32_t, char, mbstate_t>
4910b57cec5SDimitry Andric{
4920b57cec5SDimitry Andric    unsigned long _Maxcode_;
4930b57cec5SDimitry Andric    codecvt_mode _Mode_;
4940b57cec5SDimitry Andricpublic:
4950b57cec5SDimitry Andric    typedef char32_t  intern_type;
4960b57cec5SDimitry Andric    typedef char      extern_type;
4970b57cec5SDimitry Andric    typedef mbstate_t state_type;
4980b57cec5SDimitry Andric
4990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5000b57cec5SDimitry Andric    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
5010b57cec5SDimitry Andric                            codecvt_mode _Mode)
5020b57cec5SDimitry Andric        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
5030b57cec5SDimitry Andric          _Mode_(_Mode) {}
504e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
505e8d8bef9SDimitry Andric
5060b57cec5SDimitry Andricprotected:
5070b57cec5SDimitry Andric    virtual result
5080b57cec5SDimitry Andric        do_out(state_type& __st,
5090b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
5100b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5110b57cec5SDimitry Andric    virtual result
5120b57cec5SDimitry Andric        do_in(state_type& __st,
5130b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
5140b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
5150b57cec5SDimitry Andric    virtual result
5160b57cec5SDimitry Andric        do_unshift(state_type& __st,
5170b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5189ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
5199ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
5200b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
5210b57cec5SDimitry Andric                          size_t __mx) const;
5229ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
5230b57cec5SDimitry Andric};
5240b57cec5SDimitry Andric
525e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_PUSH
5260b57cec5SDimitry Andrictemplate <>
5270b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
5280b57cec5SDimitry Andric    : public codecvt<char16_t, char, mbstate_t>
5290b57cec5SDimitry Andric{
5300b57cec5SDimitry Andric    unsigned long _Maxcode_;
5310b57cec5SDimitry Andric    codecvt_mode _Mode_;
5320b57cec5SDimitry Andricpublic:
5330b57cec5SDimitry Andric    typedef char16_t  intern_type;
5340b57cec5SDimitry Andric    typedef char      extern_type;
5350b57cec5SDimitry Andric    typedef mbstate_t state_type;
5360b57cec5SDimitry Andric
5370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5380b57cec5SDimitry Andric    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
5390b57cec5SDimitry Andric                            codecvt_mode _Mode)
5400b57cec5SDimitry Andric        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
5410b57cec5SDimitry Andric          _Mode_(_Mode) {}
542e8d8bef9SDimitry Andric_LIBCPP_SUPPRESS_DEPRECATED_POP
543e8d8bef9SDimitry Andric
5440b57cec5SDimitry Andricprotected:
5450b57cec5SDimitry Andric    virtual result
5460b57cec5SDimitry Andric        do_out(state_type& __st,
5470b57cec5SDimitry Andric               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
5480b57cec5SDimitry Andric               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5490b57cec5SDimitry Andric    virtual result
5500b57cec5SDimitry Andric        do_in(state_type& __st,
5510b57cec5SDimitry Andric              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
5520b57cec5SDimitry Andric              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
5530b57cec5SDimitry Andric    virtual result
5540b57cec5SDimitry Andric        do_unshift(state_type& __st,
5550b57cec5SDimitry Andric                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
5569ec406dcSDimitry Andric    virtual int do_encoding() const _NOEXCEPT;
5579ec406dcSDimitry Andric    virtual bool do_always_noconv() const _NOEXCEPT;
5580b57cec5SDimitry Andric    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
5590b57cec5SDimitry Andric                          size_t __mx) const;
5609ec406dcSDimitry Andric    virtual int do_max_length() const _NOEXCEPT;
5610b57cec5SDimitry Andric};
5620b57cec5SDimitry Andric
5630b57cec5SDimitry Andrictemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
5640b57cec5SDimitry Andric          codecvt_mode _Mode = (codecvt_mode)0>
5650b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
5660b57cec5SDimitry Andric    : public __codecvt_utf8_utf16<_Elem>
5670b57cec5SDimitry Andric{
5680b57cec5SDimitry Andricpublic:
5690b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5700b57cec5SDimitry Andric    explicit codecvt_utf8_utf16(size_t __refs = 0)
5710b57cec5SDimitry Andric        : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
5720b57cec5SDimitry Andric
5730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5740b57cec5SDimitry Andric    ~codecvt_utf8_utf16() {}
5750b57cec5SDimitry Andric};
5760b57cec5SDimitry Andric
5770b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
5780b57cec5SDimitry Andric
5790b57cec5SDimitry Andric#endif // _LIBCPP_CODECVT
580