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 namespace std
_GLIBCXX_VISIBILITY(default)
29 _GLIBCXX_BEGIN_NAMESPACE_VERSION
31 // Definitions for locale::id of standard facets that are specialized.
32 locale::id codecvt
<char, char, mbstate_t>::id
;
34 #ifdef _GLIBCXX_USE_WCHAR_T
35 locale::id codecvt
<wchar_t, char, mbstate_t>::id
;
38 codecvt
<char, char, mbstate_t>::
39 codecvt(size_t __refs
)
40 : __codecvt_abstract_base
<char, char, mbstate_t>(__refs
),
41 _M_c_locale_codecvt(_S_get_c_locale())
44 codecvt
<char, char, mbstate_t>::
45 codecvt(__c_locale __cloc
, size_t __refs
)
46 : __codecvt_abstract_base
<char, char, mbstate_t>(__refs
),
47 _M_c_locale_codecvt(_S_clone_c_locale(__cloc
))
50 codecvt
<char, char, mbstate_t>::
52 { _S_destroy_c_locale(_M_c_locale_codecvt
); }
55 codecvt
<char, char, mbstate_t>::
56 do_out(state_type
&, const intern_type
* __from
,
57 const intern_type
*, const intern_type
*& __from_next
,
58 extern_type
* __to
, extern_type
*,
59 extern_type
*& __to_next
) const
61 // _GLIBCXX_RESOLVE_LIB_DEFECTS
62 // According to the resolution of DR19, "If returns noconv [...]
63 // there are no changes to the values in [to, to_limit)."
70 codecvt
<char, char, mbstate_t>::
71 do_unshift(state_type
&, extern_type
* __to
,
72 extern_type
*, extern_type
*& __to_next
) const
79 codecvt
<char, char, mbstate_t>::
80 do_in(state_type
&, const extern_type
* __from
,
81 const extern_type
*, const extern_type
*& __from_next
,
82 intern_type
* __to
, intern_type
*, intern_type
*& __to_next
) const
84 // _GLIBCXX_RESOLVE_LIB_DEFECTS
85 // According to the resolution of DR19, "If returns noconv [...]
86 // there are no changes to the values in [to, to_limit)."
93 codecvt
<char, char, mbstate_t>::
94 do_encoding() const throw()
98 codecvt
<char, char, mbstate_t>::
99 do_always_noconv() const throw()
103 codecvt
<char, char, mbstate_t>::
104 do_length (state_type
&, const extern_type
* __from
,
105 const extern_type
* __end
, size_t __max
) const
107 size_t __d
= static_cast<size_t>(__end
- __from
);
108 return std::min(__max
, __d
);
112 codecvt
<char, char, mbstate_t>::
113 do_max_length() const throw()
116 #ifdef _GLIBCXX_USE_WCHAR_T
117 // codecvt<wchar_t, char, mbstate_t> required specialization
118 codecvt
<wchar_t, char, mbstate_t>::
119 codecvt(size_t __refs
)
120 : __codecvt_abstract_base
<wchar_t, char, mbstate_t>(__refs
),
121 _M_c_locale_codecvt(_S_get_c_locale())
124 codecvt
<wchar_t, char, mbstate_t>::
125 codecvt(__c_locale __cloc
, size_t __refs
)
126 : __codecvt_abstract_base
<wchar_t, char, mbstate_t>(__refs
),
127 _M_c_locale_codecvt(_S_clone_c_locale(__cloc
))
130 codecvt
<wchar_t, char, mbstate_t>::
132 { _S_destroy_c_locale(_M_c_locale_codecvt
); }
135 codecvt
<wchar_t, char, mbstate_t>::
136 do_unshift(state_type
&, extern_type
* __to
,
137 extern_type
*, extern_type
*& __to_next
) const
139 // XXX Probably wrong for stateful encodings
145 codecvt
<wchar_t, char, mbstate_t>::
146 do_always_noconv() const throw()
148 #endif // _GLIBCXX_USE_WCHAR_T
150 _GLIBCXX_END_NAMESPACE_VERSION