OSDN Git Service

2001-02-26 Phil Edwards <pme@sources.redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / src / locale-inst.cc
1 // Locale support -*- C++ -*-
2
3 // Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction.  Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License.  This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 //
31 // ISO C++ 14882: 22.1  Locales
32 //
33
34 #include <bits/std_clocale.h>
35 #include <bits/std_cstring.h>
36 #include <bits/std_cassert.h>
37 #include <bits/std_limits.h>
38 #include <exception>
39 #include <bits/std_stdexcept.h>
40 #include <bits/std_locale.h>
41 #include <bits/locale_facets.tcc>
42 #include <bits/std_istream.h>
43 #include <bits/std_ostream.h>
44
45 namespace std {
46
47   typedef ostreambuf_iterator<char, char_traits<char> > obuf_iterator;
48   typedef istreambuf_iterator<char, char_traits<char> > ibuf_iterator;
49   typedef ostreambuf_iterator<wchar_t, char_traits<wchar_t> > wobuf_iterator;
50   typedef istreambuf_iterator<wchar_t, char_traits<wchar_t> > wibuf_iterator;
51
52   // moneypunct, money_get, and money_put
53   template class moneypunct<char, false>;
54   template class moneypunct<char, true>;
55   template class moneypunct_byname<char, false>;
56   template class moneypunct_byname<char, true>;
57   template class money_get<char, obuf_iterator>;
58   template class money_put<char, obuf_iterator>;
59   template class money_get<char, ibuf_iterator>;
60   template class money_put<char, ibuf_iterator>;
61   template class _Format_cache<char>;
62
63 #ifdef _GLIBCPP_USE_WCHAR_T
64   template class moneypunct<wchar_t, false>;
65   template class moneypunct<wchar_t, true>;
66   template class moneypunct_byname<wchar_t, false>;
67   template class moneypunct_byname<wchar_t, true>;
68   template class money_get<wchar_t, wobuf_iterator>;
69   template class money_put<wchar_t, wobuf_iterator>;
70   template class money_get<wchar_t, wibuf_iterator>;
71   template class money_put<wchar_t, wibuf_iterator>;
72   template class _Format_cache<wchar_t>;
73 #endif
74
75   // numpunct, numpunct_byname, num_get, and num_put
76   template class numpunct<char>;
77   template class numpunct_byname<char>;
78   template class num_get<char, ibuf_iterator>;
79   template class num_put<char, obuf_iterator>;
80 #ifdef _GLIBCPP_USE_WCHAR_T
81   template class numpunct<wchar_t>;
82   template class numpunct_byname<wchar_t>;
83   template class num_get<wchar_t, wibuf_iterator>;
84   template class num_put<wchar_t, wobuf_iterator>;
85 #endif
86
87   // time_get and time_put
88   template class time_put<char, obuf_iterator>;
89   template class time_put_byname<char, obuf_iterator>;
90   template class time_get<char, ibuf_iterator>;
91   template class time_get_byname<char, ibuf_iterator>;
92
93 #ifdef _GLIBCPP_USE_WCHAR_T
94   template class time_put<wchar_t, wobuf_iterator>;
95   template class time_put_byname<wchar_t, wobuf_iterator>;
96   template class time_get<wchar_t, wibuf_iterator>;
97   template class time_get_byname<wchar_t, wibuf_iterator>;
98 #endif
99
100   // messages
101   template class messages<char>;
102   template class messages_byname<char>;
103 #ifdef _GLIBCPP_USE_WCHAR_T
104   template class messages<wchar_t>;
105   template class messages_byname<wchar_t>;
106 #endif
107   
108   // ctype
109   template class __ctype_abstract_base<char>;
110   template class ctype_byname<char>;
111 #ifdef _GLIBCPP_USE_WCHAR_T
112   template class __ctype_abstract_base<wchar_t>;
113   template class ctype_byname<wchar_t>;
114 #endif
115   
116   // codecvt
117   template class __codecvt_abstract_base<char, char, mbstate_t>;
118   template class __codecvt_abstract_base<wchar_t, char, mbstate_t>;
119   template class codecvt_byname<char, char, mbstate_t>;
120 #ifdef _GLIBCPP_USE_WCHAR_T
121   template class codecvt_byname<wchar_t, char, mbstate_t>;
122 #endif
123
124   // collate
125   template class collate<char>;
126   template class collate_byname<char>;
127   template class _Weekdaynames<char, int>;
128   template class _Monthnames<char, int>;
129 #ifdef _GLIBCPP_USE_WCHAR_T
130   template class collate<wchar_t>;
131   template class collate_byname<wchar_t>;
132   template class _Weekdaynames<wchar_t, int>;
133   template class _Monthnames<wchar_t, int>;
134 #endif
135     
136   // use_facet
137   template 
138     const num_put<char, obuf_iterator >& 
139     use_facet<num_put<char, obuf_iterator> >(const locale&);
140   template 
141     const num_get<char, ibuf_iterator >& 
142     use_facet<num_get<char, ibuf_iterator> >(const locale&);
143   template
144     const codecvt<char, char, mbstate_t>& 
145     use_facet<codecvt<char, char, mbstate_t> >(const locale&);
146   template
147     const numpunct<char>& 
148     use_facet<numpunct<char> >(const locale&);
149   template
150     const collate<char>& 
151     use_facet<collate<char> >(const locale&);
152 #ifdef _GLIBCPP_USE_WCHAR_T
153   template 
154     const num_put<wchar_t, wobuf_iterator>& 
155     use_facet<num_put<wchar_t, wobuf_iterator> >(const locale&);
156   template 
157     const num_get<wchar_t, wibuf_iterator>& 
158     use_facet<num_get<wchar_t, wibuf_iterator> >(const locale&);
159   template
160     const codecvt<wchar_t, char, mbstate_t>& 
161     use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&);
162   template
163     const numpunct<wchar_t>& 
164     use_facet<numpunct<wchar_t> >(const locale&);
165   template
166     const collate<wchar_t>& 
167     use_facet<collate<wchar_t> >(const locale&);
168 #endif
169
170   // has_facet
171   template 
172     bool
173     has_facet<numpunct<char> >(const locale &);
174 #ifdef _GLIBCPP_USE_WCHAR_T
175   template 
176     bool
177     has_facet<numpunct<wchar_t> >(const locale &);
178 #endif
179
180   //
181   // iterator
182   //
183   typedef vector<locale::facet*> vec_pfacet;
184   template 
185     void 
186     vec_pfacet::
187     insert(vec_pfacet::iterator, vec_pfacet::size_type, 
188            const vec_pfacet::value_type&);
189   template 
190     void 
191     vec_pfacet::
192     _M_fill_insert(vec_pfacet::iterator, vec_pfacet::size_type, 
193                    const vec_pfacet::value_type&);
194
195
196   typedef istreambuf_iterator<char, char_traits<char> > istreambuf_iter;
197   typedef ostreambuf_iterator<char, char_traits<char> > ostreambuf_iter;
198
199
200   template 
201     istreambuf_iter 
202     __match_parallel<istreambuf_iter, char>
203     (istreambuf_iter, istreambuf_iter, int, const string*, int*, int&, bool&);
204
205
206 #ifdef _GLIBCPP_USE_WCHAR_T
207   typedef istreambuf_iterator<wchar_t,char_traits<wchar_t> > wistreambuf_iter;
208   typedef ostreambuf_iterator<wchar_t,char_traits<wchar_t> > wostreambuf_iter;
209
210   template 
211     wistreambuf_iter 
212     __match_parallel<wistreambuf_iter, wchar_t>
213    (wistreambuf_iter, wistreambuf_iter, int, const wstring*, int*, int&, bool&);
214 #endif
215
216
217   //
218   // locale
219   //
220   template 
221     bool
222     locale::operator()(const string&, const string&) const;
223
224   template
225     ostreambuf_iter
226     __pad<char, ostreambuf_iter, output_iterator_tag>
227     (ostreambuf_iter, char, int, output_iterator_tag);
228
229   template 
230     ostreambuf_iter
231     __pad_numeric<char, ostreambuf_iter>
232     (ostreambuf_iter, ios_base::fmtflags, char, int, char const*, char const*, 
233      char const*);
234
235   template
236     char*
237     __group_digits<char>(char*, char, char const*, char const*, 
238                          char const*, char const*);
239
240   template 
241     ostreambuf_iter
242     __output_integer<char, ostreambuf_iter, unsigned long>
243     (ostreambuf_iter, ios_base &, char, bool, unsigned long);
244
245 #ifdef _GLIBCPP_USE_LONG_LONG
246   template
247     ostreambuf_iter
248     __output_integer<char, ostreambuf_iter, unsigned long long>
249     (ostreambuf_iter, ios_base &, char, bool, unsigned long long);
250 #endif
251
252 #ifdef _GLIBCPP_USE_WCHAR_T
253   template 
254     bool
255     locale::operator()(const wstring&, const wstring&) const;
256
257   typedef ostreambuf_iterator<wchar_t> wostreambuf_iter;
258
259   template
260     wostreambuf_iter
261     __pad<wchar_t, wostreambuf_iter, output_iterator_tag>
262     (wostreambuf_iter, wchar_t, int, output_iterator_tag);
263
264   template 
265     wostreambuf_iter
266     __pad_numeric<wchar_t, wostreambuf_iter>
267     (wostreambuf_iter, ios_base::fmtflags, wchar_t __fill, int, wchar_t const*,
268      wchar_t const*, wchar_t const*);
269
270   template
271     wchar_t*
272     __group_digits<wchar_t>(wchar_t*, wchar_t, char const*, char const*, 
273                             wchar_t const*, wchar_t const*);
274
275   template 
276     wostreambuf_iter
277     __output_integer<wchar_t, wostreambuf_iter, unsigned long>
278     (wostreambuf_iter, ios_base &, wchar_t, bool, unsigned long);
279
280 #ifdef _GLIBCPP_USE_LONG_LONG
281   template
282     wostreambuf_iter
283     __output_integer<wchar_t, wostreambuf_iter, unsigned long long>
284     (wostreambuf_iter, ios_base &, wchar_t, bool, unsigned long long);
285 #endif
286 #endif // _GLIBCPP_USE_WCHAR_T
287
288   template
289     void __sink_unused_warning<locale::facet*>(locale::facet*);
290
291   template 
292     locale::facet** 
293     fill_n<locale::facet**, size_t, locale::facet*>
294     (locale::facet**, size_t, locale::facet* const&);
295
296   template
297     __normal_iterator<locale::facet**, vector<locale::facet*> >
298     fill_n(__normal_iterator<locale::facet**, vector<locale::facet*> >,
299            size_t, locale::facet* const&);
300
301   template
302     void
303     fill(__normal_iterator<locale::facet**, vector<locale::facet*> >,
304          __normal_iterator<locale::facet**, vector<locale::facet*> >,
305          locale::facet* const&);
306
307