1 // Copyright (C) 2000, 2002, 2004, 2005, 2009 Free Software Foundation, Inc.
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
6 // Free Software Foundation; either version 3, or (at your option)
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.
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.
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/>.
23 // Written by Benjamin Kosnik <bkoz@redhat.com>
27 _GLIBCXX_BEGIN_NAMESPACE(std
)
29 // Definitions for locale::id of standard facets that are specialized.
30 locale::id codecvt
<char, char, mbstate_t>::id
;
32 #ifdef _GLIBCXX_USE_WCHAR_T
33 locale::id codecvt
<wchar_t, char, mbstate_t>::id
;
36 codecvt
<char, char, mbstate_t>::
37 codecvt(size_t __refs
)
38 : __codecvt_abstract_base
<char, char, mbstate_t>(__refs
),
39 _M_c_locale_codecvt(_S_get_c_locale())
42 codecvt
<char, char, mbstate_t>::
43 codecvt(__c_locale __cloc
, size_t __refs
)
44 : __codecvt_abstract_base
<char, char, mbstate_t>(__refs
),
45 _M_c_locale_codecvt(_S_clone_c_locale(__cloc
))
48 codecvt
<char, char, mbstate_t>::
50 { _S_destroy_c_locale(_M_c_locale_codecvt
); }
53 codecvt
<char, char, mbstate_t>::
54 do_out(state_type
&, const intern_type
* __from
,
55 const intern_type
*, const intern_type
*& __from_next
,
56 extern_type
* __to
, extern_type
*,
57 extern_type
*& __to_next
) const
59 // _GLIBCXX_RESOLVE_LIB_DEFECTS
60 // According to the resolution of DR19, "If returns noconv [...]
61 // there are no changes to the values in [to, to_limit)."
68 codecvt
<char, char, mbstate_t>::
69 do_unshift(state_type
&, extern_type
* __to
,
70 extern_type
*, extern_type
*& __to_next
) const
77 codecvt
<char, char, mbstate_t>::
78 do_in(state_type
&, const extern_type
* __from
,
79 const extern_type
*, const extern_type
*& __from_next
,
80 intern_type
* __to
, intern_type
*, intern_type
*& __to_next
) const
82 // _GLIBCXX_RESOLVE_LIB_DEFECTS
83 // According to the resolution of DR19, "If returns noconv [...]
84 // there are no changes to the values in [to, to_limit)."
91 codecvt
<char, char, mbstate_t>::
92 do_encoding() const throw()
96 codecvt
<char, char, mbstate_t>::
97 do_always_noconv() const throw()
101 codecvt
<char, char, mbstate_t>::
102 do_length (state_type
&, const extern_type
* __from
,
103 const extern_type
* __end
, size_t __max
) const
105 size_t __d
= static_cast<size_t>(__end
- __from
);
106 return std::min(__max
, __d
);
110 codecvt
<char, char, mbstate_t>::
111 do_max_length() const throw()
114 #ifdef _GLIBCXX_USE_WCHAR_T
115 // codecvt<wchar_t, char, mbstate_t> required specialization
116 codecvt
<wchar_t, char, mbstate_t>::
117 codecvt(size_t __refs
)
118 : __codecvt_abstract_base
<wchar_t, char, mbstate_t>(__refs
),
119 _M_c_locale_codecvt(_S_get_c_locale())
122 codecvt
<wchar_t, char, mbstate_t>::
123 codecvt(__c_locale __cloc
, size_t __refs
)
124 : __codecvt_abstract_base
<wchar_t, char, mbstate_t>(__refs
),
125 _M_c_locale_codecvt(_S_clone_c_locale(__cloc
))
128 codecvt
<wchar_t, char, mbstate_t>::
130 { _S_destroy_c_locale(_M_c_locale_codecvt
); }
133 codecvt
<wchar_t, char, mbstate_t>::
134 do_unshift(state_type
&, extern_type
* __to
,
135 extern_type
*, extern_type
*& __to_next
) const
137 // XXX Probably wrong for stateful encodings
143 codecvt
<wchar_t, char, mbstate_t>::
144 do_always_noconv() const throw()
146 #endif // _GLIBCXX_USE_WCHAR_T
148 _GLIBCXX_END_NAMESPACE