1*e4b17023SJohn Marino // Locale support -*- C++ -*-
2*e4b17023SJohn Marino 
3*e4b17023SJohn Marino // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4*e4b17023SJohn Marino //
5*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library.  This library is free
6*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the
7*e4b17023SJohn Marino // terms of the GNU General Public License as published by the
8*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option)
9*e4b17023SJohn Marino // any later version.
10*e4b17023SJohn Marino 
11*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful,
12*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*e4b17023SJohn Marino // GNU General Public License for more details.
15*e4b17023SJohn Marino 
16*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional
17*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version
18*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation.
19*e4b17023SJohn Marino 
20*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and
21*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program;
22*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>.
24*e4b17023SJohn Marino 
25*e4b17023SJohn Marino /** @file bits/locale_facets_nonio.h
26*e4b17023SJohn Marino  *  This is an internal header file, included by other library headers.
27*e4b17023SJohn Marino  *  Do not attempt to use it directly. @headername{locale}
28*e4b17023SJohn Marino  */
29*e4b17023SJohn Marino 
30*e4b17023SJohn Marino //
31*e4b17023SJohn Marino // ISO C++ 14882: 22.1  Locales
32*e4b17023SJohn Marino //
33*e4b17023SJohn Marino 
34*e4b17023SJohn Marino #ifndef _LOCALE_FACETS_NONIO_H
35*e4b17023SJohn Marino #define _LOCALE_FACETS_NONIO_H 1
36*e4b17023SJohn Marino 
37*e4b17023SJohn Marino #pragma GCC system_header
38*e4b17023SJohn Marino 
39*e4b17023SJohn Marino #include <ctime>	// For struct tm
40*e4b17023SJohn Marino 
_GLIBCXX_VISIBILITY(default)41*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
42*e4b17023SJohn Marino {
43*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION
44*e4b17023SJohn Marino 
45*e4b17023SJohn Marino   /**
46*e4b17023SJohn Marino    *  @brief  Time format ordering data.
47*e4b17023SJohn Marino    *  @ingroup locales
48*e4b17023SJohn Marino    *
49*e4b17023SJohn Marino    *  This class provides an enum representing different orderings of
50*e4b17023SJohn Marino    *  time: day, month, and year.
51*e4b17023SJohn Marino   */
52*e4b17023SJohn Marino   class time_base
53*e4b17023SJohn Marino   {
54*e4b17023SJohn Marino   public:
55*e4b17023SJohn Marino     enum dateorder { no_order, dmy, mdy, ymd, ydm };
56*e4b17023SJohn Marino   };
57*e4b17023SJohn Marino 
58*e4b17023SJohn Marino   template<typename _CharT>
59*e4b17023SJohn Marino     struct __timepunct_cache : public locale::facet
60*e4b17023SJohn Marino     {
61*e4b17023SJohn Marino       // List of all known timezones, with GMT first.
62*e4b17023SJohn Marino       static const _CharT*		_S_timezones[14];
63*e4b17023SJohn Marino 
64*e4b17023SJohn Marino       const _CharT*			_M_date_format;
65*e4b17023SJohn Marino       const _CharT*			_M_date_era_format;
66*e4b17023SJohn Marino       const _CharT*			_M_time_format;
67*e4b17023SJohn Marino       const _CharT*			_M_time_era_format;
68*e4b17023SJohn Marino       const _CharT*			_M_date_time_format;
69*e4b17023SJohn Marino       const _CharT*			_M_date_time_era_format;
70*e4b17023SJohn Marino       const _CharT*			_M_am;
71*e4b17023SJohn Marino       const _CharT*			_M_pm;
72*e4b17023SJohn Marino       const _CharT*			_M_am_pm_format;
73*e4b17023SJohn Marino 
74*e4b17023SJohn Marino       // Day names, starting with "C"'s Sunday.
75*e4b17023SJohn Marino       const _CharT*			_M_day1;
76*e4b17023SJohn Marino       const _CharT*			_M_day2;
77*e4b17023SJohn Marino       const _CharT*			_M_day3;
78*e4b17023SJohn Marino       const _CharT*			_M_day4;
79*e4b17023SJohn Marino       const _CharT*			_M_day5;
80*e4b17023SJohn Marino       const _CharT*			_M_day6;
81*e4b17023SJohn Marino       const _CharT*			_M_day7;
82*e4b17023SJohn Marino 
83*e4b17023SJohn Marino       // Abbreviated day names, starting with "C"'s Sun.
84*e4b17023SJohn Marino       const _CharT*			_M_aday1;
85*e4b17023SJohn Marino       const _CharT*			_M_aday2;
86*e4b17023SJohn Marino       const _CharT*			_M_aday3;
87*e4b17023SJohn Marino       const _CharT*			_M_aday4;
88*e4b17023SJohn Marino       const _CharT*			_M_aday5;
89*e4b17023SJohn Marino       const _CharT*			_M_aday6;
90*e4b17023SJohn Marino       const _CharT*			_M_aday7;
91*e4b17023SJohn Marino 
92*e4b17023SJohn Marino       // Month names, starting with "C"'s January.
93*e4b17023SJohn Marino       const _CharT*			_M_month01;
94*e4b17023SJohn Marino       const _CharT*			_M_month02;
95*e4b17023SJohn Marino       const _CharT*			_M_month03;
96*e4b17023SJohn Marino       const _CharT*			_M_month04;
97*e4b17023SJohn Marino       const _CharT*			_M_month05;
98*e4b17023SJohn Marino       const _CharT*			_M_month06;
99*e4b17023SJohn Marino       const _CharT*			_M_month07;
100*e4b17023SJohn Marino       const _CharT*			_M_month08;
101*e4b17023SJohn Marino       const _CharT*			_M_month09;
102*e4b17023SJohn Marino       const _CharT*			_M_month10;
103*e4b17023SJohn Marino       const _CharT*			_M_month11;
104*e4b17023SJohn Marino       const _CharT*			_M_month12;
105*e4b17023SJohn Marino 
106*e4b17023SJohn Marino       // Abbreviated month names, starting with "C"'s Jan.
107*e4b17023SJohn Marino       const _CharT*			_M_amonth01;
108*e4b17023SJohn Marino       const _CharT*			_M_amonth02;
109*e4b17023SJohn Marino       const _CharT*			_M_amonth03;
110*e4b17023SJohn Marino       const _CharT*			_M_amonth04;
111*e4b17023SJohn Marino       const _CharT*			_M_amonth05;
112*e4b17023SJohn Marino       const _CharT*			_M_amonth06;
113*e4b17023SJohn Marino       const _CharT*			_M_amonth07;
114*e4b17023SJohn Marino       const _CharT*			_M_amonth08;
115*e4b17023SJohn Marino       const _CharT*			_M_amonth09;
116*e4b17023SJohn Marino       const _CharT*			_M_amonth10;
117*e4b17023SJohn Marino       const _CharT*			_M_amonth11;
118*e4b17023SJohn Marino       const _CharT*			_M_amonth12;
119*e4b17023SJohn Marino 
120*e4b17023SJohn Marino       bool				_M_allocated;
121*e4b17023SJohn Marino 
122*e4b17023SJohn Marino       __timepunct_cache(size_t __refs = 0) : facet(__refs),
123*e4b17023SJohn Marino       _M_date_format(0), _M_date_era_format(0), _M_time_format(0),
124*e4b17023SJohn Marino       _M_time_era_format(0), _M_date_time_format(0),
125*e4b17023SJohn Marino       _M_date_time_era_format(0), _M_am(0), _M_pm(0),
126*e4b17023SJohn Marino       _M_am_pm_format(0), _M_day1(0), _M_day2(0), _M_day3(0),
127*e4b17023SJohn Marino       _M_day4(0), _M_day5(0), _M_day6(0), _M_day7(0),
128*e4b17023SJohn Marino       _M_aday1(0), _M_aday2(0), _M_aday3(0), _M_aday4(0),
129*e4b17023SJohn Marino       _M_aday5(0), _M_aday6(0), _M_aday7(0), _M_month01(0),
130*e4b17023SJohn Marino       _M_month02(0), _M_month03(0), _M_month04(0), _M_month05(0),
131*e4b17023SJohn Marino       _M_month06(0), _M_month07(0), _M_month08(0), _M_month09(0),
132*e4b17023SJohn Marino       _M_month10(0), _M_month11(0), _M_month12(0), _M_amonth01(0),
133*e4b17023SJohn Marino       _M_amonth02(0), _M_amonth03(0), _M_amonth04(0),
134*e4b17023SJohn Marino       _M_amonth05(0), _M_amonth06(0), _M_amonth07(0),
135*e4b17023SJohn Marino       _M_amonth08(0), _M_amonth09(0), _M_amonth10(0),
136*e4b17023SJohn Marino       _M_amonth11(0), _M_amonth12(0), _M_allocated(false)
137*e4b17023SJohn Marino       { }
138*e4b17023SJohn Marino 
139*e4b17023SJohn Marino       ~__timepunct_cache();
140*e4b17023SJohn Marino 
141*e4b17023SJohn Marino       void
142*e4b17023SJohn Marino       _M_cache(const locale& __loc);
143*e4b17023SJohn Marino 
144*e4b17023SJohn Marino     private:
145*e4b17023SJohn Marino       __timepunct_cache&
146*e4b17023SJohn Marino       operator=(const __timepunct_cache&);
147*e4b17023SJohn Marino 
148*e4b17023SJohn Marino       explicit
149*e4b17023SJohn Marino       __timepunct_cache(const __timepunct_cache&);
150*e4b17023SJohn Marino     };
151*e4b17023SJohn Marino 
152*e4b17023SJohn Marino   template<typename _CharT>
153*e4b17023SJohn Marino     __timepunct_cache<_CharT>::~__timepunct_cache()
154*e4b17023SJohn Marino     {
155*e4b17023SJohn Marino       if (_M_allocated)
156*e4b17023SJohn Marino 	{
157*e4b17023SJohn Marino 	  // Unused.
158*e4b17023SJohn Marino 	}
159*e4b17023SJohn Marino     }
160*e4b17023SJohn Marino 
161*e4b17023SJohn Marino   // Specializations.
162*e4b17023SJohn Marino   template<>
163*e4b17023SJohn Marino     const char*
164*e4b17023SJohn Marino     __timepunct_cache<char>::_S_timezones[14];
165*e4b17023SJohn Marino 
166*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
167*e4b17023SJohn Marino   template<>
168*e4b17023SJohn Marino     const wchar_t*
169*e4b17023SJohn Marino     __timepunct_cache<wchar_t>::_S_timezones[14];
170*e4b17023SJohn Marino #endif
171*e4b17023SJohn Marino 
172*e4b17023SJohn Marino   // Generic.
173*e4b17023SJohn Marino   template<typename _CharT>
174*e4b17023SJohn Marino     const _CharT* __timepunct_cache<_CharT>::_S_timezones[14];
175*e4b17023SJohn Marino 
176*e4b17023SJohn Marino   template<typename _CharT>
177*e4b17023SJohn Marino     class __timepunct : public locale::facet
178*e4b17023SJohn Marino     {
179*e4b17023SJohn Marino     public:
180*e4b17023SJohn Marino       // Types:
181*e4b17023SJohn Marino       typedef _CharT			__char_type;
182*e4b17023SJohn Marino       typedef basic_string<_CharT>	__string_type;
183*e4b17023SJohn Marino       typedef __timepunct_cache<_CharT>	__cache_type;
184*e4b17023SJohn Marino 
185*e4b17023SJohn Marino     protected:
186*e4b17023SJohn Marino       __cache_type*			_M_data;
187*e4b17023SJohn Marino       __c_locale			_M_c_locale_timepunct;
188*e4b17023SJohn Marino       const char*			_M_name_timepunct;
189*e4b17023SJohn Marino 
190*e4b17023SJohn Marino     public:
191*e4b17023SJohn Marino       /// Numpunct facet id.
192*e4b17023SJohn Marino       static locale::id			id;
193*e4b17023SJohn Marino 
194*e4b17023SJohn Marino       explicit
195*e4b17023SJohn Marino       __timepunct(size_t __refs = 0);
196*e4b17023SJohn Marino 
197*e4b17023SJohn Marino       explicit
198*e4b17023SJohn Marino       __timepunct(__cache_type* __cache, size_t __refs = 0);
199*e4b17023SJohn Marino 
200*e4b17023SJohn Marino       /**
201*e4b17023SJohn Marino        *  @brief  Internal constructor. Not for general use.
202*e4b17023SJohn Marino        *
203*e4b17023SJohn Marino        *  This is a constructor for use by the library itself to set up new
204*e4b17023SJohn Marino        *  locales.
205*e4b17023SJohn Marino        *
206*e4b17023SJohn Marino        *  @param __cloc  The C locale.
207*e4b17023SJohn Marino        *  @param __s  The name of a locale.
208*e4b17023SJohn Marino        *  @param refs  Passed to the base facet class.
209*e4b17023SJohn Marino       */
210*e4b17023SJohn Marino       explicit
211*e4b17023SJohn Marino       __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
212*e4b17023SJohn Marino 
213*e4b17023SJohn Marino       // FIXME: for error checking purposes _M_put should return the return
214*e4b17023SJohn Marino       // value of strftime/wcsftime.
215*e4b17023SJohn Marino       void
216*e4b17023SJohn Marino       _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
217*e4b17023SJohn Marino 	     const tm* __tm) const throw ();
218*e4b17023SJohn Marino 
219*e4b17023SJohn Marino       void
220*e4b17023SJohn Marino       _M_date_formats(const _CharT** __date) const
221*e4b17023SJohn Marino       {
222*e4b17023SJohn Marino 	// Always have default first.
223*e4b17023SJohn Marino 	__date[0] = _M_data->_M_date_format;
224*e4b17023SJohn Marino 	__date[1] = _M_data->_M_date_era_format;
225*e4b17023SJohn Marino       }
226*e4b17023SJohn Marino 
227*e4b17023SJohn Marino       void
228*e4b17023SJohn Marino       _M_time_formats(const _CharT** __time) const
229*e4b17023SJohn Marino       {
230*e4b17023SJohn Marino 	// Always have default first.
231*e4b17023SJohn Marino 	__time[0] = _M_data->_M_time_format;
232*e4b17023SJohn Marino 	__time[1] = _M_data->_M_time_era_format;
233*e4b17023SJohn Marino       }
234*e4b17023SJohn Marino 
235*e4b17023SJohn Marino       void
236*e4b17023SJohn Marino       _M_date_time_formats(const _CharT** __dt) const
237*e4b17023SJohn Marino       {
238*e4b17023SJohn Marino 	// Always have default first.
239*e4b17023SJohn Marino 	__dt[0] = _M_data->_M_date_time_format;
240*e4b17023SJohn Marino 	__dt[1] = _M_data->_M_date_time_era_format;
241*e4b17023SJohn Marino       }
242*e4b17023SJohn Marino 
243*e4b17023SJohn Marino       void
244*e4b17023SJohn Marino       _M_am_pm_format(const _CharT* __ampm) const
245*e4b17023SJohn Marino       { __ampm = _M_data->_M_am_pm_format; }
246*e4b17023SJohn Marino 
247*e4b17023SJohn Marino       void
248*e4b17023SJohn Marino       _M_am_pm(const _CharT** __ampm) const
249*e4b17023SJohn Marino       {
250*e4b17023SJohn Marino 	__ampm[0] = _M_data->_M_am;
251*e4b17023SJohn Marino 	__ampm[1] = _M_data->_M_pm;
252*e4b17023SJohn Marino       }
253*e4b17023SJohn Marino 
254*e4b17023SJohn Marino       void
255*e4b17023SJohn Marino       _M_days(const _CharT** __days) const
256*e4b17023SJohn Marino       {
257*e4b17023SJohn Marino 	__days[0] = _M_data->_M_day1;
258*e4b17023SJohn Marino 	__days[1] = _M_data->_M_day2;
259*e4b17023SJohn Marino 	__days[2] = _M_data->_M_day3;
260*e4b17023SJohn Marino 	__days[3] = _M_data->_M_day4;
261*e4b17023SJohn Marino 	__days[4] = _M_data->_M_day5;
262*e4b17023SJohn Marino 	__days[5] = _M_data->_M_day6;
263*e4b17023SJohn Marino 	__days[6] = _M_data->_M_day7;
264*e4b17023SJohn Marino       }
265*e4b17023SJohn Marino 
266*e4b17023SJohn Marino       void
267*e4b17023SJohn Marino       _M_days_abbreviated(const _CharT** __days) const
268*e4b17023SJohn Marino       {
269*e4b17023SJohn Marino 	__days[0] = _M_data->_M_aday1;
270*e4b17023SJohn Marino 	__days[1] = _M_data->_M_aday2;
271*e4b17023SJohn Marino 	__days[2] = _M_data->_M_aday3;
272*e4b17023SJohn Marino 	__days[3] = _M_data->_M_aday4;
273*e4b17023SJohn Marino 	__days[4] = _M_data->_M_aday5;
274*e4b17023SJohn Marino 	__days[5] = _M_data->_M_aday6;
275*e4b17023SJohn Marino 	__days[6] = _M_data->_M_aday7;
276*e4b17023SJohn Marino       }
277*e4b17023SJohn Marino 
278*e4b17023SJohn Marino       void
279*e4b17023SJohn Marino       _M_months(const _CharT** __months) const
280*e4b17023SJohn Marino       {
281*e4b17023SJohn Marino 	__months[0] = _M_data->_M_month01;
282*e4b17023SJohn Marino 	__months[1] = _M_data->_M_month02;
283*e4b17023SJohn Marino 	__months[2] = _M_data->_M_month03;
284*e4b17023SJohn Marino 	__months[3] = _M_data->_M_month04;
285*e4b17023SJohn Marino 	__months[4] = _M_data->_M_month05;
286*e4b17023SJohn Marino 	__months[5] = _M_data->_M_month06;
287*e4b17023SJohn Marino 	__months[6] = _M_data->_M_month07;
288*e4b17023SJohn Marino 	__months[7] = _M_data->_M_month08;
289*e4b17023SJohn Marino 	__months[8] = _M_data->_M_month09;
290*e4b17023SJohn Marino 	__months[9] = _M_data->_M_month10;
291*e4b17023SJohn Marino 	__months[10] = _M_data->_M_month11;
292*e4b17023SJohn Marino 	__months[11] = _M_data->_M_month12;
293*e4b17023SJohn Marino       }
294*e4b17023SJohn Marino 
295*e4b17023SJohn Marino       void
296*e4b17023SJohn Marino       _M_months_abbreviated(const _CharT** __months) const
297*e4b17023SJohn Marino       {
298*e4b17023SJohn Marino 	__months[0] = _M_data->_M_amonth01;
299*e4b17023SJohn Marino 	__months[1] = _M_data->_M_amonth02;
300*e4b17023SJohn Marino 	__months[2] = _M_data->_M_amonth03;
301*e4b17023SJohn Marino 	__months[3] = _M_data->_M_amonth04;
302*e4b17023SJohn Marino 	__months[4] = _M_data->_M_amonth05;
303*e4b17023SJohn Marino 	__months[5] = _M_data->_M_amonth06;
304*e4b17023SJohn Marino 	__months[6] = _M_data->_M_amonth07;
305*e4b17023SJohn Marino 	__months[7] = _M_data->_M_amonth08;
306*e4b17023SJohn Marino 	__months[8] = _M_data->_M_amonth09;
307*e4b17023SJohn Marino 	__months[9] = _M_data->_M_amonth10;
308*e4b17023SJohn Marino 	__months[10] = _M_data->_M_amonth11;
309*e4b17023SJohn Marino 	__months[11] = _M_data->_M_amonth12;
310*e4b17023SJohn Marino       }
311*e4b17023SJohn Marino 
312*e4b17023SJohn Marino     protected:
313*e4b17023SJohn Marino       virtual
314*e4b17023SJohn Marino       ~__timepunct();
315*e4b17023SJohn Marino 
316*e4b17023SJohn Marino       // For use at construction time only.
317*e4b17023SJohn Marino       void
318*e4b17023SJohn Marino       _M_initialize_timepunct(__c_locale __cloc = 0);
319*e4b17023SJohn Marino     };
320*e4b17023SJohn Marino 
321*e4b17023SJohn Marino   template<typename _CharT>
322*e4b17023SJohn Marino     locale::id __timepunct<_CharT>::id;
323*e4b17023SJohn Marino 
324*e4b17023SJohn Marino   // Specializations.
325*e4b17023SJohn Marino   template<>
326*e4b17023SJohn Marino     void
327*e4b17023SJohn Marino     __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc);
328*e4b17023SJohn Marino 
329*e4b17023SJohn Marino   template<>
330*e4b17023SJohn Marino     void
331*e4b17023SJohn Marino     __timepunct<char>::_M_put(char*, size_t, const char*, const tm*) const throw ();
332*e4b17023SJohn Marino 
333*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
334*e4b17023SJohn Marino   template<>
335*e4b17023SJohn Marino     void
336*e4b17023SJohn Marino     __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc);
337*e4b17023SJohn Marino 
338*e4b17023SJohn Marino   template<>
339*e4b17023SJohn Marino     void
340*e4b17023SJohn Marino     __timepunct<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
341*e4b17023SJohn Marino 				 const tm*) const throw ();
342*e4b17023SJohn Marino #endif
343*e4b17023SJohn Marino 
344*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION
345*e4b17023SJohn Marino } // namespace
346*e4b17023SJohn Marino 
347*e4b17023SJohn Marino   // Include host and configuration specific timepunct functions.
348*e4b17023SJohn Marino   #include <bits/time_members.h>
349*e4b17023SJohn Marino 
_GLIBCXX_VISIBILITY(default)350*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
351*e4b17023SJohn Marino {
352*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION
353*e4b17023SJohn Marino 
354*e4b17023SJohn Marino   /**
355*e4b17023SJohn Marino    *  @brief  Primary class template time_get.
356*e4b17023SJohn Marino    *  @ingroup locales
357*e4b17023SJohn Marino    *
358*e4b17023SJohn Marino    *  This facet encapsulates the code to parse and return a date or
359*e4b17023SJohn Marino    *  time from a string.  It is used by the istream numeric
360*e4b17023SJohn Marino    *  extraction operators.
361*e4b17023SJohn Marino    *
362*e4b17023SJohn Marino    *  The time_get template uses protected virtual functions to provide the
363*e4b17023SJohn Marino    *  actual results.  The public accessors forward the call to the virtual
364*e4b17023SJohn Marino    *  functions.  These virtual functions are hooks for developers to
365*e4b17023SJohn Marino    *  implement the behavior they require from the time_get facet.
366*e4b17023SJohn Marino   */
367*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
368*e4b17023SJohn Marino     class time_get : public locale::facet, public time_base
369*e4b17023SJohn Marino     {
370*e4b17023SJohn Marino     public:
371*e4b17023SJohn Marino       // Types:
372*e4b17023SJohn Marino       //@{
373*e4b17023SJohn Marino       /// Public typedefs
374*e4b17023SJohn Marino       typedef _CharT			char_type;
375*e4b17023SJohn Marino       typedef _InIter			iter_type;
376*e4b17023SJohn Marino       //@}
377*e4b17023SJohn Marino       typedef basic_string<_CharT>	__string_type;
378*e4b17023SJohn Marino 
379*e4b17023SJohn Marino       /// Numpunct facet id.
380*e4b17023SJohn Marino       static locale::id			id;
381*e4b17023SJohn Marino 
382*e4b17023SJohn Marino       /**
383*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
384*e4b17023SJohn Marino        *
385*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
386*e4b17023SJohn Marino        *
387*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
388*e4b17023SJohn Marino       */
389*e4b17023SJohn Marino       explicit
390*e4b17023SJohn Marino       time_get(size_t __refs = 0)
391*e4b17023SJohn Marino       : facet (__refs) { }
392*e4b17023SJohn Marino 
393*e4b17023SJohn Marino       /**
394*e4b17023SJohn Marino        *  @brief  Return preferred order of month, day, and year.
395*e4b17023SJohn Marino        *
396*e4b17023SJohn Marino        *  This function returns an enum from timebase::dateorder giving the
397*e4b17023SJohn Marino        *  preferred ordering if the format @a x given to time_put::put() only
398*e4b17023SJohn Marino        *  uses month, day, and year.  If the format @a x for the associated
399*e4b17023SJohn Marino        *  locale uses other fields, this function returns
400*e4b17023SJohn Marino        *  timebase::dateorder::noorder.
401*e4b17023SJohn Marino        *
402*e4b17023SJohn Marino        *  NOTE: The library always returns noorder at the moment.
403*e4b17023SJohn Marino        *
404*e4b17023SJohn Marino        *  @return  A member of timebase::dateorder.
405*e4b17023SJohn Marino       */
406*e4b17023SJohn Marino       dateorder
407*e4b17023SJohn Marino       date_order()  const
408*e4b17023SJohn Marino       { return this->do_date_order(); }
409*e4b17023SJohn Marino 
410*e4b17023SJohn Marino       /**
411*e4b17023SJohn Marino        *  @brief  Parse input time string.
412*e4b17023SJohn Marino        *
413*e4b17023SJohn Marino        *  This function parses a time according to the format @a X and puts the
414*e4b17023SJohn Marino        *  results into a user-supplied struct tm.  The result is returned by
415*e4b17023SJohn Marino        *  calling time_get::do_get_time().
416*e4b17023SJohn Marino        *
417*e4b17023SJohn Marino        *  If there is a valid time string according to format @a X, @a tm will
418*e4b17023SJohn Marino        *  be filled in accordingly and the returned iterator will point to the
419*e4b17023SJohn Marino        *  first character beyond the time string.  If an error occurs before
420*e4b17023SJohn Marino        *  the end, err |= ios_base::failbit.  If parsing reads all the
421*e4b17023SJohn Marino        *  characters, err |= ios_base::eofbit.
422*e4b17023SJohn Marino        *
423*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
424*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
425*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
426*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
427*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
428*e4b17023SJohn Marino        *  @return  Iterator to first char beyond time string.
429*e4b17023SJohn Marino       */
430*e4b17023SJohn Marino       iter_type
431*e4b17023SJohn Marino       get_time(iter_type __beg, iter_type __end, ios_base& __io,
432*e4b17023SJohn Marino 	       ios_base::iostate& __err, tm* __tm)  const
433*e4b17023SJohn Marino       { return this->do_get_time(__beg, __end, __io, __err, __tm); }
434*e4b17023SJohn Marino 
435*e4b17023SJohn Marino       /**
436*e4b17023SJohn Marino        *  @brief  Parse input date string.
437*e4b17023SJohn Marino        *
438*e4b17023SJohn Marino        *  This function parses a date according to the format @a x and puts the
439*e4b17023SJohn Marino        *  results into a user-supplied struct tm.  The result is returned by
440*e4b17023SJohn Marino        *  calling time_get::do_get_date().
441*e4b17023SJohn Marino        *
442*e4b17023SJohn Marino        *  If there is a valid date string according to format @a x, @a tm will
443*e4b17023SJohn Marino        *  be filled in accordingly and the returned iterator will point to the
444*e4b17023SJohn Marino        *  first character beyond the date string.  If an error occurs before
445*e4b17023SJohn Marino        *  the end, err |= ios_base::failbit.  If parsing reads all the
446*e4b17023SJohn Marino        *  characters, err |= ios_base::eofbit.
447*e4b17023SJohn Marino        *
448*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
449*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
450*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
451*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
452*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
453*e4b17023SJohn Marino        *  @return  Iterator to first char beyond date string.
454*e4b17023SJohn Marino       */
455*e4b17023SJohn Marino       iter_type
456*e4b17023SJohn Marino       get_date(iter_type __beg, iter_type __end, ios_base& __io,
457*e4b17023SJohn Marino 	       ios_base::iostate& __err, tm* __tm)  const
458*e4b17023SJohn Marino       { return this->do_get_date(__beg, __end, __io, __err, __tm); }
459*e4b17023SJohn Marino 
460*e4b17023SJohn Marino       /**
461*e4b17023SJohn Marino        *  @brief  Parse input weekday string.
462*e4b17023SJohn Marino        *
463*e4b17023SJohn Marino        *  This function parses a weekday name and puts the results into a
464*e4b17023SJohn Marino        *  user-supplied struct tm.  The result is returned by calling
465*e4b17023SJohn Marino        *  time_get::do_get_weekday().
466*e4b17023SJohn Marino        *
467*e4b17023SJohn Marino        *  Parsing starts by parsing an abbreviated weekday name.  If a valid
468*e4b17023SJohn Marino        *  abbreviation is followed by a character that would lead to the full
469*e4b17023SJohn Marino        *  weekday name, parsing continues until the full name is found or an
470*e4b17023SJohn Marino        *  error occurs.  Otherwise parsing finishes at the end of the
471*e4b17023SJohn Marino        *  abbreviated name.
472*e4b17023SJohn Marino        *
473*e4b17023SJohn Marino        *  If an error occurs before the end, err |= ios_base::failbit.  If
474*e4b17023SJohn Marino        *  parsing reads all the characters, err |= ios_base::eofbit.
475*e4b17023SJohn Marino        *
476*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
477*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
478*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
479*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
480*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
481*e4b17023SJohn Marino        *  @return  Iterator to first char beyond weekday name.
482*e4b17023SJohn Marino       */
483*e4b17023SJohn Marino       iter_type
484*e4b17023SJohn Marino       get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
485*e4b17023SJohn Marino 		  ios_base::iostate& __err, tm* __tm) const
486*e4b17023SJohn Marino       { return this->do_get_weekday(__beg, __end, __io, __err, __tm); }
487*e4b17023SJohn Marino 
488*e4b17023SJohn Marino       /**
489*e4b17023SJohn Marino        *  @brief  Parse input month string.
490*e4b17023SJohn Marino        *
491*e4b17023SJohn Marino        *  This function parses a month name and puts the results into a
492*e4b17023SJohn Marino        *  user-supplied struct tm.  The result is returned by calling
493*e4b17023SJohn Marino        *  time_get::do_get_monthname().
494*e4b17023SJohn Marino        *
495*e4b17023SJohn Marino        *  Parsing starts by parsing an abbreviated month name.  If a valid
496*e4b17023SJohn Marino        *  abbreviation is followed by a character that would lead to the full
497*e4b17023SJohn Marino        *  month name, parsing continues until the full name is found or an
498*e4b17023SJohn Marino        *  error occurs.  Otherwise parsing finishes at the end of the
499*e4b17023SJohn Marino        *  abbreviated name.
500*e4b17023SJohn Marino        *
501*e4b17023SJohn Marino        *  If an error occurs before the end, err |= ios_base::failbit.  If
502*e4b17023SJohn Marino        *  parsing reads all the characters, err |=
503*e4b17023SJohn Marino        *  ios_base::eofbit.
504*e4b17023SJohn Marino        *
505*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
506*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
507*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
508*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
509*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
510*e4b17023SJohn Marino        *  @return  Iterator to first char beyond month name.
511*e4b17023SJohn Marino       */
512*e4b17023SJohn Marino       iter_type
513*e4b17023SJohn Marino       get_monthname(iter_type __beg, iter_type __end, ios_base& __io,
514*e4b17023SJohn Marino 		    ios_base::iostate& __err, tm* __tm) const
515*e4b17023SJohn Marino       { return this->do_get_monthname(__beg, __end, __io, __err, __tm); }
516*e4b17023SJohn Marino 
517*e4b17023SJohn Marino       /**
518*e4b17023SJohn Marino        *  @brief  Parse input year string.
519*e4b17023SJohn Marino        *
520*e4b17023SJohn Marino        *  This function reads up to 4 characters to parse a year string and
521*e4b17023SJohn Marino        *  puts the results into a user-supplied struct tm.  The result is
522*e4b17023SJohn Marino        *  returned by calling time_get::do_get_year().
523*e4b17023SJohn Marino        *
524*e4b17023SJohn Marino        *  4 consecutive digits are interpreted as a full year.  If there are
525*e4b17023SJohn Marino        *  exactly 2 consecutive digits, the library interprets this as the
526*e4b17023SJohn Marino        *  number of years since 1900.
527*e4b17023SJohn Marino        *
528*e4b17023SJohn Marino        *  If an error occurs before the end, err |= ios_base::failbit.  If
529*e4b17023SJohn Marino        *  parsing reads all the characters, err |= ios_base::eofbit.
530*e4b17023SJohn Marino        *
531*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
532*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
533*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
534*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
535*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
536*e4b17023SJohn Marino        *  @return  Iterator to first char beyond year.
537*e4b17023SJohn Marino       */
538*e4b17023SJohn Marino       iter_type
539*e4b17023SJohn Marino       get_year(iter_type __beg, iter_type __end, ios_base& __io,
540*e4b17023SJohn Marino 	       ios_base::iostate& __err, tm* __tm) const
541*e4b17023SJohn Marino       { return this->do_get_year(__beg, __end, __io, __err, __tm); }
542*e4b17023SJohn Marino 
543*e4b17023SJohn Marino     protected:
544*e4b17023SJohn Marino       /// Destructor.
545*e4b17023SJohn Marino       virtual
546*e4b17023SJohn Marino       ~time_get() { }
547*e4b17023SJohn Marino 
548*e4b17023SJohn Marino       /**
549*e4b17023SJohn Marino        *  @brief  Return preferred order of month, day, and year.
550*e4b17023SJohn Marino        *
551*e4b17023SJohn Marino        *  This function returns an enum from timebase::dateorder giving the
552*e4b17023SJohn Marino        *  preferred ordering if the format @a x given to time_put::put() only
553*e4b17023SJohn Marino        *  uses month, day, and year.  This function is a hook for derived
554*e4b17023SJohn Marino        *  classes to change the value returned.
555*e4b17023SJohn Marino        *
556*e4b17023SJohn Marino        *  @return  A member of timebase::dateorder.
557*e4b17023SJohn Marino       */
558*e4b17023SJohn Marino       virtual dateorder
559*e4b17023SJohn Marino       do_date_order() const;
560*e4b17023SJohn Marino 
561*e4b17023SJohn Marino       /**
562*e4b17023SJohn Marino        *  @brief  Parse input time string.
563*e4b17023SJohn Marino        *
564*e4b17023SJohn Marino        *  This function parses a time according to the format @a x and puts the
565*e4b17023SJohn Marino        *  results into a user-supplied struct tm.  This function is a hook for
566*e4b17023SJohn Marino        *  derived classes to change the value returned.  @see get_time() for
567*e4b17023SJohn Marino        *  details.
568*e4b17023SJohn Marino        *
569*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
570*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
571*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
572*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
573*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
574*e4b17023SJohn Marino        *  @return  Iterator to first char beyond time string.
575*e4b17023SJohn Marino       */
576*e4b17023SJohn Marino       virtual iter_type
577*e4b17023SJohn Marino       do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
578*e4b17023SJohn Marino 		  ios_base::iostate& __err, tm* __tm) const;
579*e4b17023SJohn Marino 
580*e4b17023SJohn Marino       /**
581*e4b17023SJohn Marino        *  @brief  Parse input date string.
582*e4b17023SJohn Marino        *
583*e4b17023SJohn Marino        *  This function parses a date according to the format @a X and puts the
584*e4b17023SJohn Marino        *  results into a user-supplied struct tm.  This function is a hook for
585*e4b17023SJohn Marino        *  derived classes to change the value returned.  @see get_date() for
586*e4b17023SJohn Marino        *  details.
587*e4b17023SJohn Marino        *
588*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
589*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
590*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
591*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
592*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
593*e4b17023SJohn Marino        *  @return  Iterator to first char beyond date string.
594*e4b17023SJohn Marino       */
595*e4b17023SJohn Marino       virtual iter_type
596*e4b17023SJohn Marino       do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
597*e4b17023SJohn Marino 		  ios_base::iostate& __err, tm* __tm) const;
598*e4b17023SJohn Marino 
599*e4b17023SJohn Marino       /**
600*e4b17023SJohn Marino        *  @brief  Parse input weekday string.
601*e4b17023SJohn Marino        *
602*e4b17023SJohn Marino        *  This function parses a weekday name and puts the results into a
603*e4b17023SJohn Marino        *  user-supplied struct tm.  This function is a hook for derived
604*e4b17023SJohn Marino        *  classes to change the value returned.  @see get_weekday() for
605*e4b17023SJohn Marino        *  details.
606*e4b17023SJohn Marino        *
607*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
608*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
609*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
610*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
611*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
612*e4b17023SJohn Marino        *  @return  Iterator to first char beyond weekday name.
613*e4b17023SJohn Marino       */
614*e4b17023SJohn Marino       virtual iter_type
615*e4b17023SJohn Marino       do_get_weekday(iter_type __beg, iter_type __end, ios_base&,
616*e4b17023SJohn Marino 		     ios_base::iostate& __err, tm* __tm) const;
617*e4b17023SJohn Marino 
618*e4b17023SJohn Marino       /**
619*e4b17023SJohn Marino        *  @brief  Parse input month string.
620*e4b17023SJohn Marino        *
621*e4b17023SJohn Marino        *  This function parses a month name and puts the results into a
622*e4b17023SJohn Marino        *  user-supplied struct tm.  This function is a hook for derived
623*e4b17023SJohn Marino        *  classes to change the value returned.  @see get_monthname() for
624*e4b17023SJohn Marino        *  details.
625*e4b17023SJohn Marino        *
626*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
627*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
628*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
629*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
630*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
631*e4b17023SJohn Marino        *  @return  Iterator to first char beyond month name.
632*e4b17023SJohn Marino       */
633*e4b17023SJohn Marino       virtual iter_type
634*e4b17023SJohn Marino       do_get_monthname(iter_type __beg, iter_type __end, ios_base&,
635*e4b17023SJohn Marino 		       ios_base::iostate& __err, tm* __tm) const;
636*e4b17023SJohn Marino 
637*e4b17023SJohn Marino       /**
638*e4b17023SJohn Marino        *  @brief  Parse input year string.
639*e4b17023SJohn Marino        *
640*e4b17023SJohn Marino        *  This function reads up to 4 characters to parse a year string and
641*e4b17023SJohn Marino        *  puts the results into a user-supplied struct tm.  This function is a
642*e4b17023SJohn Marino        *  hook for derived classes to change the value returned.  @see
643*e4b17023SJohn Marino        *  get_year() for details.
644*e4b17023SJohn Marino        *
645*e4b17023SJohn Marino        *  @param  __beg  Start of string to parse.
646*e4b17023SJohn Marino        *  @param  __end  End of string to parse.
647*e4b17023SJohn Marino        *  @param  __io  Source of the locale.
648*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
649*e4b17023SJohn Marino        *  @param  __tm  Pointer to struct tm to fill in.
650*e4b17023SJohn Marino        *  @return  Iterator to first char beyond year.
651*e4b17023SJohn Marino       */
652*e4b17023SJohn Marino       virtual iter_type
653*e4b17023SJohn Marino       do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
654*e4b17023SJohn Marino 		  ios_base::iostate& __err, tm* __tm) const;
655*e4b17023SJohn Marino 
656*e4b17023SJohn Marino       // Extract numeric component of length __len.
657*e4b17023SJohn Marino       iter_type
658*e4b17023SJohn Marino       _M_extract_num(iter_type __beg, iter_type __end, int& __member,
659*e4b17023SJohn Marino 		     int __min, int __max, size_t __len,
660*e4b17023SJohn Marino 		     ios_base& __io, ios_base::iostate& __err) const;
661*e4b17023SJohn Marino 
662*e4b17023SJohn Marino       // Extract any unique array of string literals in a const _CharT* array.
663*e4b17023SJohn Marino       iter_type
664*e4b17023SJohn Marino       _M_extract_name(iter_type __beg, iter_type __end, int& __member,
665*e4b17023SJohn Marino 		      const _CharT** __names, size_t __indexlen,
666*e4b17023SJohn Marino 		      ios_base& __io, ios_base::iostate& __err) const;
667*e4b17023SJohn Marino 
668*e4b17023SJohn Marino       // Extract day or month name in a const _CharT* array.
669*e4b17023SJohn Marino       iter_type
670*e4b17023SJohn Marino       _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member,
671*e4b17023SJohn Marino 			       const _CharT** __names, size_t __indexlen,
672*e4b17023SJohn Marino 			       ios_base& __io, ios_base::iostate& __err) const;
673*e4b17023SJohn Marino 
674*e4b17023SJohn Marino       // Extract on a component-by-component basis, via __format argument.
675*e4b17023SJohn Marino       iter_type
676*e4b17023SJohn Marino       _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
677*e4b17023SJohn Marino 			    ios_base::iostate& __err, tm* __tm,
678*e4b17023SJohn Marino 			    const _CharT* __format) const;
679*e4b17023SJohn Marino     };
680*e4b17023SJohn Marino 
681*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
682*e4b17023SJohn Marino     locale::id time_get<_CharT, _InIter>::id;
683*e4b17023SJohn Marino 
684*e4b17023SJohn Marino   /// class time_get_byname [22.2.5.2].
685*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
686*e4b17023SJohn Marino     class time_get_byname : public time_get<_CharT, _InIter>
687*e4b17023SJohn Marino     {
688*e4b17023SJohn Marino     public:
689*e4b17023SJohn Marino       // Types:
690*e4b17023SJohn Marino       typedef _CharT			char_type;
691*e4b17023SJohn Marino       typedef _InIter			iter_type;
692*e4b17023SJohn Marino 
693*e4b17023SJohn Marino       explicit
694*e4b17023SJohn Marino       time_get_byname(const char*, size_t __refs = 0)
695*e4b17023SJohn Marino       : time_get<_CharT, _InIter>(__refs) { }
696*e4b17023SJohn Marino 
697*e4b17023SJohn Marino     protected:
698*e4b17023SJohn Marino       virtual
699*e4b17023SJohn Marino       ~time_get_byname() { }
700*e4b17023SJohn Marino     };
701*e4b17023SJohn Marino 
702*e4b17023SJohn Marino   /**
703*e4b17023SJohn Marino    *  @brief  Primary class template time_put.
704*e4b17023SJohn Marino    *  @ingroup locales
705*e4b17023SJohn Marino    *
706*e4b17023SJohn Marino    *  This facet encapsulates the code to format and output dates and times
707*e4b17023SJohn Marino    *  according to formats used by strftime().
708*e4b17023SJohn Marino    *
709*e4b17023SJohn Marino    *  The time_put template uses protected virtual functions to provide the
710*e4b17023SJohn Marino    *  actual results.  The public accessors forward the call to the virtual
711*e4b17023SJohn Marino    *  functions.  These virtual functions are hooks for developers to
712*e4b17023SJohn Marino    *  implement the behavior they require from the time_put facet.
713*e4b17023SJohn Marino   */
714*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
715*e4b17023SJohn Marino     class time_put : public locale::facet
716*e4b17023SJohn Marino     {
717*e4b17023SJohn Marino     public:
718*e4b17023SJohn Marino       // Types:
719*e4b17023SJohn Marino       //@{
720*e4b17023SJohn Marino       /// Public typedefs
721*e4b17023SJohn Marino       typedef _CharT			char_type;
722*e4b17023SJohn Marino       typedef _OutIter			iter_type;
723*e4b17023SJohn Marino       //@}
724*e4b17023SJohn Marino 
725*e4b17023SJohn Marino       /// Numpunct facet id.
726*e4b17023SJohn Marino       static locale::id			id;
727*e4b17023SJohn Marino 
728*e4b17023SJohn Marino       /**
729*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
730*e4b17023SJohn Marino        *
731*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
732*e4b17023SJohn Marino        *
733*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
734*e4b17023SJohn Marino       */
735*e4b17023SJohn Marino       explicit
736*e4b17023SJohn Marino       time_put(size_t __refs = 0)
737*e4b17023SJohn Marino       : facet(__refs) { }
738*e4b17023SJohn Marino 
739*e4b17023SJohn Marino       /**
740*e4b17023SJohn Marino        *  @brief  Format and output a time or date.
741*e4b17023SJohn Marino        *
742*e4b17023SJohn Marino        *  This function formats the data in struct tm according to the
743*e4b17023SJohn Marino        *  provided format string.  The format string is interpreted as by
744*e4b17023SJohn Marino        *  strftime().
745*e4b17023SJohn Marino        *
746*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
747*e4b17023SJohn Marino        *  @param  __io  Source of locale.
748*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
749*e4b17023SJohn Marino        *  @param  __tm  Struct tm with date and time info to format.
750*e4b17023SJohn Marino        *  @param  __beg  Start of format string.
751*e4b17023SJohn Marino        *  @param  __end  End of format string.
752*e4b17023SJohn Marino        *  @return  Iterator after writing.
753*e4b17023SJohn Marino        */
754*e4b17023SJohn Marino       iter_type
755*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
756*e4b17023SJohn Marino 	  const _CharT* __beg, const _CharT* __end) const;
757*e4b17023SJohn Marino 
758*e4b17023SJohn Marino       /**
759*e4b17023SJohn Marino        *  @brief  Format and output a time or date.
760*e4b17023SJohn Marino        *
761*e4b17023SJohn Marino        *  This function formats the data in struct tm according to the
762*e4b17023SJohn Marino        *  provided format char and optional modifier.  The format and modifier
763*e4b17023SJohn Marino        *  are interpreted as by strftime().  It does so by returning
764*e4b17023SJohn Marino        *  time_put::do_put().
765*e4b17023SJohn Marino        *
766*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
767*e4b17023SJohn Marino        *  @param  __io  Source of locale.
768*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
769*e4b17023SJohn Marino        *  @param  __tm  Struct tm with date and time info to format.
770*e4b17023SJohn Marino        *  @param  __format  Format char.
771*e4b17023SJohn Marino        *  @param  __mod  Optional modifier char.
772*e4b17023SJohn Marino        *  @return  Iterator after writing.
773*e4b17023SJohn Marino        */
774*e4b17023SJohn Marino       iter_type
775*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill,
776*e4b17023SJohn Marino 	  const tm* __tm, char __format, char __mod = 0) const
777*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __tm, __format, __mod); }
778*e4b17023SJohn Marino 
779*e4b17023SJohn Marino     protected:
780*e4b17023SJohn Marino       /// Destructor.
781*e4b17023SJohn Marino       virtual
782*e4b17023SJohn Marino       ~time_put()
783*e4b17023SJohn Marino       { }
784*e4b17023SJohn Marino 
785*e4b17023SJohn Marino       /**
786*e4b17023SJohn Marino        *  @brief  Format and output a time or date.
787*e4b17023SJohn Marino        *
788*e4b17023SJohn Marino        *  This function formats the data in struct tm according to the
789*e4b17023SJohn Marino        *  provided format char and optional modifier.  This function is a hook
790*e4b17023SJohn Marino        *  for derived classes to change the value returned.  @see put() for
791*e4b17023SJohn Marino        *  more details.
792*e4b17023SJohn Marino        *
793*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
794*e4b17023SJohn Marino        *  @param  __io  Source of locale.
795*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
796*e4b17023SJohn Marino        *  @param  __tm  Struct tm with date and time info to format.
797*e4b17023SJohn Marino        *  @param  __format  Format char.
798*e4b17023SJohn Marino        *  @param  __mod  Optional modifier char.
799*e4b17023SJohn Marino        *  @return  Iterator after writing.
800*e4b17023SJohn Marino        */
801*e4b17023SJohn Marino       virtual iter_type
802*e4b17023SJohn Marino       do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
803*e4b17023SJohn Marino 	     char __format, char __mod) const;
804*e4b17023SJohn Marino     };
805*e4b17023SJohn Marino 
806*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
807*e4b17023SJohn Marino     locale::id time_put<_CharT, _OutIter>::id;
808*e4b17023SJohn Marino 
809*e4b17023SJohn Marino   /// class time_put_byname [22.2.5.4].
810*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
811*e4b17023SJohn Marino     class time_put_byname : public time_put<_CharT, _OutIter>
812*e4b17023SJohn Marino     {
813*e4b17023SJohn Marino     public:
814*e4b17023SJohn Marino       // Types:
815*e4b17023SJohn Marino       typedef _CharT			char_type;
816*e4b17023SJohn Marino       typedef _OutIter			iter_type;
817*e4b17023SJohn Marino 
818*e4b17023SJohn Marino       explicit
819*e4b17023SJohn Marino       time_put_byname(const char*, size_t __refs = 0)
820*e4b17023SJohn Marino       : time_put<_CharT, _OutIter>(__refs)
821*e4b17023SJohn Marino       { };
822*e4b17023SJohn Marino 
823*e4b17023SJohn Marino     protected:
824*e4b17023SJohn Marino       virtual
825*e4b17023SJohn Marino       ~time_put_byname() { }
826*e4b17023SJohn Marino     };
827*e4b17023SJohn Marino 
828*e4b17023SJohn Marino 
829*e4b17023SJohn Marino   /**
830*e4b17023SJohn Marino    *  @brief  Money format ordering data.
831*e4b17023SJohn Marino    *  @ingroup locales
832*e4b17023SJohn Marino    *
833*e4b17023SJohn Marino    *  This class contains an ordered array of 4 fields to represent the
834*e4b17023SJohn Marino    *  pattern for formatting a money amount.  Each field may contain one entry
835*e4b17023SJohn Marino    *  from the part enum.  symbol, sign, and value must be present and the
836*e4b17023SJohn Marino    *  remaining field must contain either none or space.  @see
837*e4b17023SJohn Marino    *  moneypunct::pos_format() and moneypunct::neg_format() for details of how
838*e4b17023SJohn Marino    *  these fields are interpreted.
839*e4b17023SJohn Marino   */
840*e4b17023SJohn Marino   class money_base
841*e4b17023SJohn Marino   {
842*e4b17023SJohn Marino   public:
843*e4b17023SJohn Marino     enum part { none, space, symbol, sign, value };
844*e4b17023SJohn Marino     struct pattern { char field[4]; };
845*e4b17023SJohn Marino 
846*e4b17023SJohn Marino     static const pattern _S_default_pattern;
847*e4b17023SJohn Marino 
848*e4b17023SJohn Marino     enum
849*e4b17023SJohn Marino     {
850*e4b17023SJohn Marino       _S_minus,
851*e4b17023SJohn Marino       _S_zero,
852*e4b17023SJohn Marino       _S_end = 11
853*e4b17023SJohn Marino     };
854*e4b17023SJohn Marino 
855*e4b17023SJohn Marino     // String literal of acceptable (narrow) input/output, for
856*e4b17023SJohn Marino     // money_get/money_put. "-0123456789"
857*e4b17023SJohn Marino     static const char* _S_atoms;
858*e4b17023SJohn Marino 
859*e4b17023SJohn Marino     // Construct and return valid pattern consisting of some combination of:
860*e4b17023SJohn Marino     // space none symbol sign value
861*e4b17023SJohn Marino     _GLIBCXX_CONST static pattern
862*e4b17023SJohn Marino     _S_construct_pattern(char __precedes, char __space, char __posn) throw ();
863*e4b17023SJohn Marino   };
864*e4b17023SJohn Marino 
865*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
866*e4b17023SJohn Marino     struct __moneypunct_cache : public locale::facet
867*e4b17023SJohn Marino     {
868*e4b17023SJohn Marino       const char*			_M_grouping;
869*e4b17023SJohn Marino       size_t                            _M_grouping_size;
870*e4b17023SJohn Marino       bool				_M_use_grouping;
871*e4b17023SJohn Marino       _CharT				_M_decimal_point;
872*e4b17023SJohn Marino       _CharT				_M_thousands_sep;
873*e4b17023SJohn Marino       const _CharT*			_M_curr_symbol;
874*e4b17023SJohn Marino       size_t                            _M_curr_symbol_size;
875*e4b17023SJohn Marino       const _CharT*			_M_positive_sign;
876*e4b17023SJohn Marino       size_t                            _M_positive_sign_size;
877*e4b17023SJohn Marino       const _CharT*			_M_negative_sign;
878*e4b17023SJohn Marino       size_t                            _M_negative_sign_size;
879*e4b17023SJohn Marino       int				_M_frac_digits;
880*e4b17023SJohn Marino       money_base::pattern		_M_pos_format;
881*e4b17023SJohn Marino       money_base::pattern	        _M_neg_format;
882*e4b17023SJohn Marino 
883*e4b17023SJohn Marino       // A list of valid numeric literals for input and output: in the standard
884*e4b17023SJohn Marino       // "C" locale, this is "-0123456789". This array contains the chars after
885*e4b17023SJohn Marino       // having been passed through the current locale's ctype<_CharT>.widen().
886*e4b17023SJohn Marino       _CharT				_M_atoms[money_base::_S_end];
887*e4b17023SJohn Marino 
888*e4b17023SJohn Marino       bool				_M_allocated;
889*e4b17023SJohn Marino 
890*e4b17023SJohn Marino       __moneypunct_cache(size_t __refs = 0) : facet(__refs),
891*e4b17023SJohn Marino       _M_grouping(0), _M_grouping_size(0), _M_use_grouping(false),
892*e4b17023SJohn Marino       _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()),
893*e4b17023SJohn Marino       _M_curr_symbol(0), _M_curr_symbol_size(0),
894*e4b17023SJohn Marino       _M_positive_sign(0), _M_positive_sign_size(0),
895*e4b17023SJohn Marino       _M_negative_sign(0), _M_negative_sign_size(0),
896*e4b17023SJohn Marino       _M_frac_digits(0),
897*e4b17023SJohn Marino       _M_pos_format(money_base::pattern()),
898*e4b17023SJohn Marino       _M_neg_format(money_base::pattern()), _M_allocated(false)
899*e4b17023SJohn Marino       { }
900*e4b17023SJohn Marino 
901*e4b17023SJohn Marino       ~__moneypunct_cache();
902*e4b17023SJohn Marino 
903*e4b17023SJohn Marino       void
904*e4b17023SJohn Marino       _M_cache(const locale& __loc);
905*e4b17023SJohn Marino 
906*e4b17023SJohn Marino     private:
907*e4b17023SJohn Marino       __moneypunct_cache&
908*e4b17023SJohn Marino       operator=(const __moneypunct_cache&);
909*e4b17023SJohn Marino 
910*e4b17023SJohn Marino       explicit
911*e4b17023SJohn Marino       __moneypunct_cache(const __moneypunct_cache&);
912*e4b17023SJohn Marino     };
913*e4b17023SJohn Marino 
914*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
915*e4b17023SJohn Marino     __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache()
916*e4b17023SJohn Marino     {
917*e4b17023SJohn Marino       if (_M_allocated)
918*e4b17023SJohn Marino 	{
919*e4b17023SJohn Marino 	  delete [] _M_grouping;
920*e4b17023SJohn Marino 	  delete [] _M_curr_symbol;
921*e4b17023SJohn Marino 	  delete [] _M_positive_sign;
922*e4b17023SJohn Marino 	  delete [] _M_negative_sign;
923*e4b17023SJohn Marino 	}
924*e4b17023SJohn Marino     }
925*e4b17023SJohn Marino 
926*e4b17023SJohn Marino   /**
927*e4b17023SJohn Marino    *  @brief  Primary class template moneypunct.
928*e4b17023SJohn Marino    *  @ingroup locales
929*e4b17023SJohn Marino    *
930*e4b17023SJohn Marino    *  This facet encapsulates the punctuation, grouping and other formatting
931*e4b17023SJohn Marino    *  features of money amount string representations.
932*e4b17023SJohn Marino   */
933*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
934*e4b17023SJohn Marino     class moneypunct : public locale::facet, public money_base
935*e4b17023SJohn Marino     {
936*e4b17023SJohn Marino     public:
937*e4b17023SJohn Marino       // Types:
938*e4b17023SJohn Marino       //@{
939*e4b17023SJohn Marino       /// Public typedefs
940*e4b17023SJohn Marino       typedef _CharT			char_type;
941*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
942*e4b17023SJohn Marino       //@}
943*e4b17023SJohn Marino       typedef __moneypunct_cache<_CharT, _Intl>     __cache_type;
944*e4b17023SJohn Marino 
945*e4b17023SJohn Marino     private:
946*e4b17023SJohn Marino       __cache_type*			_M_data;
947*e4b17023SJohn Marino 
948*e4b17023SJohn Marino     public:
949*e4b17023SJohn Marino       /// This value is provided by the standard, but no reason for its
950*e4b17023SJohn Marino       /// existence.
951*e4b17023SJohn Marino       static const bool			intl = _Intl;
952*e4b17023SJohn Marino       /// Numpunct facet id.
953*e4b17023SJohn Marino       static locale::id			id;
954*e4b17023SJohn Marino 
955*e4b17023SJohn Marino       /**
956*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
957*e4b17023SJohn Marino        *
958*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
959*e4b17023SJohn Marino        *
960*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
961*e4b17023SJohn Marino       */
962*e4b17023SJohn Marino       explicit
963*e4b17023SJohn Marino       moneypunct(size_t __refs = 0)
964*e4b17023SJohn Marino       : facet(__refs), _M_data(0)
965*e4b17023SJohn Marino       { _M_initialize_moneypunct(); }
966*e4b17023SJohn Marino 
967*e4b17023SJohn Marino       /**
968*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
969*e4b17023SJohn Marino        *
970*e4b17023SJohn Marino        *  This is an internal constructor.
971*e4b17023SJohn Marino        *
972*e4b17023SJohn Marino        *  @param __cache  Cache for optimization.
973*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
974*e4b17023SJohn Marino       */
975*e4b17023SJohn Marino       explicit
976*e4b17023SJohn Marino       moneypunct(__cache_type* __cache, size_t __refs = 0)
977*e4b17023SJohn Marino       : facet(__refs), _M_data(__cache)
978*e4b17023SJohn Marino       { _M_initialize_moneypunct(); }
979*e4b17023SJohn Marino 
980*e4b17023SJohn Marino       /**
981*e4b17023SJohn Marino        *  @brief  Internal constructor. Not for general use.
982*e4b17023SJohn Marino        *
983*e4b17023SJohn Marino        *  This is a constructor for use by the library itself to set up new
984*e4b17023SJohn Marino        *  locales.
985*e4b17023SJohn Marino        *
986*e4b17023SJohn Marino        *  @param __cloc  The C locale.
987*e4b17023SJohn Marino        *  @param __s  The name of a locale.
988*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
989*e4b17023SJohn Marino       */
990*e4b17023SJohn Marino       explicit
991*e4b17023SJohn Marino       moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
992*e4b17023SJohn Marino       : facet(__refs), _M_data(0)
993*e4b17023SJohn Marino       { _M_initialize_moneypunct(__cloc, __s); }
994*e4b17023SJohn Marino 
995*e4b17023SJohn Marino       /**
996*e4b17023SJohn Marino        *  @brief  Return decimal point character.
997*e4b17023SJohn Marino        *
998*e4b17023SJohn Marino        *  This function returns a char_type to use as a decimal point.  It
999*e4b17023SJohn Marino        *  does so by returning returning
1000*e4b17023SJohn Marino        *  moneypunct<char_type>::do_decimal_point().
1001*e4b17023SJohn Marino        *
1002*e4b17023SJohn Marino        *  @return  @a char_type representing a decimal point.
1003*e4b17023SJohn Marino       */
1004*e4b17023SJohn Marino       char_type
1005*e4b17023SJohn Marino       decimal_point() const
1006*e4b17023SJohn Marino       { return this->do_decimal_point(); }
1007*e4b17023SJohn Marino 
1008*e4b17023SJohn Marino       /**
1009*e4b17023SJohn Marino        *  @brief  Return thousands separator character.
1010*e4b17023SJohn Marino        *
1011*e4b17023SJohn Marino        *  This function returns a char_type to use as a thousands
1012*e4b17023SJohn Marino        *  separator.  It does so by returning returning
1013*e4b17023SJohn Marino        *  moneypunct<char_type>::do_thousands_sep().
1014*e4b17023SJohn Marino        *
1015*e4b17023SJohn Marino        *  @return  char_type representing a thousands separator.
1016*e4b17023SJohn Marino       */
1017*e4b17023SJohn Marino       char_type
1018*e4b17023SJohn Marino       thousands_sep() const
1019*e4b17023SJohn Marino       { return this->do_thousands_sep(); }
1020*e4b17023SJohn Marino 
1021*e4b17023SJohn Marino       /**
1022*e4b17023SJohn Marino        *  @brief  Return grouping specification.
1023*e4b17023SJohn Marino        *
1024*e4b17023SJohn Marino        *  This function returns a string representing groupings for the
1025*e4b17023SJohn Marino        *  integer part of an amount.  Groupings indicate where thousands
1026*e4b17023SJohn Marino        *  separators should be inserted.
1027*e4b17023SJohn Marino        *
1028*e4b17023SJohn Marino        *  Each char in the return string is interpret as an integer rather
1029*e4b17023SJohn Marino        *  than a character.  These numbers represent the number of digits in a
1030*e4b17023SJohn Marino        *  group.  The first char in the string represents the number of digits
1031*e4b17023SJohn Marino        *  in the least significant group.  If a char is negative, it indicates
1032*e4b17023SJohn Marino        *  an unlimited number of digits for the group.  If more chars from the
1033*e4b17023SJohn Marino        *  string are required to group a number, the last char is used
1034*e4b17023SJohn Marino        *  repeatedly.
1035*e4b17023SJohn Marino        *
1036*e4b17023SJohn Marino        *  For example, if the grouping() returns <code>\003\002</code>
1037*e4b17023SJohn Marino        *  and is applied to the number 123456789, this corresponds to
1038*e4b17023SJohn Marino        *  12,34,56,789.  Note that if the string was <code>32</code>, this would
1039*e4b17023SJohn Marino        *  put more than 50 digits into the least significant group if
1040*e4b17023SJohn Marino        *  the character set is ASCII.
1041*e4b17023SJohn Marino        *
1042*e4b17023SJohn Marino        *  The string is returned by calling
1043*e4b17023SJohn Marino        *  moneypunct<char_type>::do_grouping().
1044*e4b17023SJohn Marino        *
1045*e4b17023SJohn Marino        *  @return  string representing grouping specification.
1046*e4b17023SJohn Marino       */
1047*e4b17023SJohn Marino       string
1048*e4b17023SJohn Marino       grouping() const
1049*e4b17023SJohn Marino       { return this->do_grouping(); }
1050*e4b17023SJohn Marino 
1051*e4b17023SJohn Marino       /**
1052*e4b17023SJohn Marino        *  @brief  Return currency symbol string.
1053*e4b17023SJohn Marino        *
1054*e4b17023SJohn Marino        *  This function returns a string_type to use as a currency symbol.  It
1055*e4b17023SJohn Marino        *  does so by returning returning
1056*e4b17023SJohn Marino        *  moneypunct<char_type>::do_curr_symbol().
1057*e4b17023SJohn Marino        *
1058*e4b17023SJohn Marino        *  @return  @a string_type representing a currency symbol.
1059*e4b17023SJohn Marino       */
1060*e4b17023SJohn Marino       string_type
1061*e4b17023SJohn Marino       curr_symbol() const
1062*e4b17023SJohn Marino       { return this->do_curr_symbol(); }
1063*e4b17023SJohn Marino 
1064*e4b17023SJohn Marino       /**
1065*e4b17023SJohn Marino        *  @brief  Return positive sign string.
1066*e4b17023SJohn Marino        *
1067*e4b17023SJohn Marino        *  This function returns a string_type to use as a sign for positive
1068*e4b17023SJohn Marino        *  amounts.  It does so by returning returning
1069*e4b17023SJohn Marino        *  moneypunct<char_type>::do_positive_sign().
1070*e4b17023SJohn Marino        *
1071*e4b17023SJohn Marino        *  If the return value contains more than one character, the first
1072*e4b17023SJohn Marino        *  character appears in the position indicated by pos_format() and the
1073*e4b17023SJohn Marino        *  remainder appear at the end of the formatted string.
1074*e4b17023SJohn Marino        *
1075*e4b17023SJohn Marino        *  @return  @a string_type representing a positive sign.
1076*e4b17023SJohn Marino       */
1077*e4b17023SJohn Marino       string_type
1078*e4b17023SJohn Marino       positive_sign() const
1079*e4b17023SJohn Marino       { return this->do_positive_sign(); }
1080*e4b17023SJohn Marino 
1081*e4b17023SJohn Marino       /**
1082*e4b17023SJohn Marino        *  @brief  Return negative sign string.
1083*e4b17023SJohn Marino        *
1084*e4b17023SJohn Marino        *  This function returns a string_type to use as a sign for negative
1085*e4b17023SJohn Marino        *  amounts.  It does so by returning returning
1086*e4b17023SJohn Marino        *  moneypunct<char_type>::do_negative_sign().
1087*e4b17023SJohn Marino        *
1088*e4b17023SJohn Marino        *  If the return value contains more than one character, the first
1089*e4b17023SJohn Marino        *  character appears in the position indicated by neg_format() and the
1090*e4b17023SJohn Marino        *  remainder appear at the end of the formatted string.
1091*e4b17023SJohn Marino        *
1092*e4b17023SJohn Marino        *  @return  @a string_type representing a negative sign.
1093*e4b17023SJohn Marino       */
1094*e4b17023SJohn Marino       string_type
1095*e4b17023SJohn Marino       negative_sign() const
1096*e4b17023SJohn Marino       { return this->do_negative_sign(); }
1097*e4b17023SJohn Marino 
1098*e4b17023SJohn Marino       /**
1099*e4b17023SJohn Marino        *  @brief  Return number of digits in fraction.
1100*e4b17023SJohn Marino        *
1101*e4b17023SJohn Marino        *  This function returns the exact number of digits that make up the
1102*e4b17023SJohn Marino        *  fractional part of a money amount.  It does so by returning
1103*e4b17023SJohn Marino        *  returning moneypunct<char_type>::do_frac_digits().
1104*e4b17023SJohn Marino        *
1105*e4b17023SJohn Marino        *  The fractional part of a money amount is optional.  But if it is
1106*e4b17023SJohn Marino        *  present, there must be frac_digits() digits.
1107*e4b17023SJohn Marino        *
1108*e4b17023SJohn Marino        *  @return  Number of digits in amount fraction.
1109*e4b17023SJohn Marino       */
1110*e4b17023SJohn Marino       int
1111*e4b17023SJohn Marino       frac_digits() const
1112*e4b17023SJohn Marino       { return this->do_frac_digits(); }
1113*e4b17023SJohn Marino 
1114*e4b17023SJohn Marino       //@{
1115*e4b17023SJohn Marino       /**
1116*e4b17023SJohn Marino        *  @brief  Return pattern for money values.
1117*e4b17023SJohn Marino        *
1118*e4b17023SJohn Marino        *  This function returns a pattern describing the formatting of a
1119*e4b17023SJohn Marino        *  positive or negative valued money amount.  It does so by returning
1120*e4b17023SJohn Marino        *  returning moneypunct<char_type>::do_pos_format() or
1121*e4b17023SJohn Marino        *  moneypunct<char_type>::do_neg_format().
1122*e4b17023SJohn Marino        *
1123*e4b17023SJohn Marino        *  The pattern has 4 fields describing the ordering of symbol, sign,
1124*e4b17023SJohn Marino        *  value, and none or space.  There must be one of each in the pattern.
1125*e4b17023SJohn Marino        *  The none and space enums may not appear in the first field and space
1126*e4b17023SJohn Marino        *  may not appear in the final field.
1127*e4b17023SJohn Marino        *
1128*e4b17023SJohn Marino        *  The parts of a money string must appear in the order indicated by
1129*e4b17023SJohn Marino        *  the fields of the pattern.  The symbol field indicates that the
1130*e4b17023SJohn Marino        *  value of curr_symbol() may be present.  The sign field indicates
1131*e4b17023SJohn Marino        *  that the value of positive_sign() or negative_sign() must be
1132*e4b17023SJohn Marino        *  present.  The value field indicates that the absolute value of the
1133*e4b17023SJohn Marino        *  money amount is present.  none indicates 0 or more whitespace
1134*e4b17023SJohn Marino        *  characters, except at the end, where it permits no whitespace.
1135*e4b17023SJohn Marino        *  space indicates that 1 or more whitespace characters must be
1136*e4b17023SJohn Marino        *  present.
1137*e4b17023SJohn Marino        *
1138*e4b17023SJohn Marino        *  For example, for the US locale and pos_format() pattern
1139*e4b17023SJohn Marino        *  {symbol,sign,value,none}, curr_symbol() == &apos;$&apos;
1140*e4b17023SJohn Marino        *  positive_sign() == &apos;+&apos;, and value 10.01, and
1141*e4b17023SJohn Marino        *  options set to force the symbol, the corresponding string is
1142*e4b17023SJohn Marino        *  <code>$+10.01</code>.
1143*e4b17023SJohn Marino        *
1144*e4b17023SJohn Marino        *  @return  Pattern for money values.
1145*e4b17023SJohn Marino       */
1146*e4b17023SJohn Marino       pattern
1147*e4b17023SJohn Marino       pos_format() const
1148*e4b17023SJohn Marino       { return this->do_pos_format(); }
1149*e4b17023SJohn Marino 
1150*e4b17023SJohn Marino       pattern
1151*e4b17023SJohn Marino       neg_format() const
1152*e4b17023SJohn Marino       { return this->do_neg_format(); }
1153*e4b17023SJohn Marino       //@}
1154*e4b17023SJohn Marino 
1155*e4b17023SJohn Marino     protected:
1156*e4b17023SJohn Marino       /// Destructor.
1157*e4b17023SJohn Marino       virtual
1158*e4b17023SJohn Marino       ~moneypunct();
1159*e4b17023SJohn Marino 
1160*e4b17023SJohn Marino       /**
1161*e4b17023SJohn Marino        *  @brief  Return decimal point character.
1162*e4b17023SJohn Marino        *
1163*e4b17023SJohn Marino        *  Returns a char_type to use as a decimal point.  This function is a
1164*e4b17023SJohn Marino        *  hook for derived classes to change the value returned.
1165*e4b17023SJohn Marino        *
1166*e4b17023SJohn Marino        *  @return  @a char_type representing a decimal point.
1167*e4b17023SJohn Marino       */
1168*e4b17023SJohn Marino       virtual char_type
1169*e4b17023SJohn Marino       do_decimal_point() const
1170*e4b17023SJohn Marino       { return _M_data->_M_decimal_point; }
1171*e4b17023SJohn Marino 
1172*e4b17023SJohn Marino       /**
1173*e4b17023SJohn Marino        *  @brief  Return thousands separator character.
1174*e4b17023SJohn Marino        *
1175*e4b17023SJohn Marino        *  Returns a char_type to use as a thousands separator.  This function
1176*e4b17023SJohn Marino        *  is a hook for derived classes to change the value returned.
1177*e4b17023SJohn Marino        *
1178*e4b17023SJohn Marino        *  @return  @a char_type representing a thousands separator.
1179*e4b17023SJohn Marino       */
1180*e4b17023SJohn Marino       virtual char_type
1181*e4b17023SJohn Marino       do_thousands_sep() const
1182*e4b17023SJohn Marino       { return _M_data->_M_thousands_sep; }
1183*e4b17023SJohn Marino 
1184*e4b17023SJohn Marino       /**
1185*e4b17023SJohn Marino        *  @brief  Return grouping specification.
1186*e4b17023SJohn Marino        *
1187*e4b17023SJohn Marino        *  Returns a string representing groupings for the integer part of a
1188*e4b17023SJohn Marino        *  number.  This function is a hook for derived classes to change the
1189*e4b17023SJohn Marino        *  value returned.  @see grouping() for details.
1190*e4b17023SJohn Marino        *
1191*e4b17023SJohn Marino        *  @return  String representing grouping specification.
1192*e4b17023SJohn Marino       */
1193*e4b17023SJohn Marino       virtual string
1194*e4b17023SJohn Marino       do_grouping() const
1195*e4b17023SJohn Marino       { return _M_data->_M_grouping; }
1196*e4b17023SJohn Marino 
1197*e4b17023SJohn Marino       /**
1198*e4b17023SJohn Marino        *  @brief  Return currency symbol string.
1199*e4b17023SJohn Marino        *
1200*e4b17023SJohn Marino        *  This function returns a string_type to use as a currency symbol.
1201*e4b17023SJohn Marino        *  This function is a hook for derived classes to change the value
1202*e4b17023SJohn Marino        *  returned.  @see curr_symbol() for details.
1203*e4b17023SJohn Marino        *
1204*e4b17023SJohn Marino        *  @return  @a string_type representing a currency symbol.
1205*e4b17023SJohn Marino       */
1206*e4b17023SJohn Marino       virtual string_type
1207*e4b17023SJohn Marino       do_curr_symbol()   const
1208*e4b17023SJohn Marino       { return _M_data->_M_curr_symbol; }
1209*e4b17023SJohn Marino 
1210*e4b17023SJohn Marino       /**
1211*e4b17023SJohn Marino        *  @brief  Return positive sign string.
1212*e4b17023SJohn Marino        *
1213*e4b17023SJohn Marino        *  This function returns a string_type to use as a sign for positive
1214*e4b17023SJohn Marino        *  amounts.  This function is a hook for derived classes to change the
1215*e4b17023SJohn Marino        *  value returned.  @see positive_sign() for details.
1216*e4b17023SJohn Marino        *
1217*e4b17023SJohn Marino        *  @return  @a string_type representing a positive sign.
1218*e4b17023SJohn Marino       */
1219*e4b17023SJohn Marino       virtual string_type
1220*e4b17023SJohn Marino       do_positive_sign() const
1221*e4b17023SJohn Marino       { return _M_data->_M_positive_sign; }
1222*e4b17023SJohn Marino 
1223*e4b17023SJohn Marino       /**
1224*e4b17023SJohn Marino        *  @brief  Return negative sign string.
1225*e4b17023SJohn Marino        *
1226*e4b17023SJohn Marino        *  This function returns a string_type to use as a sign for negative
1227*e4b17023SJohn Marino        *  amounts.  This function is a hook for derived classes to change the
1228*e4b17023SJohn Marino        *  value returned.  @see negative_sign() for details.
1229*e4b17023SJohn Marino        *
1230*e4b17023SJohn Marino        *  @return  @a string_type representing a negative sign.
1231*e4b17023SJohn Marino       */
1232*e4b17023SJohn Marino       virtual string_type
1233*e4b17023SJohn Marino       do_negative_sign() const
1234*e4b17023SJohn Marino       { return _M_data->_M_negative_sign; }
1235*e4b17023SJohn Marino 
1236*e4b17023SJohn Marino       /**
1237*e4b17023SJohn Marino        *  @brief  Return number of digits in fraction.
1238*e4b17023SJohn Marino        *
1239*e4b17023SJohn Marino        *  This function returns the exact number of digits that make up the
1240*e4b17023SJohn Marino        *  fractional part of a money amount.  This function is a hook for
1241*e4b17023SJohn Marino        *  derived classes to change the value returned.  @see frac_digits()
1242*e4b17023SJohn Marino        *  for details.
1243*e4b17023SJohn Marino        *
1244*e4b17023SJohn Marino        *  @return  Number of digits in amount fraction.
1245*e4b17023SJohn Marino       */
1246*e4b17023SJohn Marino       virtual int
1247*e4b17023SJohn Marino       do_frac_digits() const
1248*e4b17023SJohn Marino       { return _M_data->_M_frac_digits; }
1249*e4b17023SJohn Marino 
1250*e4b17023SJohn Marino       /**
1251*e4b17023SJohn Marino        *  @brief  Return pattern for money values.
1252*e4b17023SJohn Marino        *
1253*e4b17023SJohn Marino        *  This function returns a pattern describing the formatting of a
1254*e4b17023SJohn Marino        *  positive valued money amount.  This function is a hook for derived
1255*e4b17023SJohn Marino        *  classes to change the value returned.  @see pos_format() for
1256*e4b17023SJohn Marino        *  details.
1257*e4b17023SJohn Marino        *
1258*e4b17023SJohn Marino        *  @return  Pattern for money values.
1259*e4b17023SJohn Marino       */
1260*e4b17023SJohn Marino       virtual pattern
1261*e4b17023SJohn Marino       do_pos_format() const
1262*e4b17023SJohn Marino       { return _M_data->_M_pos_format; }
1263*e4b17023SJohn Marino 
1264*e4b17023SJohn Marino       /**
1265*e4b17023SJohn Marino        *  @brief  Return pattern for money values.
1266*e4b17023SJohn Marino        *
1267*e4b17023SJohn Marino        *  This function returns a pattern describing the formatting of a
1268*e4b17023SJohn Marino        *  negative valued money amount.  This function is a hook for derived
1269*e4b17023SJohn Marino        *  classes to change the value returned.  @see neg_format() for
1270*e4b17023SJohn Marino        *  details.
1271*e4b17023SJohn Marino        *
1272*e4b17023SJohn Marino        *  @return  Pattern for money values.
1273*e4b17023SJohn Marino       */
1274*e4b17023SJohn Marino       virtual pattern
1275*e4b17023SJohn Marino       do_neg_format() const
1276*e4b17023SJohn Marino       { return _M_data->_M_neg_format; }
1277*e4b17023SJohn Marino 
1278*e4b17023SJohn Marino       // For use at construction time only.
1279*e4b17023SJohn Marino        void
1280*e4b17023SJohn Marino        _M_initialize_moneypunct(__c_locale __cloc = 0,
1281*e4b17023SJohn Marino 				const char* __name = 0);
1282*e4b17023SJohn Marino     };
1283*e4b17023SJohn Marino 
1284*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
1285*e4b17023SJohn Marino     locale::id moneypunct<_CharT, _Intl>::id;
1286*e4b17023SJohn Marino 
1287*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
1288*e4b17023SJohn Marino     const bool moneypunct<_CharT, _Intl>::intl;
1289*e4b17023SJohn Marino 
1290*e4b17023SJohn Marino   template<>
1291*e4b17023SJohn Marino     moneypunct<char, true>::~moneypunct();
1292*e4b17023SJohn Marino 
1293*e4b17023SJohn Marino   template<>
1294*e4b17023SJohn Marino     moneypunct<char, false>::~moneypunct();
1295*e4b17023SJohn Marino 
1296*e4b17023SJohn Marino   template<>
1297*e4b17023SJohn Marino     void
1298*e4b17023SJohn Marino     moneypunct<char, true>::_M_initialize_moneypunct(__c_locale, const char*);
1299*e4b17023SJohn Marino 
1300*e4b17023SJohn Marino   template<>
1301*e4b17023SJohn Marino     void
1302*e4b17023SJohn Marino     moneypunct<char, false>::_M_initialize_moneypunct(__c_locale, const char*);
1303*e4b17023SJohn Marino 
1304*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
1305*e4b17023SJohn Marino   template<>
1306*e4b17023SJohn Marino     moneypunct<wchar_t, true>::~moneypunct();
1307*e4b17023SJohn Marino 
1308*e4b17023SJohn Marino   template<>
1309*e4b17023SJohn Marino     moneypunct<wchar_t, false>::~moneypunct();
1310*e4b17023SJohn Marino 
1311*e4b17023SJohn Marino   template<>
1312*e4b17023SJohn Marino     void
1313*e4b17023SJohn Marino     moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale,
1314*e4b17023SJohn Marino 							const char*);
1315*e4b17023SJohn Marino 
1316*e4b17023SJohn Marino   template<>
1317*e4b17023SJohn Marino     void
1318*e4b17023SJohn Marino     moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale,
1319*e4b17023SJohn Marino 							 const char*);
1320*e4b17023SJohn Marino #endif
1321*e4b17023SJohn Marino 
1322*e4b17023SJohn Marino   /// class moneypunct_byname [22.2.6.4].
1323*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
1324*e4b17023SJohn Marino     class moneypunct_byname : public moneypunct<_CharT, _Intl>
1325*e4b17023SJohn Marino     {
1326*e4b17023SJohn Marino     public:
1327*e4b17023SJohn Marino       typedef _CharT			char_type;
1328*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1329*e4b17023SJohn Marino 
1330*e4b17023SJohn Marino       static const bool intl = _Intl;
1331*e4b17023SJohn Marino 
1332*e4b17023SJohn Marino       explicit
1333*e4b17023SJohn Marino       moneypunct_byname(const char* __s, size_t __refs = 0)
1334*e4b17023SJohn Marino       : moneypunct<_CharT, _Intl>(__refs)
1335*e4b17023SJohn Marino       {
1336*e4b17023SJohn Marino 	if (__builtin_strcmp(__s, "C") != 0
1337*e4b17023SJohn Marino 	    && __builtin_strcmp(__s, "POSIX") != 0)
1338*e4b17023SJohn Marino 	  {
1339*e4b17023SJohn Marino 	    __c_locale __tmp;
1340*e4b17023SJohn Marino 	    this->_S_create_c_locale(__tmp, __s);
1341*e4b17023SJohn Marino 	    this->_M_initialize_moneypunct(__tmp);
1342*e4b17023SJohn Marino 	    this->_S_destroy_c_locale(__tmp);
1343*e4b17023SJohn Marino 	  }
1344*e4b17023SJohn Marino       }
1345*e4b17023SJohn Marino 
1346*e4b17023SJohn Marino     protected:
1347*e4b17023SJohn Marino       virtual
1348*e4b17023SJohn Marino       ~moneypunct_byname() { }
1349*e4b17023SJohn Marino     };
1350*e4b17023SJohn Marino 
1351*e4b17023SJohn Marino   template<typename _CharT, bool _Intl>
1352*e4b17023SJohn Marino     const bool moneypunct_byname<_CharT, _Intl>::intl;
1353*e4b17023SJohn Marino 
1354*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_LDBL
1355*e4b17023SJohn Marino 
1356*e4b17023SJohn Marino   /**
1357*e4b17023SJohn Marino    *  @brief  Primary class template money_get.
1358*e4b17023SJohn Marino    *  @ingroup locales
1359*e4b17023SJohn Marino    *
1360*e4b17023SJohn Marino    *  This facet encapsulates the code to parse and return a monetary
1361*e4b17023SJohn Marino    *  amount from a string.
1362*e4b17023SJohn Marino    *
1363*e4b17023SJohn Marino    *  The money_get template uses protected virtual functions to
1364*e4b17023SJohn Marino    *  provide the actual results.  The public accessors forward the
1365*e4b17023SJohn Marino    *  call to the virtual functions.  These virtual functions are
1366*e4b17023SJohn Marino    *  hooks for developers to implement the behavior they require from
1367*e4b17023SJohn Marino    *  the money_get facet.
1368*e4b17023SJohn Marino   */
1369*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
1370*e4b17023SJohn Marino     class money_get : public locale::facet
1371*e4b17023SJohn Marino     {
1372*e4b17023SJohn Marino     public:
1373*e4b17023SJohn Marino       // Types:
1374*e4b17023SJohn Marino       //@{
1375*e4b17023SJohn Marino       /// Public typedefs
1376*e4b17023SJohn Marino       typedef _CharT			char_type;
1377*e4b17023SJohn Marino       typedef _InIter			iter_type;
1378*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1379*e4b17023SJohn Marino       //@}
1380*e4b17023SJohn Marino 
1381*e4b17023SJohn Marino       /// Numpunct facet id.
1382*e4b17023SJohn Marino       static locale::id			id;
1383*e4b17023SJohn Marino 
1384*e4b17023SJohn Marino       /**
1385*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
1386*e4b17023SJohn Marino        *
1387*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
1388*e4b17023SJohn Marino        *
1389*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
1390*e4b17023SJohn Marino       */
1391*e4b17023SJohn Marino       explicit
1392*e4b17023SJohn Marino       money_get(size_t __refs = 0) : facet(__refs) { }
1393*e4b17023SJohn Marino 
1394*e4b17023SJohn Marino       /**
1395*e4b17023SJohn Marino        *  @brief  Read and parse a monetary value.
1396*e4b17023SJohn Marino        *
1397*e4b17023SJohn Marino        *  This function reads characters from @a __s, interprets them as a
1398*e4b17023SJohn Marino        *  monetary value according to moneypunct and ctype facets retrieved
1399*e4b17023SJohn Marino        *  from io.getloc(), and returns the result in @a units as an integral
1400*e4b17023SJohn Marino        *  value moneypunct::frac_digits() * the actual amount.  For example,
1401*e4b17023SJohn Marino        *  the string $10.01 in a US locale would store 1001 in @a units.
1402*e4b17023SJohn Marino        *
1403*e4b17023SJohn Marino        *  Any characters not part of a valid money amount are not consumed.
1404*e4b17023SJohn Marino        *
1405*e4b17023SJohn Marino        *  If a money value cannot be parsed from the input stream, sets
1406*e4b17023SJohn Marino        *  err=(err|io.failbit).  If the stream is consumed before finishing
1407*e4b17023SJohn Marino        *  parsing,  sets err=(err|io.failbit|io.eofbit).  @a units is
1408*e4b17023SJohn Marino        *  unchanged if parsing fails.
1409*e4b17023SJohn Marino        *
1410*e4b17023SJohn Marino        *  This function works by returning the result of do_get().
1411*e4b17023SJohn Marino        *
1412*e4b17023SJohn Marino        *  @param  __s  Start of characters to parse.
1413*e4b17023SJohn Marino        *  @param  __end  End of characters to parse.
1414*e4b17023SJohn Marino        *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1415*e4b17023SJohn Marino        *  @param  __io  Source of facets and io state.
1416*e4b17023SJohn Marino        *  @param  __err  Error field to set if parsing fails.
1417*e4b17023SJohn Marino        *  @param  __units  Place to store result of parsing.
1418*e4b17023SJohn Marino        *  @return  Iterator referencing first character beyond valid money
1419*e4b17023SJohn Marino        *	   amount.
1420*e4b17023SJohn Marino        */
1421*e4b17023SJohn Marino       iter_type
1422*e4b17023SJohn Marino       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1423*e4b17023SJohn Marino 	  ios_base::iostate& __err, long double& __units) const
1424*e4b17023SJohn Marino       { return this->do_get(__s, __end, __intl, __io, __err, __units); }
1425*e4b17023SJohn Marino 
1426*e4b17023SJohn Marino       /**
1427*e4b17023SJohn Marino        *  @brief  Read and parse a monetary value.
1428*e4b17023SJohn Marino        *
1429*e4b17023SJohn Marino        *  This function reads characters from @a __s, interprets them as
1430*e4b17023SJohn Marino        *  a monetary value according to moneypunct and ctype facets
1431*e4b17023SJohn Marino        *  retrieved from io.getloc(), and returns the result in @a
1432*e4b17023SJohn Marino        *  digits.  For example, the string $10.01 in a US locale would
1433*e4b17023SJohn Marino        *  store <code>1001</code> in @a digits.
1434*e4b17023SJohn Marino        *
1435*e4b17023SJohn Marino        *  Any characters not part of a valid money amount are not consumed.
1436*e4b17023SJohn Marino        *
1437*e4b17023SJohn Marino        *  If a money value cannot be parsed from the input stream, sets
1438*e4b17023SJohn Marino        *  err=(err|io.failbit).  If the stream is consumed before finishing
1439*e4b17023SJohn Marino        *  parsing,  sets err=(err|io.failbit|io.eofbit).
1440*e4b17023SJohn Marino        *
1441*e4b17023SJohn Marino        *  This function works by returning the result of do_get().
1442*e4b17023SJohn Marino        *
1443*e4b17023SJohn Marino        *  @param  __s  Start of characters to parse.
1444*e4b17023SJohn Marino        *  @param  __end  End of characters to parse.
1445*e4b17023SJohn Marino        *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1446*e4b17023SJohn Marino        *  @param  __io  Source of facets and io state.
1447*e4b17023SJohn Marino        *  @param  __err  Error field to set if parsing fails.
1448*e4b17023SJohn Marino        *  @param  __digits  Place to store result of parsing.
1449*e4b17023SJohn Marino        *  @return  Iterator referencing first character beyond valid money
1450*e4b17023SJohn Marino        *	   amount.
1451*e4b17023SJohn Marino        */
1452*e4b17023SJohn Marino       iter_type
1453*e4b17023SJohn Marino       get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1454*e4b17023SJohn Marino 	  ios_base::iostate& __err, string_type& __digits) const
1455*e4b17023SJohn Marino       { return this->do_get(__s, __end, __intl, __io, __err, __digits); }
1456*e4b17023SJohn Marino 
1457*e4b17023SJohn Marino     protected:
1458*e4b17023SJohn Marino       /// Destructor.
1459*e4b17023SJohn Marino       virtual
1460*e4b17023SJohn Marino       ~money_get() { }
1461*e4b17023SJohn Marino 
1462*e4b17023SJohn Marino       /**
1463*e4b17023SJohn Marino        *  @brief  Read and parse a monetary value.
1464*e4b17023SJohn Marino        *
1465*e4b17023SJohn Marino        *  This function reads and parses characters representing a monetary
1466*e4b17023SJohn Marino        *  value.  This function is a hook for derived classes to change the
1467*e4b17023SJohn Marino        *  value returned.  @see get() for details.
1468*e4b17023SJohn Marino        */
1469*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
1470*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
1471*e4b17023SJohn Marino       virtual iter_type
1472*e4b17023SJohn Marino       __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1473*e4b17023SJohn Marino 	       ios_base::iostate& __err, double& __units) const;
1474*e4b17023SJohn Marino #else
1475*e4b17023SJohn Marino       virtual iter_type
1476*e4b17023SJohn Marino       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1477*e4b17023SJohn Marino 	     ios_base::iostate& __err, long double& __units) const;
1478*e4b17023SJohn Marino #endif
1479*e4b17023SJohn Marino 
1480*e4b17023SJohn Marino       /**
1481*e4b17023SJohn Marino        *  @brief  Read and parse a monetary value.
1482*e4b17023SJohn Marino        *
1483*e4b17023SJohn Marino        *  This function reads and parses characters representing a monetary
1484*e4b17023SJohn Marino        *  value.  This function is a hook for derived classes to change the
1485*e4b17023SJohn Marino        *  value returned.  @see get() for details.
1486*e4b17023SJohn Marino        */
1487*e4b17023SJohn Marino       virtual iter_type
1488*e4b17023SJohn Marino       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1489*e4b17023SJohn Marino 	     ios_base::iostate& __err, string_type& __digits) const;
1490*e4b17023SJohn Marino 
1491*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
1492*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
1493*e4b17023SJohn Marino       virtual iter_type
1494*e4b17023SJohn Marino       do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io,
1495*e4b17023SJohn Marino 	     ios_base::iostate& __err, long double& __units) const;
1496*e4b17023SJohn Marino #endif
1497*e4b17023SJohn Marino 
1498*e4b17023SJohn Marino       template<bool _Intl>
1499*e4b17023SJohn Marino         iter_type
1500*e4b17023SJohn Marino         _M_extract(iter_type __s, iter_type __end, ios_base& __io,
1501*e4b17023SJohn Marino 		   ios_base::iostate& __err, string& __digits) const;
1502*e4b17023SJohn Marino     };
1503*e4b17023SJohn Marino 
1504*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
1505*e4b17023SJohn Marino     locale::id money_get<_CharT, _InIter>::id;
1506*e4b17023SJohn Marino 
1507*e4b17023SJohn Marino   /**
1508*e4b17023SJohn Marino    *  @brief  Primary class template money_put.
1509*e4b17023SJohn Marino    *  @ingroup locales
1510*e4b17023SJohn Marino    *
1511*e4b17023SJohn Marino    *  This facet encapsulates the code to format and output a monetary
1512*e4b17023SJohn Marino    *  amount.
1513*e4b17023SJohn Marino    *
1514*e4b17023SJohn Marino    *  The money_put template uses protected virtual functions to
1515*e4b17023SJohn Marino    *  provide the actual results.  The public accessors forward the
1516*e4b17023SJohn Marino    *  call to the virtual functions.  These virtual functions are
1517*e4b17023SJohn Marino    *  hooks for developers to implement the behavior they require from
1518*e4b17023SJohn Marino    *  the money_put facet.
1519*e4b17023SJohn Marino   */
1520*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
1521*e4b17023SJohn Marino     class money_put : public locale::facet
1522*e4b17023SJohn Marino     {
1523*e4b17023SJohn Marino     public:
1524*e4b17023SJohn Marino       //@{
1525*e4b17023SJohn Marino       /// Public typedefs
1526*e4b17023SJohn Marino       typedef _CharT			char_type;
1527*e4b17023SJohn Marino       typedef _OutIter			iter_type;
1528*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1529*e4b17023SJohn Marino       //@}
1530*e4b17023SJohn Marino 
1531*e4b17023SJohn Marino       /// Numpunct facet id.
1532*e4b17023SJohn Marino       static locale::id			id;
1533*e4b17023SJohn Marino 
1534*e4b17023SJohn Marino       /**
1535*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
1536*e4b17023SJohn Marino        *
1537*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
1538*e4b17023SJohn Marino        *
1539*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
1540*e4b17023SJohn Marino       */
1541*e4b17023SJohn Marino       explicit
1542*e4b17023SJohn Marino       money_put(size_t __refs = 0) : facet(__refs) { }
1543*e4b17023SJohn Marino 
1544*e4b17023SJohn Marino       /**
1545*e4b17023SJohn Marino        *  @brief  Format and output a monetary value.
1546*e4b17023SJohn Marino        *
1547*e4b17023SJohn Marino        *  This function formats @a units as a monetary value according to
1548*e4b17023SJohn Marino        *  moneypunct and ctype facets retrieved from io.getloc(), and writes
1549*e4b17023SJohn Marino        *  the resulting characters to @a __s.  For example, the value 1001 in a
1550*e4b17023SJohn Marino        *  US locale would write <code>$10.01</code> to @a __s.
1551*e4b17023SJohn Marino        *
1552*e4b17023SJohn Marino        *  This function works by returning the result of do_put().
1553*e4b17023SJohn Marino        *
1554*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
1555*e4b17023SJohn Marino        *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1556*e4b17023SJohn Marino        *  @param  __io  Source of facets and io state.
1557*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
1558*e4b17023SJohn Marino        *  @param  __units  Place to store result of parsing.
1559*e4b17023SJohn Marino        *  @return  Iterator after writing.
1560*e4b17023SJohn Marino        */
1561*e4b17023SJohn Marino       iter_type
1562*e4b17023SJohn Marino       put(iter_type __s, bool __intl, ios_base& __io,
1563*e4b17023SJohn Marino 	  char_type __fill, long double __units) const
1564*e4b17023SJohn Marino       { return this->do_put(__s, __intl, __io, __fill, __units); }
1565*e4b17023SJohn Marino 
1566*e4b17023SJohn Marino       /**
1567*e4b17023SJohn Marino        *  @brief  Format and output a monetary value.
1568*e4b17023SJohn Marino        *
1569*e4b17023SJohn Marino        *  This function formats @a digits as a monetary value
1570*e4b17023SJohn Marino        *  according to moneypunct and ctype facets retrieved from
1571*e4b17023SJohn Marino        *  io.getloc(), and writes the resulting characters to @a __s.
1572*e4b17023SJohn Marino        *  For example, the string <code>1001</code> in a US locale
1573*e4b17023SJohn Marino        *  would write <code>$10.01</code> to @a __s.
1574*e4b17023SJohn Marino        *
1575*e4b17023SJohn Marino        *  This function works by returning the result of do_put().
1576*e4b17023SJohn Marino        *
1577*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
1578*e4b17023SJohn Marino        *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1579*e4b17023SJohn Marino        *  @param  __io  Source of facets and io state.
1580*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
1581*e4b17023SJohn Marino        *  @param  __digits  Place to store result of parsing.
1582*e4b17023SJohn Marino        *  @return  Iterator after writing.
1583*e4b17023SJohn Marino        */
1584*e4b17023SJohn Marino       iter_type
1585*e4b17023SJohn Marino       put(iter_type __s, bool __intl, ios_base& __io,
1586*e4b17023SJohn Marino 	  char_type __fill, const string_type& __digits) const
1587*e4b17023SJohn Marino       { return this->do_put(__s, __intl, __io, __fill, __digits); }
1588*e4b17023SJohn Marino 
1589*e4b17023SJohn Marino     protected:
1590*e4b17023SJohn Marino       /// Destructor.
1591*e4b17023SJohn Marino       virtual
1592*e4b17023SJohn Marino       ~money_put() { }
1593*e4b17023SJohn Marino 
1594*e4b17023SJohn Marino       /**
1595*e4b17023SJohn Marino        *  @brief  Format and output a monetary value.
1596*e4b17023SJohn Marino        *
1597*e4b17023SJohn Marino        *  This function formats @a units as a monetary value according to
1598*e4b17023SJohn Marino        *  moneypunct and ctype facets retrieved from io.getloc(), and writes
1599*e4b17023SJohn Marino        *  the resulting characters to @a __s.  For example, the value 1001 in a
1600*e4b17023SJohn Marino        *  US locale would write <code>$10.01</code> to @a __s.
1601*e4b17023SJohn Marino        *
1602*e4b17023SJohn Marino        *  This function is a hook for derived classes to change the value
1603*e4b17023SJohn Marino        *  returned.  @see put().
1604*e4b17023SJohn Marino        *
1605*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
1606*e4b17023SJohn Marino        *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1607*e4b17023SJohn Marino        *  @param  __io  Source of facets and io state.
1608*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
1609*e4b17023SJohn Marino        *  @param  __units  Place to store result of parsing.
1610*e4b17023SJohn Marino        *  @return  Iterator after writing.
1611*e4b17023SJohn Marino        */
1612*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
1613*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
1614*e4b17023SJohn Marino       virtual iter_type
1615*e4b17023SJohn Marino       __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1616*e4b17023SJohn Marino 	       double __units) const;
1617*e4b17023SJohn Marino #else
1618*e4b17023SJohn Marino       virtual iter_type
1619*e4b17023SJohn Marino       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1620*e4b17023SJohn Marino 	     long double __units) const;
1621*e4b17023SJohn Marino #endif
1622*e4b17023SJohn Marino 
1623*e4b17023SJohn Marino       /**
1624*e4b17023SJohn Marino        *  @brief  Format and output a monetary value.
1625*e4b17023SJohn Marino        *
1626*e4b17023SJohn Marino        *  This function formats @a digits as a monetary value
1627*e4b17023SJohn Marino        *  according to moneypunct and ctype facets retrieved from
1628*e4b17023SJohn Marino        *  io.getloc(), and writes the resulting characters to @a __s.
1629*e4b17023SJohn Marino        *  For example, the string <code>1001</code> in a US locale
1630*e4b17023SJohn Marino        *  would write <code>$10.01</code> to @a __s.
1631*e4b17023SJohn Marino        *
1632*e4b17023SJohn Marino        *  This function is a hook for derived classes to change the value
1633*e4b17023SJohn Marino        *  returned.  @see put().
1634*e4b17023SJohn Marino        *
1635*e4b17023SJohn Marino        *  @param  __s  The stream to write to.
1636*e4b17023SJohn Marino        *  @param  __intl  Parameter to use_facet<moneypunct<CharT,intl> >.
1637*e4b17023SJohn Marino        *  @param  __io  Source of facets and io state.
1638*e4b17023SJohn Marino        *  @param  __fill  char_type to use for padding.
1639*e4b17023SJohn Marino        *  @param  __digits  Place to store result of parsing.
1640*e4b17023SJohn Marino        *  @return  Iterator after writing.
1641*e4b17023SJohn Marino        */
1642*e4b17023SJohn Marino       virtual iter_type
1643*e4b17023SJohn Marino       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1644*e4b17023SJohn Marino 	     const string_type& __digits) const;
1645*e4b17023SJohn Marino 
1646*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
1647*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
1648*e4b17023SJohn Marino       virtual iter_type
1649*e4b17023SJohn Marino       do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
1650*e4b17023SJohn Marino 	     long double __units) const;
1651*e4b17023SJohn Marino #endif
1652*e4b17023SJohn Marino 
1653*e4b17023SJohn Marino       template<bool _Intl>
1654*e4b17023SJohn Marino         iter_type
1655*e4b17023SJohn Marino         _M_insert(iter_type __s, ios_base& __io, char_type __fill,
1656*e4b17023SJohn Marino 		  const string_type& __digits) const;
1657*e4b17023SJohn Marino     };
1658*e4b17023SJohn Marino 
1659*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
1660*e4b17023SJohn Marino     locale::id money_put<_CharT, _OutIter>::id;
1661*e4b17023SJohn Marino 
1662*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_LDBL
1663*e4b17023SJohn Marino 
1664*e4b17023SJohn Marino   /**
1665*e4b17023SJohn Marino    *  @brief  Messages facet base class providing catalog typedef.
1666*e4b17023SJohn Marino    *  @ingroup locales
1667*e4b17023SJohn Marino    */
1668*e4b17023SJohn Marino   struct messages_base
1669*e4b17023SJohn Marino   {
1670*e4b17023SJohn Marino     typedef int catalog;
1671*e4b17023SJohn Marino   };
1672*e4b17023SJohn Marino 
1673*e4b17023SJohn Marino   /**
1674*e4b17023SJohn Marino    *  @brief  Primary class template messages.
1675*e4b17023SJohn Marino    *  @ingroup locales
1676*e4b17023SJohn Marino    *
1677*e4b17023SJohn Marino    *  This facet encapsulates the code to retrieve messages from
1678*e4b17023SJohn Marino    *  message catalogs.  The only thing defined by the standard for this facet
1679*e4b17023SJohn Marino    *  is the interface.  All underlying functionality is
1680*e4b17023SJohn Marino    *  implementation-defined.
1681*e4b17023SJohn Marino    *
1682*e4b17023SJohn Marino    *  This library currently implements 3 versions of the message facet.  The
1683*e4b17023SJohn Marino    *  first version (gnu) is a wrapper around gettext, provided by libintl.
1684*e4b17023SJohn Marino    *  The second version (ieee) is a wrapper around catgets.  The final
1685*e4b17023SJohn Marino    *  version (default) does no actual translation.  These implementations are
1686*e4b17023SJohn Marino    *  only provided for char and wchar_t instantiations.
1687*e4b17023SJohn Marino    *
1688*e4b17023SJohn Marino    *  The messages template uses protected virtual functions to
1689*e4b17023SJohn Marino    *  provide the actual results.  The public accessors forward the
1690*e4b17023SJohn Marino    *  call to the virtual functions.  These virtual functions are
1691*e4b17023SJohn Marino    *  hooks for developers to implement the behavior they require from
1692*e4b17023SJohn Marino    *  the messages facet.
1693*e4b17023SJohn Marino   */
1694*e4b17023SJohn Marino   template<typename _CharT>
1695*e4b17023SJohn Marino     class messages : public locale::facet, public messages_base
1696*e4b17023SJohn Marino     {
1697*e4b17023SJohn Marino     public:
1698*e4b17023SJohn Marino       // Types:
1699*e4b17023SJohn Marino       //@{
1700*e4b17023SJohn Marino       /// Public typedefs
1701*e4b17023SJohn Marino       typedef _CharT			char_type;
1702*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1703*e4b17023SJohn Marino       //@}
1704*e4b17023SJohn Marino 
1705*e4b17023SJohn Marino     protected:
1706*e4b17023SJohn Marino       // Underlying "C" library locale information saved from
1707*e4b17023SJohn Marino       // initialization, needed by messages_byname as well.
1708*e4b17023SJohn Marino       __c_locale			_M_c_locale_messages;
1709*e4b17023SJohn Marino       const char*			_M_name_messages;
1710*e4b17023SJohn Marino 
1711*e4b17023SJohn Marino     public:
1712*e4b17023SJohn Marino       /// Numpunct facet id.
1713*e4b17023SJohn Marino       static locale::id			id;
1714*e4b17023SJohn Marino 
1715*e4b17023SJohn Marino       /**
1716*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
1717*e4b17023SJohn Marino        *
1718*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
1719*e4b17023SJohn Marino        *
1720*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
1721*e4b17023SJohn Marino       */
1722*e4b17023SJohn Marino       explicit
1723*e4b17023SJohn Marino       messages(size_t __refs = 0);
1724*e4b17023SJohn Marino 
1725*e4b17023SJohn Marino       // Non-standard.
1726*e4b17023SJohn Marino       /**
1727*e4b17023SJohn Marino        *  @brief  Internal constructor.  Not for general use.
1728*e4b17023SJohn Marino        *
1729*e4b17023SJohn Marino        *  This is a constructor for use by the library itself to set up new
1730*e4b17023SJohn Marino        *  locales.
1731*e4b17023SJohn Marino        *
1732*e4b17023SJohn Marino        *  @param  __cloc  The C locale.
1733*e4b17023SJohn Marino        *  @param  __s  The name of a locale.
1734*e4b17023SJohn Marino        *  @param  __refs  Refcount to pass to the base class.
1735*e4b17023SJohn Marino        */
1736*e4b17023SJohn Marino       explicit
1737*e4b17023SJohn Marino       messages(__c_locale __cloc, const char* __s, size_t __refs = 0);
1738*e4b17023SJohn Marino 
1739*e4b17023SJohn Marino       /*
1740*e4b17023SJohn Marino        *  @brief  Open a message catalog.
1741*e4b17023SJohn Marino        *
1742*e4b17023SJohn Marino        *  This function opens and returns a handle to a message catalog by
1743*e4b17023SJohn Marino        *  returning do_open(__s, __loc).
1744*e4b17023SJohn Marino        *
1745*e4b17023SJohn Marino        *  @param  __s  The catalog to open.
1746*e4b17023SJohn Marino        *  @param  __loc  Locale to use for character set conversions.
1747*e4b17023SJohn Marino        *  @return  Handle to the catalog or value < 0 if open fails.
1748*e4b17023SJohn Marino       */
1749*e4b17023SJohn Marino       catalog
1750*e4b17023SJohn Marino       open(const basic_string<char>& __s, const locale& __loc) const
1751*e4b17023SJohn Marino       { return this->do_open(__s, __loc); }
1752*e4b17023SJohn Marino 
1753*e4b17023SJohn Marino       // Non-standard and unorthodox, yet effective.
1754*e4b17023SJohn Marino       /*
1755*e4b17023SJohn Marino        *  @brief  Open a message catalog.
1756*e4b17023SJohn Marino        *
1757*e4b17023SJohn Marino        *  This non-standard function opens and returns a handle to a message
1758*e4b17023SJohn Marino        *  catalog by returning do_open(s, loc).  The third argument provides a
1759*e4b17023SJohn Marino        *  message catalog root directory for gnu gettext and is ignored
1760*e4b17023SJohn Marino        *  otherwise.
1761*e4b17023SJohn Marino        *
1762*e4b17023SJohn Marino        *  @param  __s  The catalog to open.
1763*e4b17023SJohn Marino        *  @param  __loc  Locale to use for character set conversions.
1764*e4b17023SJohn Marino        *  @param  __dir  Message catalog root directory.
1765*e4b17023SJohn Marino        *  @return  Handle to the catalog or value < 0 if open fails.
1766*e4b17023SJohn Marino       */
1767*e4b17023SJohn Marino       catalog
1768*e4b17023SJohn Marino       open(const basic_string<char>&, const locale&, const char*) const;
1769*e4b17023SJohn Marino 
1770*e4b17023SJohn Marino       /*
1771*e4b17023SJohn Marino        *  @brief  Look up a string in a message catalog.
1772*e4b17023SJohn Marino        *
1773*e4b17023SJohn Marino        *  This function retrieves and returns a message from a catalog by
1774*e4b17023SJohn Marino        *  returning do_get(c, set, msgid, s).
1775*e4b17023SJohn Marino        *
1776*e4b17023SJohn Marino        *  For gnu, @a __set and @a msgid are ignored.  Returns gettext(s).
1777*e4b17023SJohn Marino        *  For default, returns s. For ieee, returns catgets(c,set,msgid,s).
1778*e4b17023SJohn Marino        *
1779*e4b17023SJohn Marino        *  @param  __c  The catalog to access.
1780*e4b17023SJohn Marino        *  @param  __set  Implementation-defined.
1781*e4b17023SJohn Marino        *  @param  __msgid  Implementation-defined.
1782*e4b17023SJohn Marino        *  @param  __s  Default return value if retrieval fails.
1783*e4b17023SJohn Marino        *  @return  Retrieved message or @a __s if get fails.
1784*e4b17023SJohn Marino       */
1785*e4b17023SJohn Marino       string_type
1786*e4b17023SJohn Marino       get(catalog __c, int __set, int __msgid, const string_type& __s) const
1787*e4b17023SJohn Marino       { return this->do_get(__c, __set, __msgid, __s); }
1788*e4b17023SJohn Marino 
1789*e4b17023SJohn Marino       /*
1790*e4b17023SJohn Marino        *  @brief  Close a message catalog.
1791*e4b17023SJohn Marino        *
1792*e4b17023SJohn Marino        *  Closes catalog @a c by calling do_close(c).
1793*e4b17023SJohn Marino        *
1794*e4b17023SJohn Marino        *  @param  __c  The catalog to close.
1795*e4b17023SJohn Marino       */
1796*e4b17023SJohn Marino       void
1797*e4b17023SJohn Marino       close(catalog __c) const
1798*e4b17023SJohn Marino       { return this->do_close(__c); }
1799*e4b17023SJohn Marino 
1800*e4b17023SJohn Marino     protected:
1801*e4b17023SJohn Marino       /// Destructor.
1802*e4b17023SJohn Marino       virtual
1803*e4b17023SJohn Marino       ~messages();
1804*e4b17023SJohn Marino 
1805*e4b17023SJohn Marino       /*
1806*e4b17023SJohn Marino        *  @brief  Open a message catalog.
1807*e4b17023SJohn Marino        *
1808*e4b17023SJohn Marino        *  This function opens and returns a handle to a message catalog in an
1809*e4b17023SJohn Marino        *  implementation-defined manner.  This function is a hook for derived
1810*e4b17023SJohn Marino        *  classes to change the value returned.
1811*e4b17023SJohn Marino        *
1812*e4b17023SJohn Marino        *  @param  __s  The catalog to open.
1813*e4b17023SJohn Marino        *  @param  __loc  Locale to use for character set conversions.
1814*e4b17023SJohn Marino        *  @return  Handle to the opened catalog, value < 0 if open failed.
1815*e4b17023SJohn Marino       */
1816*e4b17023SJohn Marino       virtual catalog
1817*e4b17023SJohn Marino       do_open(const basic_string<char>&, const locale&) const;
1818*e4b17023SJohn Marino 
1819*e4b17023SJohn Marino       /*
1820*e4b17023SJohn Marino        *  @brief  Look up a string in a message catalog.
1821*e4b17023SJohn Marino        *
1822*e4b17023SJohn Marino        *  This function retrieves and returns a message from a catalog in an
1823*e4b17023SJohn Marino        *  implementation-defined manner.  This function is a hook for derived
1824*e4b17023SJohn Marino        *  classes to change the value returned.
1825*e4b17023SJohn Marino        *
1826*e4b17023SJohn Marino        *  For gnu, @a __set and @a __msgid are ignored.  Returns gettext(s).
1827*e4b17023SJohn Marino        *  For default, returns s. For ieee, returns catgets(c,set,msgid,s).
1828*e4b17023SJohn Marino        *
1829*e4b17023SJohn Marino        *  @param  __c  The catalog to access.
1830*e4b17023SJohn Marino        *  @param  __set  Implementation-defined.
1831*e4b17023SJohn Marino        *  @param  __msgid  Implementation-defined.
1832*e4b17023SJohn Marino        *  @param  __s  Default return value if retrieval fails.
1833*e4b17023SJohn Marino        *  @return  Retrieved message or @a __s if get fails.
1834*e4b17023SJohn Marino       */
1835*e4b17023SJohn Marino       virtual string_type
1836*e4b17023SJohn Marino       do_get(catalog, int, int, const string_type& __dfault) const;
1837*e4b17023SJohn Marino 
1838*e4b17023SJohn Marino       /*
1839*e4b17023SJohn Marino        *  @brief  Close a message catalog.
1840*e4b17023SJohn Marino        *
1841*e4b17023SJohn Marino        *  @param  __c  The catalog to close.
1842*e4b17023SJohn Marino       */
1843*e4b17023SJohn Marino       virtual void
1844*e4b17023SJohn Marino       do_close(catalog) const;
1845*e4b17023SJohn Marino 
1846*e4b17023SJohn Marino       // Returns a locale and codeset-converted string, given a char* message.
1847*e4b17023SJohn Marino       char*
1848*e4b17023SJohn Marino       _M_convert_to_char(const string_type& __msg) const
1849*e4b17023SJohn Marino       {
1850*e4b17023SJohn Marino 	// XXX
1851*e4b17023SJohn Marino 	return reinterpret_cast<char*>(const_cast<_CharT*>(__msg.c_str()));
1852*e4b17023SJohn Marino       }
1853*e4b17023SJohn Marino 
1854*e4b17023SJohn Marino       // Returns a locale and codeset-converted string, given a char* message.
1855*e4b17023SJohn Marino       string_type
1856*e4b17023SJohn Marino       _M_convert_from_char(char*) const
1857*e4b17023SJohn Marino       {
1858*e4b17023SJohn Marino 	// XXX
1859*e4b17023SJohn Marino 	return string_type();
1860*e4b17023SJohn Marino       }
1861*e4b17023SJohn Marino      };
1862*e4b17023SJohn Marino 
1863*e4b17023SJohn Marino   template<typename _CharT>
1864*e4b17023SJohn Marino     locale::id messages<_CharT>::id;
1865*e4b17023SJohn Marino 
1866*e4b17023SJohn Marino   /// Specializations for required instantiations.
1867*e4b17023SJohn Marino   template<>
1868*e4b17023SJohn Marino     string
1869*e4b17023SJohn Marino     messages<char>::do_get(catalog, int, int, const string&) const;
1870*e4b17023SJohn Marino 
1871*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
1872*e4b17023SJohn Marino   template<>
1873*e4b17023SJohn Marino     wstring
1874*e4b17023SJohn Marino     messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
1875*e4b17023SJohn Marino #endif
1876*e4b17023SJohn Marino 
1877*e4b17023SJohn Marino    /// class messages_byname [22.2.7.2].
1878*e4b17023SJohn Marino    template<typename _CharT>
1879*e4b17023SJohn Marino     class messages_byname : public messages<_CharT>
1880*e4b17023SJohn Marino     {
1881*e4b17023SJohn Marino     public:
1882*e4b17023SJohn Marino       typedef _CharT			char_type;
1883*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1884*e4b17023SJohn Marino 
1885*e4b17023SJohn Marino       explicit
1886*e4b17023SJohn Marino       messages_byname(const char* __s, size_t __refs = 0);
1887*e4b17023SJohn Marino 
1888*e4b17023SJohn Marino     protected:
1889*e4b17023SJohn Marino       virtual
1890*e4b17023SJohn Marino       ~messages_byname()
1891*e4b17023SJohn Marino       { }
1892*e4b17023SJohn Marino     };
1893*e4b17023SJohn Marino 
1894*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION
1895*e4b17023SJohn Marino } // namespace
1896*e4b17023SJohn Marino 
1897*e4b17023SJohn Marino // Include host and configuration specific messages functions.
1898*e4b17023SJohn Marino #include <bits/messages_members.h>
1899*e4b17023SJohn Marino 
1900*e4b17023SJohn Marino // 22.2.1.5  Template class codecvt
1901*e4b17023SJohn Marino #include <bits/codecvt.h>
1902*e4b17023SJohn Marino 
1903*e4b17023SJohn Marino #include <bits/locale_facets_nonio.tcc>
1904*e4b17023SJohn Marino 
1905*e4b17023SJohn Marino #endif
1906