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