codecvt 22 KB

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