codecvt 21 KB

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