1*38fd1498Szrj // Copyright (C) 2000-2018 Free Software Foundation, Inc. 2*38fd1498Szrj // 3*38fd1498Szrj // This file is part of the GNU ISO C++ Library. This library is free 4*38fd1498Szrj // software; you can redistribute it and/or modify it under the 5*38fd1498Szrj // terms of the GNU General Public License as published by the 6*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option) 7*38fd1498Szrj // any later version. 8*38fd1498Szrj 9*38fd1498Szrj // This library is distributed in the hope that it will be useful, 10*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of 11*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*38fd1498Szrj // GNU General Public License for more details. 13*38fd1498Szrj 14*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional 15*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version 16*38fd1498Szrj // 3.1, as published by the Free Software Foundation. 17*38fd1498Szrj 18*38fd1498Szrj // You should have received a copy of the GNU General Public License and 19*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program; 20*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 21*38fd1498Szrj // <http://www.gnu.org/licenses/>. 22*38fd1498Szrj 23*38fd1498Szrj // Written by Benjamin Kosnik <bkoz@redhat.com> 24*38fd1498Szrj 25*38fd1498Szrj #include <locale> 26*38fd1498Szrj 27*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default) 28*38fd1498Szrj { 29*38fd1498Szrj _GLIBCXX_BEGIN_NAMESPACE_VERSION 30*38fd1498Szrj 31*38fd1498Szrj // Definitions for locale::id of standard facets that are specialized. 32*38fd1498Szrj locale::id codecvt<char, char, mbstate_t>::id; 33*38fd1498Szrj 34*38fd1498Szrj #ifdef _GLIBCXX_USE_WCHAR_T 35*38fd1498Szrj locale::id codecvt<wchar_t, char, mbstate_t>::id; 36*38fd1498Szrj #endif 37*38fd1498Szrj 38*38fd1498Szrj codecvt<char, char, mbstate_t>:: codecvt(size_t __refs)39*38fd1498Szrj codecvt(size_t __refs) 40*38fd1498Szrj : __codecvt_abstract_base<char, char, mbstate_t>(__refs), 41*38fd1498Szrj _M_c_locale_codecvt(_S_get_c_locale()) 42*38fd1498Szrj { } 43*38fd1498Szrj 44*38fd1498Szrj codecvt<char, char, mbstate_t>:: codecvt(__c_locale __cloc,size_t __refs)45*38fd1498Szrj codecvt(__c_locale __cloc, size_t __refs) 46*38fd1498Szrj : __codecvt_abstract_base<char, char, mbstate_t>(__refs), 47*38fd1498Szrj _M_c_locale_codecvt(_S_clone_c_locale(__cloc)) 48*38fd1498Szrj { } 49*38fd1498Szrj 50*38fd1498Szrj codecvt<char, char, mbstate_t>:: ~codecvt()51*38fd1498Szrj ~codecvt() 52*38fd1498Szrj { _S_destroy_c_locale(_M_c_locale_codecvt); } 53*38fd1498Szrj 54*38fd1498Szrj codecvt_base::result 55*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_out(state_type &,const intern_type * __from,const intern_type *,const intern_type * & __from_next,extern_type * __to,extern_type *,extern_type * & __to_next) const56*38fd1498Szrj do_out(state_type&, const intern_type* __from, 57*38fd1498Szrj const intern_type*, const intern_type*& __from_next, 58*38fd1498Szrj extern_type* __to, extern_type*, 59*38fd1498Szrj extern_type*& __to_next) const 60*38fd1498Szrj { 61*38fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 62*38fd1498Szrj // According to the resolution of DR19, "If returns noconv [...] 63*38fd1498Szrj // there are no changes to the values in [to, to_limit)." 64*38fd1498Szrj __from_next = __from; 65*38fd1498Szrj __to_next = __to; 66*38fd1498Szrj return noconv; 67*38fd1498Szrj } 68*38fd1498Szrj 69*38fd1498Szrj codecvt_base::result 70*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_unshift(state_type &,extern_type * __to,extern_type *,extern_type * & __to_next) const71*38fd1498Szrj do_unshift(state_type&, extern_type* __to, 72*38fd1498Szrj extern_type*, extern_type*& __to_next) const 73*38fd1498Szrj { 74*38fd1498Szrj __to_next = __to; 75*38fd1498Szrj return noconv; 76*38fd1498Szrj } 77*38fd1498Szrj 78*38fd1498Szrj codecvt_base::result 79*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_in(state_type &,const extern_type * __from,const extern_type *,const extern_type * & __from_next,intern_type * __to,intern_type *,intern_type * & __to_next) const80*38fd1498Szrj do_in(state_type&, const extern_type* __from, 81*38fd1498Szrj const extern_type*, const extern_type*& __from_next, 82*38fd1498Szrj intern_type* __to, intern_type*, intern_type*& __to_next) const 83*38fd1498Szrj { 84*38fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 85*38fd1498Szrj // According to the resolution of DR19, "If returns noconv [...] 86*38fd1498Szrj // there are no changes to the values in [to, to_limit)." 87*38fd1498Szrj __from_next = __from; 88*38fd1498Szrj __to_next = __to; 89*38fd1498Szrj return noconv; 90*38fd1498Szrj } 91*38fd1498Szrj 92*38fd1498Szrj int 93*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_encoding() const94*38fd1498Szrj do_encoding() const throw() 95*38fd1498Szrj { return 1; } 96*38fd1498Szrj 97*38fd1498Szrj bool 98*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_always_noconv() const99*38fd1498Szrj do_always_noconv() const throw() 100*38fd1498Szrj { return true; } 101*38fd1498Szrj 102*38fd1498Szrj int 103*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_length(state_type &,const extern_type * __from,const extern_type * __end,size_t __max) const104*38fd1498Szrj do_length (state_type&, const extern_type* __from, 105*38fd1498Szrj const extern_type* __end, size_t __max) const 106*38fd1498Szrj { 107*38fd1498Szrj size_t __d = static_cast<size_t>(__end - __from); 108*38fd1498Szrj return std::min(__max, __d); 109*38fd1498Szrj } 110*38fd1498Szrj 111*38fd1498Szrj int 112*38fd1498Szrj codecvt<char, char, mbstate_t>:: do_max_length() const113*38fd1498Szrj do_max_length() const throw() 114*38fd1498Szrj { return 1; } 115*38fd1498Szrj 116*38fd1498Szrj #ifdef _GLIBCXX_USE_WCHAR_T 117*38fd1498Szrj // codecvt<wchar_t, char, mbstate_t> required specialization 118*38fd1498Szrj codecvt<wchar_t, char, mbstate_t>:: codecvt(size_t __refs)119*38fd1498Szrj codecvt(size_t __refs) 120*38fd1498Szrj : __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs), 121*38fd1498Szrj _M_c_locale_codecvt(_S_get_c_locale()) 122*38fd1498Szrj { } 123*38fd1498Szrj 124*38fd1498Szrj codecvt<wchar_t, char, mbstate_t>:: codecvt(__c_locale __cloc,size_t __refs)125*38fd1498Szrj codecvt(__c_locale __cloc, size_t __refs) 126*38fd1498Szrj : __codecvt_abstract_base<wchar_t, char, mbstate_t>(__refs), 127*38fd1498Szrj _M_c_locale_codecvt(_S_clone_c_locale(__cloc)) 128*38fd1498Szrj { } 129*38fd1498Szrj 130*38fd1498Szrj codecvt<wchar_t, char, mbstate_t>:: ~codecvt()131*38fd1498Szrj ~codecvt() 132*38fd1498Szrj { _S_destroy_c_locale(_M_c_locale_codecvt); } 133*38fd1498Szrj 134*38fd1498Szrj codecvt_base::result 135*38fd1498Szrj codecvt<wchar_t, char, mbstate_t>:: do_unshift(state_type &,extern_type * __to,extern_type *,extern_type * & __to_next) const136*38fd1498Szrj do_unshift(state_type&, extern_type* __to, 137*38fd1498Szrj extern_type*, extern_type*& __to_next) const 138*38fd1498Szrj { 139*38fd1498Szrj // XXX Probably wrong for stateful encodings 140*38fd1498Szrj __to_next = __to; 141*38fd1498Szrj return noconv; 142*38fd1498Szrj } 143*38fd1498Szrj 144*38fd1498Szrj bool 145*38fd1498Szrj codecvt<wchar_t, char, mbstate_t>:: do_always_noconv() const146*38fd1498Szrj do_always_noconv() const throw() 147*38fd1498Szrj { return false; } 148*38fd1498Szrj #endif // _GLIBCXX_USE_WCHAR_T 149*38fd1498Szrj 150*38fd1498Szrj _GLIBCXX_END_NAMESPACE_VERSION 151*38fd1498Szrj } // namespace 152