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