* tree-vrp.c (vrp_prop): Move class to earlier point in the file.
[official-gcc.git] / libstdc++-v3 / src / c++98 / codecvt.cc
blob4255e18b1000dbde613a87df10ac252868bc5256
1 // Copyright (C) 2000-2017 Free Software Foundation, Inc.
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
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
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>
25 #include <locale>
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;
36 #endif
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())
42 { }
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))
48 { }
50 codecvt<char, char, mbstate_t>::
51 ~codecvt()
52 { _S_destroy_c_locale(_M_c_locale_codecvt); }
54 codecvt_base::result
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)."
64 __from_next = __from;
65 __to_next = __to;
66 return noconv;
69 codecvt_base::result
70 codecvt<char, char, mbstate_t>::
71 do_unshift(state_type&, extern_type* __to,
72 extern_type*, extern_type*& __to_next) const
74 __to_next = __to;
75 return noconv;
78 codecvt_base::result
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)."
87 __from_next = __from;
88 __to_next = __to;
89 return noconv;
92 int
93 codecvt<char, char, mbstate_t>::
94 do_encoding() const throw()
95 { return 1; }
97 bool
98 codecvt<char, char, mbstate_t>::
99 do_always_noconv() const throw()
100 { return true; }
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()
114 { return 1; }
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>::
131 ~codecvt()
132 { _S_destroy_c_locale(_M_c_locale_codecvt); }
134 codecvt_base::result
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
140 __to_next = __to;
141 return noconv;
144 bool
145 codecvt<wchar_t, char, mbstate_t>::
146 do_always_noconv() const throw()
147 { return false; }
148 #endif // _GLIBCXX_USE_WCHAR_T
150 _GLIBCXX_END_NAMESPACE_VERSION
151 } // namespace