xref: /minix3/external/bsd/libc++/dist/libcxx/include/codecvt (revision 4684ddb6aab0b36791c8099bc705d6140b3d05d0)
1*4684ddb6SLionel Sambuc// -*- C++ -*-
2*4684ddb6SLionel Sambuc//===-------------------------- codecvt -----------------------------------===//
3*4684ddb6SLionel Sambuc//
4*4684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
5*4684ddb6SLionel Sambuc//
6*4684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
7*4684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
8*4684ddb6SLionel Sambuc//
9*4684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
10*4684ddb6SLionel Sambuc
11*4684ddb6SLionel Sambuc#ifndef _LIBCPP_CODECVT
12*4684ddb6SLionel Sambuc#define _LIBCPP_CODECVT
13*4684ddb6SLionel Sambuc
14*4684ddb6SLionel Sambuc/*
15*4684ddb6SLionel Sambuc    codecvt synopsis
16*4684ddb6SLionel Sambuc
17*4684ddb6SLionel Sambucnamespace std
18*4684ddb6SLionel Sambuc{
19*4684ddb6SLionel Sambuc
20*4684ddb6SLionel Sambucenum codecvt_mode
21*4684ddb6SLionel Sambuc{
22*4684ddb6SLionel Sambuc    consume_header = 4,
23*4684ddb6SLionel Sambuc    generate_header = 2,
24*4684ddb6SLionel Sambuc    little_endian = 1
25*4684ddb6SLionel Sambuc};
26*4684ddb6SLionel Sambuc
27*4684ddb6SLionel Sambuctemplate <class Elem, unsigned long Maxcode = 0x10ffff,
28*4684ddb6SLionel Sambuc          codecvt_mode Mode = (codecvt_mode)0>
29*4684ddb6SLionel Sambucclass codecvt_utf8
30*4684ddb6SLionel Sambuc    : public codecvt<Elem, char, mbstate_t>
31*4684ddb6SLionel Sambuc{
32*4684ddb6SLionel Sambuc    explicit codecvt_utf8(size_t refs = 0);
33*4684ddb6SLionel Sambuc    ~codecvt_utf8();
34*4684ddb6SLionel Sambuc};
35*4684ddb6SLionel Sambuc
36*4684ddb6SLionel Sambuctemplate <class Elem, unsigned long Maxcode = 0x10ffff,
37*4684ddb6SLionel Sambuc          codecvt_mode Mode = (codecvt_mode)0>
38*4684ddb6SLionel Sambucclass codecvt_utf16
39*4684ddb6SLionel Sambuc    : public codecvt<Elem, char, mbstate_t>
40*4684ddb6SLionel Sambuc{
41*4684ddb6SLionel Sambuc    explicit codecvt_utf16(size_t refs = 0);
42*4684ddb6SLionel Sambuc    ~codecvt_utf16();
43*4684ddb6SLionel Sambuc};
44*4684ddb6SLionel Sambuc
45*4684ddb6SLionel Sambuctemplate <class Elem, unsigned long Maxcode = 0x10ffff,
46*4684ddb6SLionel Sambuc          codecvt_mode Mode = (codecvt_mode)0>
47*4684ddb6SLionel Sambucclass codecvt_utf8_utf16
48*4684ddb6SLionel Sambuc    : public codecvt<Elem, char, mbstate_t>
49*4684ddb6SLionel Sambuc{
50*4684ddb6SLionel Sambuc    explicit codecvt_utf8_utf16(size_t refs = 0);
51*4684ddb6SLionel Sambuc    ~codecvt_utf8_utf16();
52*4684ddb6SLionel Sambuc};
53*4684ddb6SLionel Sambuc
54*4684ddb6SLionel Sambuc}  // std
55*4684ddb6SLionel Sambuc
56*4684ddb6SLionel Sambuc*/
57*4684ddb6SLionel Sambuc
58*4684ddb6SLionel Sambuc#include <__config>
59*4684ddb6SLionel Sambuc#include <__locale>
60*4684ddb6SLionel Sambuc
61*4684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
62*4684ddb6SLionel Sambuc#pragma GCC system_header
63*4684ddb6SLionel Sambuc#endif
64*4684ddb6SLionel Sambuc
65*4684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
66*4684ddb6SLionel Sambuc
67*4684ddb6SLionel Sambucenum codecvt_mode
68*4684ddb6SLionel Sambuc{
69*4684ddb6SLionel Sambuc    consume_header = 4,
70*4684ddb6SLionel Sambuc    generate_header = 2,
71*4684ddb6SLionel Sambuc    little_endian = 1
72*4684ddb6SLionel Sambuc};
73*4684ddb6SLionel Sambuc
74*4684ddb6SLionel Sambuc// codecvt_utf8
75*4684ddb6SLionel Sambuc
76*4684ddb6SLionel Sambuctemplate <class _Elem> class __codecvt_utf8;
77*4684ddb6SLionel Sambuc
78*4684ddb6SLionel Sambuctemplate <>
79*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
80*4684ddb6SLionel Sambuc    : public codecvt<wchar_t, char, mbstate_t>
81*4684ddb6SLionel Sambuc{
82*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
83*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
84*4684ddb6SLionel Sambucpublic:
85*4684ddb6SLionel Sambuc    typedef wchar_t   intern_type;
86*4684ddb6SLionel Sambuc    typedef char      extern_type;
87*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
88*4684ddb6SLionel Sambuc
89*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
90*4684ddb6SLionel Sambuc    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
91*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
92*4684ddb6SLionel Sambuc        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
93*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
94*4684ddb6SLionel Sambucprotected:
95*4684ddb6SLionel Sambuc    virtual result
96*4684ddb6SLionel Sambuc        do_out(state_type& __st,
97*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
98*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
99*4684ddb6SLionel Sambuc    virtual result
100*4684ddb6SLionel Sambuc        do_in(state_type& __st,
101*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
102*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
103*4684ddb6SLionel Sambuc    virtual result
104*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
105*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
106*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
107*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
108*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
109*4684ddb6SLionel Sambuc                          size_t __mx) const;
110*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
111*4684ddb6SLionel Sambuc};
112*4684ddb6SLionel Sambuc
113*4684ddb6SLionel Sambuctemplate <>
114*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
115*4684ddb6SLionel Sambuc    : public codecvt<char16_t, char, mbstate_t>
116*4684ddb6SLionel Sambuc{
117*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
118*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
119*4684ddb6SLionel Sambucpublic:
120*4684ddb6SLionel Sambuc    typedef char16_t  intern_type;
121*4684ddb6SLionel Sambuc    typedef char      extern_type;
122*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
123*4684ddb6SLionel Sambuc
124*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
125*4684ddb6SLionel Sambuc    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
126*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
127*4684ddb6SLionel Sambuc        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
128*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
129*4684ddb6SLionel Sambucprotected:
130*4684ddb6SLionel Sambuc    virtual result
131*4684ddb6SLionel Sambuc        do_out(state_type& __st,
132*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
133*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
134*4684ddb6SLionel Sambuc    virtual result
135*4684ddb6SLionel Sambuc        do_in(state_type& __st,
136*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
137*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
138*4684ddb6SLionel Sambuc    virtual result
139*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
140*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
141*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
142*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
143*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
144*4684ddb6SLionel Sambuc                          size_t __mx) const;
145*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
146*4684ddb6SLionel Sambuc};
147*4684ddb6SLionel Sambuc
148*4684ddb6SLionel Sambuctemplate <>
149*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
150*4684ddb6SLionel Sambuc    : public codecvt<char32_t, char, mbstate_t>
151*4684ddb6SLionel Sambuc{
152*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
153*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
154*4684ddb6SLionel Sambucpublic:
155*4684ddb6SLionel Sambuc    typedef char32_t  intern_type;
156*4684ddb6SLionel Sambuc    typedef char      extern_type;
157*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
158*4684ddb6SLionel Sambuc
159*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
160*4684ddb6SLionel Sambuc    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
161*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
162*4684ddb6SLionel Sambuc        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
163*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
164*4684ddb6SLionel Sambucprotected:
165*4684ddb6SLionel Sambuc    virtual result
166*4684ddb6SLionel Sambuc        do_out(state_type& __st,
167*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
168*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
169*4684ddb6SLionel Sambuc    virtual result
170*4684ddb6SLionel Sambuc        do_in(state_type& __st,
171*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
172*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
173*4684ddb6SLionel Sambuc    virtual result
174*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
175*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
176*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
177*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
178*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
179*4684ddb6SLionel Sambuc                          size_t __mx) const;
180*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
181*4684ddb6SLionel Sambuc};
182*4684ddb6SLionel Sambuc
183*4684ddb6SLionel Sambuctemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
184*4684ddb6SLionel Sambuc          codecvt_mode _Mode = (codecvt_mode)0>
185*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY codecvt_utf8
186*4684ddb6SLionel Sambuc    : public __codecvt_utf8<_Elem>
187*4684ddb6SLionel Sambuc{
188*4684ddb6SLionel Sambucpublic:
189*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
190*4684ddb6SLionel Sambuc    explicit codecvt_utf8(size_t __refs = 0)
191*4684ddb6SLionel Sambuc        : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
192*4684ddb6SLionel Sambuc
193*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
194*4684ddb6SLionel Sambuc    ~codecvt_utf8() {}
195*4684ddb6SLionel Sambuc};
196*4684ddb6SLionel Sambuc
197*4684ddb6SLionel Sambuc// codecvt_utf16
198*4684ddb6SLionel Sambuc
199*4684ddb6SLionel Sambuctemplate <class _Elem, bool _LittleEndian> class __codecvt_utf16;
200*4684ddb6SLionel Sambuc
201*4684ddb6SLionel Sambuctemplate <>
202*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
203*4684ddb6SLionel Sambuc    : public codecvt<wchar_t, char, mbstate_t>
204*4684ddb6SLionel Sambuc{
205*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
206*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
207*4684ddb6SLionel Sambucpublic:
208*4684ddb6SLionel Sambuc    typedef wchar_t   intern_type;
209*4684ddb6SLionel Sambuc    typedef char      extern_type;
210*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
211*4684ddb6SLionel Sambuc
212*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
213*4684ddb6SLionel Sambuc    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
214*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
215*4684ddb6SLionel Sambuc        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
216*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
217*4684ddb6SLionel Sambucprotected:
218*4684ddb6SLionel Sambuc    virtual result
219*4684ddb6SLionel Sambuc        do_out(state_type& __st,
220*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
221*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
222*4684ddb6SLionel Sambuc    virtual result
223*4684ddb6SLionel Sambuc        do_in(state_type& __st,
224*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
225*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
226*4684ddb6SLionel Sambuc    virtual result
227*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
228*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
229*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
230*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
231*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
232*4684ddb6SLionel Sambuc                          size_t __mx) const;
233*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
234*4684ddb6SLionel Sambuc};
235*4684ddb6SLionel Sambuc
236*4684ddb6SLionel Sambuctemplate <>
237*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
238*4684ddb6SLionel Sambuc    : public codecvt<wchar_t, char, mbstate_t>
239*4684ddb6SLionel Sambuc{
240*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
241*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
242*4684ddb6SLionel Sambucpublic:
243*4684ddb6SLionel Sambuc    typedef wchar_t   intern_type;
244*4684ddb6SLionel Sambuc    typedef char      extern_type;
245*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
246*4684ddb6SLionel Sambuc
247*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
248*4684ddb6SLionel Sambuc    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
249*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
250*4684ddb6SLionel Sambuc        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
251*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
252*4684ddb6SLionel Sambucprotected:
253*4684ddb6SLionel Sambuc    virtual result
254*4684ddb6SLionel Sambuc        do_out(state_type& __st,
255*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
256*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
257*4684ddb6SLionel Sambuc    virtual result
258*4684ddb6SLionel Sambuc        do_in(state_type& __st,
259*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
260*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
261*4684ddb6SLionel Sambuc    virtual result
262*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
263*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
264*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
265*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
266*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
267*4684ddb6SLionel Sambuc                          size_t __mx) const;
268*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
269*4684ddb6SLionel Sambuc};
270*4684ddb6SLionel Sambuc
271*4684ddb6SLionel Sambuctemplate <>
272*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
273*4684ddb6SLionel Sambuc    : public codecvt<char16_t, char, mbstate_t>
274*4684ddb6SLionel Sambuc{
275*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
276*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
277*4684ddb6SLionel Sambucpublic:
278*4684ddb6SLionel Sambuc    typedef char16_t  intern_type;
279*4684ddb6SLionel Sambuc    typedef char      extern_type;
280*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
281*4684ddb6SLionel Sambuc
282*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
283*4684ddb6SLionel Sambuc    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
284*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
285*4684ddb6SLionel Sambuc        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
286*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
287*4684ddb6SLionel Sambucprotected:
288*4684ddb6SLionel Sambuc    virtual result
289*4684ddb6SLionel Sambuc        do_out(state_type& __st,
290*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
291*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
292*4684ddb6SLionel Sambuc    virtual result
293*4684ddb6SLionel Sambuc        do_in(state_type& __st,
294*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
295*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
296*4684ddb6SLionel Sambuc    virtual result
297*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
298*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
299*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
300*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
301*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
302*4684ddb6SLionel Sambuc                          size_t __mx) const;
303*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
304*4684ddb6SLionel Sambuc};
305*4684ddb6SLionel Sambuc
306*4684ddb6SLionel Sambuctemplate <>
307*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
308*4684ddb6SLionel Sambuc    : public codecvt<char16_t, char, mbstate_t>
309*4684ddb6SLionel Sambuc{
310*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
311*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
312*4684ddb6SLionel Sambucpublic:
313*4684ddb6SLionel Sambuc    typedef char16_t  intern_type;
314*4684ddb6SLionel Sambuc    typedef char      extern_type;
315*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
316*4684ddb6SLionel Sambuc
317*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
318*4684ddb6SLionel Sambuc    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
319*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
320*4684ddb6SLionel Sambuc        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
321*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
322*4684ddb6SLionel Sambucprotected:
323*4684ddb6SLionel Sambuc    virtual result
324*4684ddb6SLionel Sambuc        do_out(state_type& __st,
325*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
326*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
327*4684ddb6SLionel Sambuc    virtual result
328*4684ddb6SLionel Sambuc        do_in(state_type& __st,
329*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
330*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
331*4684ddb6SLionel Sambuc    virtual result
332*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
333*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
334*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
335*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
336*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
337*4684ddb6SLionel Sambuc                          size_t __mx) const;
338*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
339*4684ddb6SLionel Sambuc};
340*4684ddb6SLionel Sambuc
341*4684ddb6SLionel Sambuctemplate <>
342*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
343*4684ddb6SLionel Sambuc    : public codecvt<char32_t, char, mbstate_t>
344*4684ddb6SLionel Sambuc{
345*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
346*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
347*4684ddb6SLionel Sambucpublic:
348*4684ddb6SLionel Sambuc    typedef char32_t  intern_type;
349*4684ddb6SLionel Sambuc    typedef char      extern_type;
350*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
351*4684ddb6SLionel Sambuc
352*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
353*4684ddb6SLionel Sambuc    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
354*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
355*4684ddb6SLionel Sambuc        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
356*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
357*4684ddb6SLionel Sambucprotected:
358*4684ddb6SLionel Sambuc    virtual result
359*4684ddb6SLionel Sambuc        do_out(state_type& __st,
360*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
361*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
362*4684ddb6SLionel Sambuc    virtual result
363*4684ddb6SLionel Sambuc        do_in(state_type& __st,
364*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
365*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
366*4684ddb6SLionel Sambuc    virtual result
367*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
368*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
369*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
370*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
371*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
372*4684ddb6SLionel Sambuc                          size_t __mx) const;
373*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
374*4684ddb6SLionel Sambuc};
375*4684ddb6SLionel Sambuc
376*4684ddb6SLionel Sambuctemplate <>
377*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
378*4684ddb6SLionel Sambuc    : public codecvt<char32_t, char, mbstate_t>
379*4684ddb6SLionel Sambuc{
380*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
381*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
382*4684ddb6SLionel Sambucpublic:
383*4684ddb6SLionel Sambuc    typedef char32_t  intern_type;
384*4684ddb6SLionel Sambuc    typedef char      extern_type;
385*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
386*4684ddb6SLionel Sambuc
387*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
388*4684ddb6SLionel Sambuc    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
389*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
390*4684ddb6SLionel Sambuc        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
391*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
392*4684ddb6SLionel Sambucprotected:
393*4684ddb6SLionel Sambuc    virtual result
394*4684ddb6SLionel Sambuc        do_out(state_type& __st,
395*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
396*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
397*4684ddb6SLionel Sambuc    virtual result
398*4684ddb6SLionel Sambuc        do_in(state_type& __st,
399*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
400*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
401*4684ddb6SLionel Sambuc    virtual result
402*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
403*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
404*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
405*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
406*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
407*4684ddb6SLionel Sambuc                          size_t __mx) const;
408*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
409*4684ddb6SLionel Sambuc};
410*4684ddb6SLionel Sambuc
411*4684ddb6SLionel Sambuctemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
412*4684ddb6SLionel Sambuc          codecvt_mode _Mode = (codecvt_mode)0>
413*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY codecvt_utf16
414*4684ddb6SLionel Sambuc    : public __codecvt_utf16<_Elem, _Mode & little_endian>
415*4684ddb6SLionel Sambuc{
416*4684ddb6SLionel Sambucpublic:
417*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
418*4684ddb6SLionel Sambuc    explicit codecvt_utf16(size_t __refs = 0)
419*4684ddb6SLionel Sambuc        : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
420*4684ddb6SLionel Sambuc
421*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
422*4684ddb6SLionel Sambuc    ~codecvt_utf16() {}
423*4684ddb6SLionel Sambuc};
424*4684ddb6SLionel Sambuc
425*4684ddb6SLionel Sambuc// codecvt_utf8_utf16
426*4684ddb6SLionel Sambuc
427*4684ddb6SLionel Sambuctemplate <class _Elem> class __codecvt_utf8_utf16;
428*4684ddb6SLionel Sambuc
429*4684ddb6SLionel Sambuctemplate <>
430*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
431*4684ddb6SLionel Sambuc    : public codecvt<wchar_t, char, mbstate_t>
432*4684ddb6SLionel Sambuc{
433*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
434*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
435*4684ddb6SLionel Sambucpublic:
436*4684ddb6SLionel Sambuc    typedef wchar_t   intern_type;
437*4684ddb6SLionel Sambuc    typedef char      extern_type;
438*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
439*4684ddb6SLionel Sambuc
440*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
441*4684ddb6SLionel Sambuc    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
442*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
443*4684ddb6SLionel Sambuc        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
444*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
445*4684ddb6SLionel Sambucprotected:
446*4684ddb6SLionel Sambuc    virtual result
447*4684ddb6SLionel Sambuc        do_out(state_type& __st,
448*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
449*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
450*4684ddb6SLionel Sambuc    virtual result
451*4684ddb6SLionel Sambuc        do_in(state_type& __st,
452*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
453*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
454*4684ddb6SLionel Sambuc    virtual result
455*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
456*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
457*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
458*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
459*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
460*4684ddb6SLionel Sambuc                          size_t __mx) const;
461*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
462*4684ddb6SLionel Sambuc};
463*4684ddb6SLionel Sambuc
464*4684ddb6SLionel Sambuctemplate <>
465*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
466*4684ddb6SLionel Sambuc    : public codecvt<char32_t, char, mbstate_t>
467*4684ddb6SLionel Sambuc{
468*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
469*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
470*4684ddb6SLionel Sambucpublic:
471*4684ddb6SLionel Sambuc    typedef char32_t  intern_type;
472*4684ddb6SLionel Sambuc    typedef char      extern_type;
473*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
474*4684ddb6SLionel Sambuc
475*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
476*4684ddb6SLionel Sambuc    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
477*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
478*4684ddb6SLionel Sambuc        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
479*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
480*4684ddb6SLionel Sambucprotected:
481*4684ddb6SLionel Sambuc    virtual result
482*4684ddb6SLionel Sambuc        do_out(state_type& __st,
483*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
484*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
485*4684ddb6SLionel Sambuc    virtual result
486*4684ddb6SLionel Sambuc        do_in(state_type& __st,
487*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
488*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
489*4684ddb6SLionel Sambuc    virtual result
490*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
491*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
492*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
493*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
494*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
495*4684ddb6SLionel Sambuc                          size_t __mx) const;
496*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
497*4684ddb6SLionel Sambuc};
498*4684ddb6SLionel Sambuc
499*4684ddb6SLionel Sambuctemplate <>
500*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
501*4684ddb6SLionel Sambuc    : public codecvt<char16_t, char, mbstate_t>
502*4684ddb6SLionel Sambuc{
503*4684ddb6SLionel Sambuc    unsigned long _Maxcode_;
504*4684ddb6SLionel Sambuc    codecvt_mode _Mode_;
505*4684ddb6SLionel Sambucpublic:
506*4684ddb6SLionel Sambuc    typedef char16_t  intern_type;
507*4684ddb6SLionel Sambuc    typedef char      extern_type;
508*4684ddb6SLionel Sambuc    typedef mbstate_t state_type;
509*4684ddb6SLionel Sambuc
510*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
511*4684ddb6SLionel Sambuc    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
512*4684ddb6SLionel Sambuc                            codecvt_mode _Mode)
513*4684ddb6SLionel Sambuc        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
514*4684ddb6SLionel Sambuc          _Mode_(_Mode) {}
515*4684ddb6SLionel Sambucprotected:
516*4684ddb6SLionel Sambuc    virtual result
517*4684ddb6SLionel Sambuc        do_out(state_type& __st,
518*4684ddb6SLionel Sambuc               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
519*4684ddb6SLionel Sambuc               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
520*4684ddb6SLionel Sambuc    virtual result
521*4684ddb6SLionel Sambuc        do_in(state_type& __st,
522*4684ddb6SLionel Sambuc              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
523*4684ddb6SLionel Sambuc              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
524*4684ddb6SLionel Sambuc    virtual result
525*4684ddb6SLionel Sambuc        do_unshift(state_type& __st,
526*4684ddb6SLionel Sambuc                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
527*4684ddb6SLionel Sambuc    virtual int do_encoding() const throw();
528*4684ddb6SLionel Sambuc    virtual bool do_always_noconv() const throw();
529*4684ddb6SLionel Sambuc    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
530*4684ddb6SLionel Sambuc                          size_t __mx) const;
531*4684ddb6SLionel Sambuc    virtual int do_max_length() const throw();
532*4684ddb6SLionel Sambuc};
533*4684ddb6SLionel Sambuc
534*4684ddb6SLionel Sambuctemplate <class _Elem, unsigned long _Maxcode = 0x10ffff,
535*4684ddb6SLionel Sambuc          codecvt_mode _Mode = (codecvt_mode)0>
536*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY codecvt_utf8_utf16
537*4684ddb6SLionel Sambuc    : public __codecvt_utf8_utf16<_Elem>
538*4684ddb6SLionel Sambuc{
539*4684ddb6SLionel Sambucpublic:
540*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
541*4684ddb6SLionel Sambuc    explicit codecvt_utf8_utf16(size_t __refs = 0)
542*4684ddb6SLionel Sambuc        : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
543*4684ddb6SLionel Sambuc
544*4684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE
545*4684ddb6SLionel Sambuc    ~codecvt_utf8_utf16() {}
546*4684ddb6SLionel Sambuc};
547*4684ddb6SLionel Sambuc
548*4684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
549*4684ddb6SLionel Sambuc
550*4684ddb6SLionel Sambuc#endif  // _LIBCPP_CODECVT
551