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