14d5abbe8Smrg// <codecvt> -*- C++ -*- 24d5abbe8Smrg 3*b1e83836Smrg// Copyright (C) 2015-2022 Free Software Foundation, Inc. 44d5abbe8Smrg// 54d5abbe8Smrg// This file is part of the GNU ISO C++ Library. This library is free 64d5abbe8Smrg// software; you can redistribute it and/or modify it under the 74d5abbe8Smrg// terms of the GNU General Public License as published by the 84d5abbe8Smrg// Free Software Foundation; either version 3, or (at your option) 94d5abbe8Smrg// any later version. 104d5abbe8Smrg 114d5abbe8Smrg// This library is distributed in the hope that it will be useful, 124d5abbe8Smrg// but WITHOUT ANY WARRANTY; without even the implied warranty of 134d5abbe8Smrg// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 144d5abbe8Smrg// GNU General Public License for more details. 154d5abbe8Smrg 164d5abbe8Smrg// Under Section 7 of GPL version 3, you are granted additional 174d5abbe8Smrg// permissions described in the GCC Runtime Library Exception, version 184d5abbe8Smrg// 3.1, as published by the Free Software Foundation. 194d5abbe8Smrg 204d5abbe8Smrg// You should have received a copy of the GNU General Public License and 214d5abbe8Smrg// a copy of the GCC Runtime Library Exception along with this program; 224d5abbe8Smrg// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 234d5abbe8Smrg// <http://www.gnu.org/licenses/>. 244d5abbe8Smrg 254d5abbe8Smrg// ISO C++ 14882: 22.5 Standard code conversion facets 264d5abbe8Smrg 274d5abbe8Smrg/** @file include/codecvt 284d5abbe8Smrg * This is a Standard C++ Library header. 294d5abbe8Smrg */ 304d5abbe8Smrg 314d5abbe8Smrg#ifndef _GLIBCXX_CODECVT 324d5abbe8Smrg#define _GLIBCXX_CODECVT 1 334d5abbe8Smrg 344d5abbe8Smrg#pragma GCC system_header 354d5abbe8Smrg 364d5abbe8Smrg#if __cplusplus < 201103L 374d5abbe8Smrg# include <bits/c++0x_warning.h> 384d5abbe8Smrg#else 394d5abbe8Smrg 404d5abbe8Smrg#include <bits/locale_classes.h> 414d5abbe8Smrg#include <bits/codecvt.h> 424d5abbe8Smrg 434d5abbe8Smrgnamespace std _GLIBCXX_VISIBILITY(default) 444d5abbe8Smrg{ 454d5abbe8Smrg_GLIBCXX_BEGIN_NAMESPACE_VERSION 464d5abbe8Smrg 474d5abbe8Smrg enum codecvt_mode 484d5abbe8Smrg { 494d5abbe8Smrg consume_header = 4, 504d5abbe8Smrg generate_header = 2, 514d5abbe8Smrg little_endian = 1 524d5abbe8Smrg }; 534d5abbe8Smrg 544d5abbe8Smrg template<typename _Elem, unsigned long _Maxcode = 0x10ffff, 554d5abbe8Smrg codecvt_mode _Mode = (codecvt_mode)0> 564d5abbe8Smrg class codecvt_utf8 : public codecvt<_Elem, char, mbstate_t> 574d5abbe8Smrg { 584d5abbe8Smrg public: 594d5abbe8Smrg explicit 604d5abbe8Smrg codecvt_utf8(size_t __refs = 0); 614d5abbe8Smrg 624d5abbe8Smrg ~codecvt_utf8(); 634d5abbe8Smrg }; 644d5abbe8Smrg 654d5abbe8Smrg template<typename _Elem, unsigned long _Maxcode = 0x10ffff, 664d5abbe8Smrg codecvt_mode _Mode = (codecvt_mode)0> 674d5abbe8Smrg class codecvt_utf16 : public codecvt<_Elem, char, mbstate_t> 684d5abbe8Smrg { 694d5abbe8Smrg public: 704d5abbe8Smrg explicit 714d5abbe8Smrg codecvt_utf16(size_t __refs = 0); 724d5abbe8Smrg 734d5abbe8Smrg ~codecvt_utf16(); 744d5abbe8Smrg }; 754d5abbe8Smrg 764d5abbe8Smrg template<typename _Elem, unsigned long _Maxcode = 0x10ffff, 774d5abbe8Smrg codecvt_mode _Mode = (codecvt_mode)0> 784d5abbe8Smrg class codecvt_utf8_utf16 : public codecvt<_Elem, char, mbstate_t> 794d5abbe8Smrg { 804d5abbe8Smrg public: 814d5abbe8Smrg explicit 824d5abbe8Smrg codecvt_utf8_utf16(size_t __refs = 0); 834d5abbe8Smrg 844d5abbe8Smrg ~codecvt_utf8_utf16(); 854d5abbe8Smrg }; 864d5abbe8Smrg 874d5abbe8Smrg#define _GLIBCXX_CODECVT_SPECIALIZATION2(_NAME, _ELEM) \ 884d5abbe8Smrg template<> \ 894d5abbe8Smrg class _NAME<_ELEM> \ 904d5abbe8Smrg : public codecvt<_ELEM, char, mbstate_t> \ 914d5abbe8Smrg { \ 924d5abbe8Smrg public: \ 934d5abbe8Smrg typedef _ELEM intern_type; \ 944d5abbe8Smrg typedef char extern_type; \ 954d5abbe8Smrg typedef mbstate_t state_type; \ 964d5abbe8Smrg \ 974d5abbe8Smrg protected: \ 984d5abbe8Smrg _NAME(unsigned long __maxcode, codecvt_mode __mode, size_t __refs) \ 994d5abbe8Smrg : codecvt(__refs), _M_maxcode(__maxcode), _M_mode(__mode) { } \ 1004d5abbe8Smrg \ 1014d5abbe8Smrg virtual \ 1024d5abbe8Smrg ~_NAME(); \ 1034d5abbe8Smrg \ 1044d5abbe8Smrg virtual result \ 1054d5abbe8Smrg do_out(state_type& __state, const intern_type* __from, \ 1064d5abbe8Smrg const intern_type* __from_end, const intern_type*& __from_next, \ 1074d5abbe8Smrg extern_type* __to, extern_type* __to_end, \ 1084d5abbe8Smrg extern_type*& __to_next) const; \ 1094d5abbe8Smrg \ 1104d5abbe8Smrg virtual result \ 1114d5abbe8Smrg do_unshift(state_type& __state, \ 1124d5abbe8Smrg extern_type* __to, extern_type* __to_end, \ 1134d5abbe8Smrg extern_type*& __to_next) const; \ 1144d5abbe8Smrg \ 1154d5abbe8Smrg virtual result \ 1164d5abbe8Smrg do_in(state_type& __state, \ 1174d5abbe8Smrg const extern_type* __from, const extern_type* __from_end, \ 1184d5abbe8Smrg const extern_type*& __from_next, \ 1194d5abbe8Smrg intern_type* __to, intern_type* __to_end, \ 1204d5abbe8Smrg intern_type*& __to_next) const; \ 1214d5abbe8Smrg \ 1224d5abbe8Smrg virtual \ 1234d5abbe8Smrg int do_encoding() const throw(); \ 1244d5abbe8Smrg \ 1254d5abbe8Smrg virtual \ 1264d5abbe8Smrg bool do_always_noconv() const throw(); \ 1274d5abbe8Smrg \ 1284d5abbe8Smrg virtual \ 1294d5abbe8Smrg int do_length(state_type&, const extern_type* __from, \ 1304d5abbe8Smrg const extern_type* __end, size_t __max) const; \ 1314d5abbe8Smrg \ 1324d5abbe8Smrg virtual int \ 1334d5abbe8Smrg do_max_length() const throw(); \ 1344d5abbe8Smrg \ 1354d5abbe8Smrg private: \ 1364d5abbe8Smrg unsigned long _M_maxcode; \ 1374d5abbe8Smrg codecvt_mode _M_mode; \ 1384d5abbe8Smrg } 1394d5abbe8Smrg 1404d5abbe8Smrg#define _GLIBCXX_CODECVT_SPECIALIZATION(_NAME, _ELEM) \ 1414d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION2(__ ## _NAME ## _base, _ELEM); \ 1424d5abbe8Smrg template<unsigned long _Maxcode, codecvt_mode _Mode> \ 1434d5abbe8Smrg class _NAME<_ELEM, _Maxcode, _Mode> \ 1444d5abbe8Smrg : public __ ## _NAME ## _base<_ELEM> \ 1454d5abbe8Smrg { \ 1464d5abbe8Smrg public: \ 1474d5abbe8Smrg explicit \ 1484d5abbe8Smrg _NAME(size_t __refs = 0) \ 1494d5abbe8Smrg : __ ## _NAME ## _base<_ELEM>(std::min(_Maxcode, 0x10fffful), \ 1504d5abbe8Smrg _Mode, __refs) \ 1514d5abbe8Smrg { } \ 1524d5abbe8Smrg } 1534d5abbe8Smrg 1544d5abbe8Smrg template<typename _Elem> class __codecvt_utf8_base; 1554d5abbe8Smrg template<typename _Elem> class __codecvt_utf16_base; 1564d5abbe8Smrg template<typename _Elem> class __codecvt_utf8_utf16_base; 1574d5abbe8Smrg 1584d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char16_t); 1594d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char16_t); 1604d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char16_t); 1614d5abbe8Smrg 1624d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char32_t); 1634d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char32_t); 1644d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char32_t); 1654d5abbe8Smrg 1664d5abbe8Smrg#ifdef _GLIBCXX_USE_WCHAR_T 1674d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, wchar_t); 1684d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, wchar_t); 1694d5abbe8Smrg _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, wchar_t); 1704d5abbe8Smrg#endif 1714d5abbe8Smrg 1724d5abbe8Smrg_GLIBCXX_END_NAMESPACE_VERSION 1734d5abbe8Smrg} // namespace 1744d5abbe8Smrg 175181254a7Smrg#endif // C++11 1764d5abbe8Smrg 1774d5abbe8Smrg#endif /* _GLIBCXX_CODECVT */ 178