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