codecvt 22 KB

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