codecvt 21 KB

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