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