annotate libcxx/include/codecvt @ 150:1d019706d866

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