xref: /dflybsd-src/contrib/gcc-4.7/libstdc++-v3/include/bits/locale_facets.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino // Locale support -*- C++ -*-
2*e4b17023SJohn Marino 
3*e4b17023SJohn Marino // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4*e4b17023SJohn Marino // 2006, 2007, 2008, 2009, 2010, 2011
5*e4b17023SJohn Marino // Free Software Foundation, Inc.
6*e4b17023SJohn Marino //
7*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library.  This library is free
8*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the
9*e4b17023SJohn Marino // terms of the GNU General Public License as published by the
10*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option)
11*e4b17023SJohn Marino // any later version.
12*e4b17023SJohn Marino 
13*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful,
14*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*e4b17023SJohn Marino // GNU General Public License for more details.
17*e4b17023SJohn Marino 
18*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional
19*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version
20*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation.
21*e4b17023SJohn Marino 
22*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and
23*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program;
24*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>.
26*e4b17023SJohn Marino 
27*e4b17023SJohn Marino /** @file bits/locale_facets.h
28*e4b17023SJohn Marino  *  This is an internal header file, included by other library headers.
29*e4b17023SJohn Marino  *  Do not attempt to use it directly. @headername{locale}
30*e4b17023SJohn Marino  */
31*e4b17023SJohn Marino 
32*e4b17023SJohn Marino //
33*e4b17023SJohn Marino // ISO C++ 14882: 22.1  Locales
34*e4b17023SJohn Marino //
35*e4b17023SJohn Marino 
36*e4b17023SJohn Marino #ifndef _LOCALE_FACETS_H
37*e4b17023SJohn Marino #define _LOCALE_FACETS_H 1
38*e4b17023SJohn Marino 
39*e4b17023SJohn Marino #pragma GCC system_header
40*e4b17023SJohn Marino 
41*e4b17023SJohn Marino #include <cwctype>	// For wctype_t
42*e4b17023SJohn Marino #include <cctype>
43*e4b17023SJohn Marino #include <bits/ctype_base.h>
44*e4b17023SJohn Marino #include <iosfwd>
45*e4b17023SJohn Marino #include <bits/ios_base.h>  // For ios_base, ios_base::iostate
46*e4b17023SJohn Marino #include <streambuf>
47*e4b17023SJohn Marino #include <bits/cpp_type_traits.h>
48*e4b17023SJohn Marino #include <ext/type_traits.h>
49*e4b17023SJohn Marino #include <ext/numeric_traits.h>
50*e4b17023SJohn Marino #include <bits/streambuf_iterator.h>
51*e4b17023SJohn Marino 
_GLIBCXX_VISIBILITY(default)52*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
53*e4b17023SJohn Marino {
54*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION
55*e4b17023SJohn Marino 
56*e4b17023SJohn Marino   // NB: Don't instantiate required wchar_t facets if no wchar_t support.
57*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
58*e4b17023SJohn Marino # define  _GLIBCXX_NUM_FACETS 28
59*e4b17023SJohn Marino #else
60*e4b17023SJohn Marino # define  _GLIBCXX_NUM_FACETS 14
61*e4b17023SJohn Marino #endif
62*e4b17023SJohn Marino 
63*e4b17023SJohn Marino   // Convert string to numeric value of type _Tp and store results.
64*e4b17023SJohn Marino   // NB: This is specialized for all required types, there is no
65*e4b17023SJohn Marino   // generic definition.
66*e4b17023SJohn Marino   template<typename _Tp>
67*e4b17023SJohn Marino     void
68*e4b17023SJohn Marino     __convert_to_v(const char*, _Tp&, ios_base::iostate&,
69*e4b17023SJohn Marino 		   const __c_locale&) throw();
70*e4b17023SJohn Marino 
71*e4b17023SJohn Marino   // Explicit specializations for required types.
72*e4b17023SJohn Marino   template<>
73*e4b17023SJohn Marino     void
74*e4b17023SJohn Marino     __convert_to_v(const char*, float&, ios_base::iostate&,
75*e4b17023SJohn Marino 		   const __c_locale&) throw();
76*e4b17023SJohn Marino 
77*e4b17023SJohn Marino   template<>
78*e4b17023SJohn Marino     void
79*e4b17023SJohn Marino     __convert_to_v(const char*, double&, ios_base::iostate&,
80*e4b17023SJohn Marino 		   const __c_locale&) throw();
81*e4b17023SJohn Marino 
82*e4b17023SJohn Marino   template<>
83*e4b17023SJohn Marino     void
84*e4b17023SJohn Marino     __convert_to_v(const char*, long double&, ios_base::iostate&,
85*e4b17023SJohn Marino 		   const __c_locale&) throw();
86*e4b17023SJohn Marino 
87*e4b17023SJohn Marino   // NB: __pad is a struct, rather than a function, so it can be
88*e4b17023SJohn Marino   // partially-specialized.
89*e4b17023SJohn Marino   template<typename _CharT, typename _Traits>
90*e4b17023SJohn Marino     struct __pad
91*e4b17023SJohn Marino     {
92*e4b17023SJohn Marino       static void
93*e4b17023SJohn Marino       _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
94*e4b17023SJohn Marino 	     const _CharT* __olds, streamsize __newlen, streamsize __oldlen);
95*e4b17023SJohn Marino     };
96*e4b17023SJohn Marino 
97*e4b17023SJohn Marino   // Used by both numeric and monetary facets.
98*e4b17023SJohn Marino   // Inserts "group separator" characters into an array of characters.
99*e4b17023SJohn Marino   // It's recursive, one iteration per group.  It moves the characters
100*e4b17023SJohn Marino   // in the buffer this way: "xxxx12345" -> "12,345xxx".  Call this
101*e4b17023SJohn Marino   // only with __gsize != 0.
102*e4b17023SJohn Marino   template<typename _CharT>
103*e4b17023SJohn Marino     _CharT*
104*e4b17023SJohn Marino     __add_grouping(_CharT* __s, _CharT __sep,
105*e4b17023SJohn Marino 		   const char* __gbeg, size_t __gsize,
106*e4b17023SJohn Marino 		   const _CharT* __first, const _CharT* __last);
107*e4b17023SJohn Marino 
108*e4b17023SJohn Marino   // This template permits specializing facet output code for
109*e4b17023SJohn Marino   // ostreambuf_iterator.  For ostreambuf_iterator, sputn is
110*e4b17023SJohn Marino   // significantly more efficient than incrementing iterators.
111*e4b17023SJohn Marino   template<typename _CharT>
112*e4b17023SJohn Marino     inline
113*e4b17023SJohn Marino     ostreambuf_iterator<_CharT>
114*e4b17023SJohn Marino     __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
115*e4b17023SJohn Marino     {
116*e4b17023SJohn Marino       __s._M_put(__ws, __len);
117*e4b17023SJohn Marino       return __s;
118*e4b17023SJohn Marino     }
119*e4b17023SJohn Marino 
120*e4b17023SJohn Marino   // This is the unspecialized form of the template.
121*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
122*e4b17023SJohn Marino     inline
123*e4b17023SJohn Marino     _OutIter
124*e4b17023SJohn Marino     __write(_OutIter __s, const _CharT* __ws, int __len)
125*e4b17023SJohn Marino     {
126*e4b17023SJohn Marino       for (int __j = 0; __j < __len; __j++, ++__s)
127*e4b17023SJohn Marino 	*__s = __ws[__j];
128*e4b17023SJohn Marino       return __s;
129*e4b17023SJohn Marino     }
130*e4b17023SJohn Marino 
131*e4b17023SJohn Marino 
132*e4b17023SJohn Marino   // 22.2.1.1  Template class ctype
133*e4b17023SJohn Marino   // Include host and configuration specific ctype enums for ctype_base.
134*e4b17023SJohn Marino 
135*e4b17023SJohn Marino   /**
136*e4b17023SJohn Marino    *  @brief  Common base for ctype facet
137*e4b17023SJohn Marino    *
138*e4b17023SJohn Marino    *  This template class provides implementations of the public functions
139*e4b17023SJohn Marino    *  that forward to the protected virtual functions.
140*e4b17023SJohn Marino    *
141*e4b17023SJohn Marino    *  This template also provides abstract stubs for the protected virtual
142*e4b17023SJohn Marino    *  functions.
143*e4b17023SJohn Marino   */
144*e4b17023SJohn Marino   template<typename _CharT>
145*e4b17023SJohn Marino     class __ctype_abstract_base : public locale::facet, public ctype_base
146*e4b17023SJohn Marino     {
147*e4b17023SJohn Marino     public:
148*e4b17023SJohn Marino       // Types:
149*e4b17023SJohn Marino       /// Typedef for the template parameter
150*e4b17023SJohn Marino       typedef _CharT char_type;
151*e4b17023SJohn Marino 
152*e4b17023SJohn Marino       /**
153*e4b17023SJohn Marino        *  @brief  Test char_type classification.
154*e4b17023SJohn Marino        *
155*e4b17023SJohn Marino        *  This function finds a mask M for @a __c and compares it to
156*e4b17023SJohn Marino        *  mask @a __m.  It does so by returning the value of
157*e4b17023SJohn Marino        *  ctype<char_type>::do_is().
158*e4b17023SJohn Marino        *
159*e4b17023SJohn Marino        *  @param __c  The char_type to compare the mask of.
160*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
161*e4b17023SJohn Marino        *  @return  (M & __m) != 0.
162*e4b17023SJohn Marino       */
163*e4b17023SJohn Marino       bool
164*e4b17023SJohn Marino       is(mask __m, char_type __c) const
165*e4b17023SJohn Marino       { return this->do_is(__m, __c); }
166*e4b17023SJohn Marino 
167*e4b17023SJohn Marino       /**
168*e4b17023SJohn Marino        *  @brief  Return a mask array.
169*e4b17023SJohn Marino        *
170*e4b17023SJohn Marino        *  This function finds the mask for each char_type in the range [lo,hi)
171*e4b17023SJohn Marino        *  and successively writes it to vec.  vec must have as many elements
172*e4b17023SJohn Marino        *  as the char array.  It does so by returning the value of
173*e4b17023SJohn Marino        *  ctype<char_type>::do_is().
174*e4b17023SJohn Marino        *
175*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
176*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
177*e4b17023SJohn Marino        *  @param __vec  Pointer to an array of mask storage.
178*e4b17023SJohn Marino        *  @return  @a __hi.
179*e4b17023SJohn Marino       */
180*e4b17023SJohn Marino       const char_type*
181*e4b17023SJohn Marino       is(const char_type *__lo, const char_type *__hi, mask *__vec) const
182*e4b17023SJohn Marino       { return this->do_is(__lo, __hi, __vec); }
183*e4b17023SJohn Marino 
184*e4b17023SJohn Marino       /**
185*e4b17023SJohn Marino        *  @brief  Find char_type matching a mask
186*e4b17023SJohn Marino        *
187*e4b17023SJohn Marino        *  This function searches for and returns the first char_type c in
188*e4b17023SJohn Marino        *  [lo,hi) for which is(m,c) is true.  It does so by returning
189*e4b17023SJohn Marino        *  ctype<char_type>::do_scan_is().
190*e4b17023SJohn Marino        *
191*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
192*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
193*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
194*e4b17023SJohn Marino        *  @return  Pointer to matching char_type if found, else @a __hi.
195*e4b17023SJohn Marino       */
196*e4b17023SJohn Marino       const char_type*
197*e4b17023SJohn Marino       scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
198*e4b17023SJohn Marino       { return this->do_scan_is(__m, __lo, __hi); }
199*e4b17023SJohn Marino 
200*e4b17023SJohn Marino       /**
201*e4b17023SJohn Marino        *  @brief  Find char_type not matching a mask
202*e4b17023SJohn Marino        *
203*e4b17023SJohn Marino        *  This function searches for and returns the first char_type c in
204*e4b17023SJohn Marino        *  [lo,hi) for which is(m,c) is false.  It does so by returning
205*e4b17023SJohn Marino        *  ctype<char_type>::do_scan_not().
206*e4b17023SJohn Marino        *
207*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
208*e4b17023SJohn Marino        *  @param __lo  Pointer to first char in range.
209*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
210*e4b17023SJohn Marino        *  @return  Pointer to non-matching char if found, else @a __hi.
211*e4b17023SJohn Marino       */
212*e4b17023SJohn Marino       const char_type*
213*e4b17023SJohn Marino       scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
214*e4b17023SJohn Marino       { return this->do_scan_not(__m, __lo, __hi); }
215*e4b17023SJohn Marino 
216*e4b17023SJohn Marino       /**
217*e4b17023SJohn Marino        *  @brief  Convert to uppercase.
218*e4b17023SJohn Marino        *
219*e4b17023SJohn Marino        *  This function converts the argument to uppercase if possible.
220*e4b17023SJohn Marino        *  If not possible (for example, '2'), returns the argument.  It does
221*e4b17023SJohn Marino        *  so by returning ctype<char_type>::do_toupper().
222*e4b17023SJohn Marino        *
223*e4b17023SJohn Marino        *  @param __c  The char_type to convert.
224*e4b17023SJohn Marino        *  @return  The uppercase char_type if convertible, else @a __c.
225*e4b17023SJohn Marino       */
226*e4b17023SJohn Marino       char_type
227*e4b17023SJohn Marino       toupper(char_type __c) const
228*e4b17023SJohn Marino       { return this->do_toupper(__c); }
229*e4b17023SJohn Marino 
230*e4b17023SJohn Marino       /**
231*e4b17023SJohn Marino        *  @brief  Convert array to uppercase.
232*e4b17023SJohn Marino        *
233*e4b17023SJohn Marino        *  This function converts each char_type in the range [lo,hi) to
234*e4b17023SJohn Marino        *  uppercase if possible.  Other elements remain untouched.  It does so
235*e4b17023SJohn Marino        *  by returning ctype<char_type>:: do_toupper(lo, hi).
236*e4b17023SJohn Marino        *
237*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
238*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
239*e4b17023SJohn Marino        *  @return  @a __hi.
240*e4b17023SJohn Marino       */
241*e4b17023SJohn Marino       const char_type*
242*e4b17023SJohn Marino       toupper(char_type *__lo, const char_type* __hi) const
243*e4b17023SJohn Marino       { return this->do_toupper(__lo, __hi); }
244*e4b17023SJohn Marino 
245*e4b17023SJohn Marino       /**
246*e4b17023SJohn Marino        *  @brief  Convert to lowercase.
247*e4b17023SJohn Marino        *
248*e4b17023SJohn Marino        *  This function converts the argument to lowercase if possible.  If
249*e4b17023SJohn Marino        *  not possible (for example, '2'), returns the argument.  It does so
250*e4b17023SJohn Marino        *  by returning ctype<char_type>::do_tolower(c).
251*e4b17023SJohn Marino        *
252*e4b17023SJohn Marino        *  @param __c  The char_type to convert.
253*e4b17023SJohn Marino        *  @return  The lowercase char_type if convertible, else @a __c.
254*e4b17023SJohn Marino       */
255*e4b17023SJohn Marino       char_type
256*e4b17023SJohn Marino       tolower(char_type __c) const
257*e4b17023SJohn Marino       { return this->do_tolower(__c); }
258*e4b17023SJohn Marino 
259*e4b17023SJohn Marino       /**
260*e4b17023SJohn Marino        *  @brief  Convert array to lowercase.
261*e4b17023SJohn Marino        *
262*e4b17023SJohn Marino        *  This function converts each char_type in the range [__lo,__hi) to
263*e4b17023SJohn Marino        *  lowercase if possible.  Other elements remain untouched.  It does so
264*e4b17023SJohn Marino        *  by returning ctype<char_type>:: do_tolower(__lo, __hi).
265*e4b17023SJohn Marino        *
266*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
267*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
268*e4b17023SJohn Marino        *  @return  @a __hi.
269*e4b17023SJohn Marino       */
270*e4b17023SJohn Marino       const char_type*
271*e4b17023SJohn Marino       tolower(char_type* __lo, const char_type* __hi) const
272*e4b17023SJohn Marino       { return this->do_tolower(__lo, __hi); }
273*e4b17023SJohn Marino 
274*e4b17023SJohn Marino       /**
275*e4b17023SJohn Marino        *  @brief  Widen char to char_type
276*e4b17023SJohn Marino        *
277*e4b17023SJohn Marino        *  This function converts the char argument to char_type using the
278*e4b17023SJohn Marino        *  simplest reasonable transformation.  It does so by returning
279*e4b17023SJohn Marino        *  ctype<char_type>::do_widen(c).
280*e4b17023SJohn Marino        *
281*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
282*e4b17023SJohn Marino        *  codecvt for that.
283*e4b17023SJohn Marino        *
284*e4b17023SJohn Marino        *  @param __c  The char to convert.
285*e4b17023SJohn Marino        *  @return  The converted char_type.
286*e4b17023SJohn Marino       */
287*e4b17023SJohn Marino       char_type
288*e4b17023SJohn Marino       widen(char __c) const
289*e4b17023SJohn Marino       { return this->do_widen(__c); }
290*e4b17023SJohn Marino 
291*e4b17023SJohn Marino       /**
292*e4b17023SJohn Marino        *  @brief  Widen array to char_type
293*e4b17023SJohn Marino        *
294*e4b17023SJohn Marino        *  This function converts each char in the input to char_type using the
295*e4b17023SJohn Marino        *  simplest reasonable transformation.  It does so by returning
296*e4b17023SJohn Marino        *  ctype<char_type>::do_widen(c).
297*e4b17023SJohn Marino        *
298*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
299*e4b17023SJohn Marino        *  codecvt for that.
300*e4b17023SJohn Marino        *
301*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
302*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
303*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
304*e4b17023SJohn Marino        *  @return  @a __hi.
305*e4b17023SJohn Marino       */
306*e4b17023SJohn Marino       const char*
307*e4b17023SJohn Marino       widen(const char* __lo, const char* __hi, char_type* __to) const
308*e4b17023SJohn Marino       { return this->do_widen(__lo, __hi, __to); }
309*e4b17023SJohn Marino 
310*e4b17023SJohn Marino       /**
311*e4b17023SJohn Marino        *  @brief  Narrow char_type to char
312*e4b17023SJohn Marino        *
313*e4b17023SJohn Marino        *  This function converts the char_type to char using the simplest
314*e4b17023SJohn Marino        *  reasonable transformation.  If the conversion fails, dfault is
315*e4b17023SJohn Marino        *  returned instead.  It does so by returning
316*e4b17023SJohn Marino        *  ctype<char_type>::do_narrow(__c).
317*e4b17023SJohn Marino        *
318*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
319*e4b17023SJohn Marino        *  codecvt for that.
320*e4b17023SJohn Marino        *
321*e4b17023SJohn Marino        *  @param __c  The char_type to convert.
322*e4b17023SJohn Marino        *  @param __dfault  Char to return if conversion fails.
323*e4b17023SJohn Marino        *  @return  The converted char.
324*e4b17023SJohn Marino       */
325*e4b17023SJohn Marino       char
326*e4b17023SJohn Marino       narrow(char_type __c, char __dfault) const
327*e4b17023SJohn Marino       { return this->do_narrow(__c, __dfault); }
328*e4b17023SJohn Marino 
329*e4b17023SJohn Marino       /**
330*e4b17023SJohn Marino        *  @brief  Narrow array to char array
331*e4b17023SJohn Marino        *
332*e4b17023SJohn Marino        *  This function converts each char_type in the input to char using the
333*e4b17023SJohn Marino        *  simplest reasonable transformation and writes the results to the
334*e4b17023SJohn Marino        *  destination array.  For any char_type in the input that cannot be
335*e4b17023SJohn Marino        *  converted, @a dfault is used instead.  It does so by returning
336*e4b17023SJohn Marino        *  ctype<char_type>::do_narrow(__lo, __hi, __dfault, __to).
337*e4b17023SJohn Marino        *
338*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
339*e4b17023SJohn Marino        *  codecvt for that.
340*e4b17023SJohn Marino        *
341*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
342*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
343*e4b17023SJohn Marino        *  @param __dfault  Char to use if conversion fails.
344*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
345*e4b17023SJohn Marino        *  @return  @a __hi.
346*e4b17023SJohn Marino       */
347*e4b17023SJohn Marino       const char_type*
348*e4b17023SJohn Marino       narrow(const char_type* __lo, const char_type* __hi,
349*e4b17023SJohn Marino 	      char __dfault, char* __to) const
350*e4b17023SJohn Marino       { return this->do_narrow(__lo, __hi, __dfault, __to); }
351*e4b17023SJohn Marino 
352*e4b17023SJohn Marino     protected:
353*e4b17023SJohn Marino       explicit
354*e4b17023SJohn Marino       __ctype_abstract_base(size_t __refs = 0): facet(__refs) { }
355*e4b17023SJohn Marino 
356*e4b17023SJohn Marino       virtual
357*e4b17023SJohn Marino       ~__ctype_abstract_base() { }
358*e4b17023SJohn Marino 
359*e4b17023SJohn Marino       /**
360*e4b17023SJohn Marino        *  @brief  Test char_type classification.
361*e4b17023SJohn Marino        *
362*e4b17023SJohn Marino        *  This function finds a mask M for @a c and compares it to mask @a m.
363*e4b17023SJohn Marino        *
364*e4b17023SJohn Marino        *  do_is() is a hook for a derived facet to change the behavior of
365*e4b17023SJohn Marino        *  classifying.  do_is() must always return the same result for the
366*e4b17023SJohn Marino        *  same input.
367*e4b17023SJohn Marino        *
368*e4b17023SJohn Marino        *  @param __c  The char_type to find the mask of.
369*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
370*e4b17023SJohn Marino        *  @return  (M & __m) != 0.
371*e4b17023SJohn Marino       */
372*e4b17023SJohn Marino       virtual bool
373*e4b17023SJohn Marino       do_is(mask __m, char_type __c) const = 0;
374*e4b17023SJohn Marino 
375*e4b17023SJohn Marino       /**
376*e4b17023SJohn Marino        *  @brief  Return a mask array.
377*e4b17023SJohn Marino        *
378*e4b17023SJohn Marino        *  This function finds the mask for each char_type in the range [lo,hi)
379*e4b17023SJohn Marino        *  and successively writes it to vec.  vec must have as many elements
380*e4b17023SJohn Marino        *  as the input.
381*e4b17023SJohn Marino        *
382*e4b17023SJohn Marino        *  do_is() is a hook for a derived facet to change the behavior of
383*e4b17023SJohn Marino        *  classifying.  do_is() must always return the same result for the
384*e4b17023SJohn Marino        *  same input.
385*e4b17023SJohn Marino        *
386*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
387*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
388*e4b17023SJohn Marino        *  @param __vec  Pointer to an array of mask storage.
389*e4b17023SJohn Marino        *  @return  @a __hi.
390*e4b17023SJohn Marino       */
391*e4b17023SJohn Marino       virtual const char_type*
392*e4b17023SJohn Marino       do_is(const char_type* __lo, const char_type* __hi,
393*e4b17023SJohn Marino 	    mask* __vec) const = 0;
394*e4b17023SJohn Marino 
395*e4b17023SJohn Marino       /**
396*e4b17023SJohn Marino        *  @brief  Find char_type matching mask
397*e4b17023SJohn Marino        *
398*e4b17023SJohn Marino        *  This function searches for and returns the first char_type c in
399*e4b17023SJohn Marino        *  [__lo,__hi) for which is(__m,c) is true.
400*e4b17023SJohn Marino        *
401*e4b17023SJohn Marino        *  do_scan_is() is a hook for a derived facet to change the behavior of
402*e4b17023SJohn Marino        *  match searching.  do_is() must always return the same result for the
403*e4b17023SJohn Marino        *  same input.
404*e4b17023SJohn Marino        *
405*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
406*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
407*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
408*e4b17023SJohn Marino        *  @return  Pointer to a matching char_type if found, else @a __hi.
409*e4b17023SJohn Marino       */
410*e4b17023SJohn Marino       virtual const char_type*
411*e4b17023SJohn Marino       do_scan_is(mask __m, const char_type* __lo,
412*e4b17023SJohn Marino 		 const char_type* __hi) const = 0;
413*e4b17023SJohn Marino 
414*e4b17023SJohn Marino       /**
415*e4b17023SJohn Marino        *  @brief  Find char_type not matching mask
416*e4b17023SJohn Marino        *
417*e4b17023SJohn Marino        *  This function searches for and returns a pointer to the first
418*e4b17023SJohn Marino        *  char_type c of [lo,hi) for which is(m,c) is false.
419*e4b17023SJohn Marino        *
420*e4b17023SJohn Marino        *  do_scan_is() is a hook for a derived facet to change the behavior of
421*e4b17023SJohn Marino        *  match searching.  do_is() must always return the same result for the
422*e4b17023SJohn Marino        *  same input.
423*e4b17023SJohn Marino        *
424*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
425*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
426*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
427*e4b17023SJohn Marino        *  @return  Pointer to a non-matching char_type if found, else @a __hi.
428*e4b17023SJohn Marino       */
429*e4b17023SJohn Marino       virtual const char_type*
430*e4b17023SJohn Marino       do_scan_not(mask __m, const char_type* __lo,
431*e4b17023SJohn Marino 		  const char_type* __hi) const = 0;
432*e4b17023SJohn Marino 
433*e4b17023SJohn Marino       /**
434*e4b17023SJohn Marino        *  @brief  Convert to uppercase.
435*e4b17023SJohn Marino        *
436*e4b17023SJohn Marino        *  This virtual function converts the char_type argument to uppercase
437*e4b17023SJohn Marino        *  if possible.  If not possible (for example, '2'), returns the
438*e4b17023SJohn Marino        *  argument.
439*e4b17023SJohn Marino        *
440*e4b17023SJohn Marino        *  do_toupper() is a hook for a derived facet to change the behavior of
441*e4b17023SJohn Marino        *  uppercasing.  do_toupper() must always return the same result for
442*e4b17023SJohn Marino        *  the same input.
443*e4b17023SJohn Marino        *
444*e4b17023SJohn Marino        *  @param __c  The char_type to convert.
445*e4b17023SJohn Marino        *  @return  The uppercase char_type if convertible, else @a __c.
446*e4b17023SJohn Marino       */
447*e4b17023SJohn Marino       virtual char_type
448*e4b17023SJohn Marino       do_toupper(char_type __c) const = 0;
449*e4b17023SJohn Marino 
450*e4b17023SJohn Marino       /**
451*e4b17023SJohn Marino        *  @brief  Convert array to uppercase.
452*e4b17023SJohn Marino        *
453*e4b17023SJohn Marino        *  This virtual function converts each char_type in the range [__lo,__hi)
454*e4b17023SJohn Marino        *  to uppercase if possible.  Other elements remain untouched.
455*e4b17023SJohn Marino        *
456*e4b17023SJohn Marino        *  do_toupper() is a hook for a derived facet to change the behavior of
457*e4b17023SJohn Marino        *  uppercasing.  do_toupper() must always return the same result for
458*e4b17023SJohn Marino        *  the same input.
459*e4b17023SJohn Marino        *
460*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
461*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
462*e4b17023SJohn Marino        *  @return  @a __hi.
463*e4b17023SJohn Marino       */
464*e4b17023SJohn Marino       virtual const char_type*
465*e4b17023SJohn Marino       do_toupper(char_type* __lo, const char_type* __hi) const = 0;
466*e4b17023SJohn Marino 
467*e4b17023SJohn Marino       /**
468*e4b17023SJohn Marino        *  @brief  Convert to lowercase.
469*e4b17023SJohn Marino        *
470*e4b17023SJohn Marino        *  This virtual function converts the argument to lowercase if
471*e4b17023SJohn Marino        *  possible.  If not possible (for example, '2'), returns the argument.
472*e4b17023SJohn Marino        *
473*e4b17023SJohn Marino        *  do_tolower() is a hook for a derived facet to change the behavior of
474*e4b17023SJohn Marino        *  lowercasing.  do_tolower() must always return the same result for
475*e4b17023SJohn Marino        *  the same input.
476*e4b17023SJohn Marino        *
477*e4b17023SJohn Marino        *  @param __c  The char_type to convert.
478*e4b17023SJohn Marino        *  @return  The lowercase char_type if convertible, else @a __c.
479*e4b17023SJohn Marino       */
480*e4b17023SJohn Marino       virtual char_type
481*e4b17023SJohn Marino       do_tolower(char_type __c) const = 0;
482*e4b17023SJohn Marino 
483*e4b17023SJohn Marino       /**
484*e4b17023SJohn Marino        *  @brief  Convert array to lowercase.
485*e4b17023SJohn Marino        *
486*e4b17023SJohn Marino        *  This virtual function converts each char_type in the range [__lo,__hi)
487*e4b17023SJohn Marino        *  to lowercase if possible.  Other elements remain untouched.
488*e4b17023SJohn Marino        *
489*e4b17023SJohn Marino        *  do_tolower() is a hook for a derived facet to change the behavior of
490*e4b17023SJohn Marino        *  lowercasing.  do_tolower() must always return the same result for
491*e4b17023SJohn Marino        *  the same input.
492*e4b17023SJohn Marino        *
493*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
494*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
495*e4b17023SJohn Marino        *  @return  @a __hi.
496*e4b17023SJohn Marino       */
497*e4b17023SJohn Marino       virtual const char_type*
498*e4b17023SJohn Marino       do_tolower(char_type* __lo, const char_type* __hi) const = 0;
499*e4b17023SJohn Marino 
500*e4b17023SJohn Marino       /**
501*e4b17023SJohn Marino        *  @brief  Widen char
502*e4b17023SJohn Marino        *
503*e4b17023SJohn Marino        *  This virtual function converts the char to char_type using the
504*e4b17023SJohn Marino        *  simplest reasonable transformation.
505*e4b17023SJohn Marino        *
506*e4b17023SJohn Marino        *  do_widen() is a hook for a derived facet to change the behavior of
507*e4b17023SJohn Marino        *  widening.  do_widen() must always return the same result for the
508*e4b17023SJohn Marino        *  same input.
509*e4b17023SJohn Marino        *
510*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
511*e4b17023SJohn Marino        *  codecvt for that.
512*e4b17023SJohn Marino        *
513*e4b17023SJohn Marino        *  @param __c  The char to convert.
514*e4b17023SJohn Marino        *  @return  The converted char_type
515*e4b17023SJohn Marino       */
516*e4b17023SJohn Marino       virtual char_type
517*e4b17023SJohn Marino       do_widen(char __c) const = 0;
518*e4b17023SJohn Marino 
519*e4b17023SJohn Marino       /**
520*e4b17023SJohn Marino        *  @brief  Widen char array
521*e4b17023SJohn Marino        *
522*e4b17023SJohn Marino        *  This function converts each char in the input to char_type using the
523*e4b17023SJohn Marino        *  simplest reasonable transformation.
524*e4b17023SJohn Marino        *
525*e4b17023SJohn Marino        *  do_widen() is a hook for a derived facet to change the behavior of
526*e4b17023SJohn Marino        *  widening.  do_widen() must always return the same result for the
527*e4b17023SJohn Marino        *  same input.
528*e4b17023SJohn Marino        *
529*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
530*e4b17023SJohn Marino        *  codecvt for that.
531*e4b17023SJohn Marino        *
532*e4b17023SJohn Marino        *  @param __lo  Pointer to start range.
533*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
534*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
535*e4b17023SJohn Marino        *  @return  @a __hi.
536*e4b17023SJohn Marino       */
537*e4b17023SJohn Marino       virtual const char*
538*e4b17023SJohn Marino       do_widen(const char* __lo, const char* __hi, char_type* __to) const = 0;
539*e4b17023SJohn Marino 
540*e4b17023SJohn Marino       /**
541*e4b17023SJohn Marino        *  @brief  Narrow char_type to char
542*e4b17023SJohn Marino        *
543*e4b17023SJohn Marino        *  This virtual function converts the argument to char using the
544*e4b17023SJohn Marino        *  simplest reasonable transformation.  If the conversion fails, dfault
545*e4b17023SJohn Marino        *  is returned instead.
546*e4b17023SJohn Marino        *
547*e4b17023SJohn Marino        *  do_narrow() is a hook for a derived facet to change the behavior of
548*e4b17023SJohn Marino        *  narrowing.  do_narrow() must always return the same result for the
549*e4b17023SJohn Marino        *  same input.
550*e4b17023SJohn Marino        *
551*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
552*e4b17023SJohn Marino        *  codecvt for that.
553*e4b17023SJohn Marino        *
554*e4b17023SJohn Marino        *  @param __c  The char_type to convert.
555*e4b17023SJohn Marino        *  @param __dfault  Char to return if conversion fails.
556*e4b17023SJohn Marino        *  @return  The converted char.
557*e4b17023SJohn Marino       */
558*e4b17023SJohn Marino       virtual char
559*e4b17023SJohn Marino       do_narrow(char_type __c, char __dfault) const = 0;
560*e4b17023SJohn Marino 
561*e4b17023SJohn Marino       /**
562*e4b17023SJohn Marino        *  @brief  Narrow char_type array to char
563*e4b17023SJohn Marino        *
564*e4b17023SJohn Marino        *  This virtual function converts each char_type in the range
565*e4b17023SJohn Marino        *  [__lo,__hi) to char using the simplest reasonable
566*e4b17023SJohn Marino        *  transformation and writes the results to the destination
567*e4b17023SJohn Marino        *  array.  For any element in the input that cannot be
568*e4b17023SJohn Marino        *  converted, @a __dfault is used instead.
569*e4b17023SJohn Marino        *
570*e4b17023SJohn Marino        *  do_narrow() is a hook for a derived facet to change the behavior of
571*e4b17023SJohn Marino        *  narrowing.  do_narrow() must always return the same result for the
572*e4b17023SJohn Marino        *  same input.
573*e4b17023SJohn Marino        *
574*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
575*e4b17023SJohn Marino        *  codecvt for that.
576*e4b17023SJohn Marino        *
577*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
578*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
579*e4b17023SJohn Marino        *  @param __dfault  Char to use if conversion fails.
580*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
581*e4b17023SJohn Marino        *  @return  @a __hi.
582*e4b17023SJohn Marino       */
583*e4b17023SJohn Marino       virtual const char_type*
584*e4b17023SJohn Marino       do_narrow(const char_type* __lo, const char_type* __hi,
585*e4b17023SJohn Marino 		char __dfault, char* __to) const = 0;
586*e4b17023SJohn Marino     };
587*e4b17023SJohn Marino 
588*e4b17023SJohn Marino   /**
589*e4b17023SJohn Marino    *  @brief  Primary class template ctype facet.
590*e4b17023SJohn Marino    *  @ingroup locales
591*e4b17023SJohn Marino    *
592*e4b17023SJohn Marino    *  This template class defines classification and conversion functions for
593*e4b17023SJohn Marino    *  character sets.  It wraps cctype functionality.  Ctype gets used by
594*e4b17023SJohn Marino    *  streams for many I/O operations.
595*e4b17023SJohn Marino    *
596*e4b17023SJohn Marino    *  This template provides the protected virtual functions the developer
597*e4b17023SJohn Marino    *  will have to replace in a derived class or specialization to make a
598*e4b17023SJohn Marino    *  working facet.  The public functions that access them are defined in
599*e4b17023SJohn Marino    *  __ctype_abstract_base, to allow for implementation flexibility.  See
600*e4b17023SJohn Marino    *  ctype<wchar_t> for an example.  The functions are documented in
601*e4b17023SJohn Marino    *  __ctype_abstract_base.
602*e4b17023SJohn Marino    *
603*e4b17023SJohn Marino    *  Note: implementations are provided for all the protected virtual
604*e4b17023SJohn Marino    *  functions, but will likely not be useful.
605*e4b17023SJohn Marino   */
606*e4b17023SJohn Marino   template<typename _CharT>
607*e4b17023SJohn Marino     class ctype : public __ctype_abstract_base<_CharT>
608*e4b17023SJohn Marino     {
609*e4b17023SJohn Marino     public:
610*e4b17023SJohn Marino       // Types:
611*e4b17023SJohn Marino       typedef _CharT			char_type;
612*e4b17023SJohn Marino       typedef typename __ctype_abstract_base<_CharT>::mask mask;
613*e4b17023SJohn Marino 
614*e4b17023SJohn Marino       /// The facet id for ctype<char_type>
615*e4b17023SJohn Marino       static locale::id			id;
616*e4b17023SJohn Marino 
617*e4b17023SJohn Marino       explicit
618*e4b17023SJohn Marino       ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { }
619*e4b17023SJohn Marino 
620*e4b17023SJohn Marino    protected:
621*e4b17023SJohn Marino       virtual
622*e4b17023SJohn Marino       ~ctype();
623*e4b17023SJohn Marino 
624*e4b17023SJohn Marino       virtual bool
625*e4b17023SJohn Marino       do_is(mask __m, char_type __c) const;
626*e4b17023SJohn Marino 
627*e4b17023SJohn Marino       virtual const char_type*
628*e4b17023SJohn Marino       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
629*e4b17023SJohn Marino 
630*e4b17023SJohn Marino       virtual const char_type*
631*e4b17023SJohn Marino       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
632*e4b17023SJohn Marino 
633*e4b17023SJohn Marino       virtual const char_type*
634*e4b17023SJohn Marino       do_scan_not(mask __m, const char_type* __lo,
635*e4b17023SJohn Marino 		  const char_type* __hi) const;
636*e4b17023SJohn Marino 
637*e4b17023SJohn Marino       virtual char_type
638*e4b17023SJohn Marino       do_toupper(char_type __c) const;
639*e4b17023SJohn Marino 
640*e4b17023SJohn Marino       virtual const char_type*
641*e4b17023SJohn Marino       do_toupper(char_type* __lo, const char_type* __hi) const;
642*e4b17023SJohn Marino 
643*e4b17023SJohn Marino       virtual char_type
644*e4b17023SJohn Marino       do_tolower(char_type __c) const;
645*e4b17023SJohn Marino 
646*e4b17023SJohn Marino       virtual const char_type*
647*e4b17023SJohn Marino       do_tolower(char_type* __lo, const char_type* __hi) const;
648*e4b17023SJohn Marino 
649*e4b17023SJohn Marino       virtual char_type
650*e4b17023SJohn Marino       do_widen(char __c) const;
651*e4b17023SJohn Marino 
652*e4b17023SJohn Marino       virtual const char*
653*e4b17023SJohn Marino       do_widen(const char* __lo, const char* __hi, char_type* __dest) const;
654*e4b17023SJohn Marino 
655*e4b17023SJohn Marino       virtual char
656*e4b17023SJohn Marino       do_narrow(char_type, char __dfault) const;
657*e4b17023SJohn Marino 
658*e4b17023SJohn Marino       virtual const char_type*
659*e4b17023SJohn Marino       do_narrow(const char_type* __lo, const char_type* __hi,
660*e4b17023SJohn Marino 		char __dfault, char* __to) const;
661*e4b17023SJohn Marino     };
662*e4b17023SJohn Marino 
663*e4b17023SJohn Marino   template<typename _CharT>
664*e4b17023SJohn Marino     locale::id ctype<_CharT>::id;
665*e4b17023SJohn Marino 
666*e4b17023SJohn Marino   /**
667*e4b17023SJohn Marino    *  @brief  The ctype<char> specialization.
668*e4b17023SJohn Marino    *  @ingroup locales
669*e4b17023SJohn Marino    *
670*e4b17023SJohn Marino    *  This class defines classification and conversion functions for
671*e4b17023SJohn Marino    *  the char type.  It gets used by char streams for many I/O
672*e4b17023SJohn Marino    *  operations.  The char specialization provides a number of
673*e4b17023SJohn Marino    *  optimizations as well.
674*e4b17023SJohn Marino   */
675*e4b17023SJohn Marino   template<>
676*e4b17023SJohn Marino     class ctype<char> : public locale::facet, public ctype_base
677*e4b17023SJohn Marino     {
678*e4b17023SJohn Marino     public:
679*e4b17023SJohn Marino       // Types:
680*e4b17023SJohn Marino       /// Typedef for the template parameter char.
681*e4b17023SJohn Marino       typedef char		char_type;
682*e4b17023SJohn Marino 
683*e4b17023SJohn Marino     protected:
684*e4b17023SJohn Marino       // Data Members:
685*e4b17023SJohn Marino       __c_locale		_M_c_locale_ctype;
686*e4b17023SJohn Marino       bool			_M_del;
687*e4b17023SJohn Marino       __to_type			_M_toupper;
688*e4b17023SJohn Marino       __to_type			_M_tolower;
689*e4b17023SJohn Marino       const mask*		_M_table;
690*e4b17023SJohn Marino       mutable char		_M_widen_ok;
691*e4b17023SJohn Marino       mutable char		_M_widen[1 + static_cast<unsigned char>(-1)];
692*e4b17023SJohn Marino       mutable char		_M_narrow[1 + static_cast<unsigned char>(-1)];
693*e4b17023SJohn Marino       mutable char		_M_narrow_ok;	// 0 uninitialized, 1 init,
694*e4b17023SJohn Marino 						// 2 memcpy can't be used
695*e4b17023SJohn Marino 
696*e4b17023SJohn Marino     public:
697*e4b17023SJohn Marino       /// The facet id for ctype<char>
698*e4b17023SJohn Marino       static locale::id        id;
699*e4b17023SJohn Marino       /// The size of the mask table.  It is SCHAR_MAX + 1.
700*e4b17023SJohn Marino       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
701*e4b17023SJohn Marino 
702*e4b17023SJohn Marino       /**
703*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
704*e4b17023SJohn Marino        *
705*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
706*e4b17023SJohn Marino        *
707*e4b17023SJohn Marino        *  @param __table If non-zero, table is used as the per-char mask.
708*e4b17023SJohn Marino        *               Else classic_table() is used.
709*e4b17023SJohn Marino        *  @param __del   If true, passes ownership of table to this facet.
710*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
711*e4b17023SJohn Marino       */
712*e4b17023SJohn Marino       explicit
713*e4b17023SJohn Marino       ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0);
714*e4b17023SJohn Marino 
715*e4b17023SJohn Marino       /**
716*e4b17023SJohn Marino        *  @brief  Constructor performs static initialization.
717*e4b17023SJohn Marino        *
718*e4b17023SJohn Marino        *  This constructor is used to construct the initial C locale facet.
719*e4b17023SJohn Marino        *
720*e4b17023SJohn Marino        *  @param __cloc  Handle to C locale data.
721*e4b17023SJohn Marino        *  @param __table If non-zero, table is used as the per-char mask.
722*e4b17023SJohn Marino        *  @param __del   If true, passes ownership of table to this facet.
723*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
724*e4b17023SJohn Marino       */
725*e4b17023SJohn Marino       explicit
726*e4b17023SJohn Marino       ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false,
727*e4b17023SJohn Marino 	    size_t __refs = 0);
728*e4b17023SJohn Marino 
729*e4b17023SJohn Marino       /**
730*e4b17023SJohn Marino        *  @brief  Test char classification.
731*e4b17023SJohn Marino        *
732*e4b17023SJohn Marino        *  This function compares the mask table[c] to @a __m.
733*e4b17023SJohn Marino        *
734*e4b17023SJohn Marino        *  @param __c  The char to compare the mask of.
735*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
736*e4b17023SJohn Marino        *  @return  True if __m & table[__c] is true, false otherwise.
737*e4b17023SJohn Marino       */
738*e4b17023SJohn Marino       inline bool
739*e4b17023SJohn Marino       is(mask __m, char __c) const;
740*e4b17023SJohn Marino 
741*e4b17023SJohn Marino       /**
742*e4b17023SJohn Marino        *  @brief  Return a mask array.
743*e4b17023SJohn Marino        *
744*e4b17023SJohn Marino        *  This function finds the mask for each char in the range [lo, hi) and
745*e4b17023SJohn Marino        *  successively writes it to vec.  vec must have as many elements as
746*e4b17023SJohn Marino        *  the char array.
747*e4b17023SJohn Marino        *
748*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
749*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
750*e4b17023SJohn Marino        *  @param __vec  Pointer to an array of mask storage.
751*e4b17023SJohn Marino        *  @return  @a __hi.
752*e4b17023SJohn Marino       */
753*e4b17023SJohn Marino       inline const char*
754*e4b17023SJohn Marino       is(const char* __lo, const char* __hi, mask* __vec) const;
755*e4b17023SJohn Marino 
756*e4b17023SJohn Marino       /**
757*e4b17023SJohn Marino        *  @brief  Find char matching a mask
758*e4b17023SJohn Marino        *
759*e4b17023SJohn Marino        *  This function searches for and returns the first char in [lo,hi) for
760*e4b17023SJohn Marino        *  which is(m,char) is true.
761*e4b17023SJohn Marino        *
762*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
763*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
764*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
765*e4b17023SJohn Marino        *  @return  Pointer to a matching char if found, else @a __hi.
766*e4b17023SJohn Marino       */
767*e4b17023SJohn Marino       inline const char*
768*e4b17023SJohn Marino       scan_is(mask __m, const char* __lo, const char* __hi) const;
769*e4b17023SJohn Marino 
770*e4b17023SJohn Marino       /**
771*e4b17023SJohn Marino        *  @brief  Find char not matching a mask
772*e4b17023SJohn Marino        *
773*e4b17023SJohn Marino        *  This function searches for and returns a pointer to the first char
774*e4b17023SJohn Marino        *  in [__lo,__hi) for which is(m,char) is false.
775*e4b17023SJohn Marino        *
776*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
777*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
778*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
779*e4b17023SJohn Marino        *  @return  Pointer to a non-matching char if found, else @a __hi.
780*e4b17023SJohn Marino       */
781*e4b17023SJohn Marino       inline const char*
782*e4b17023SJohn Marino       scan_not(mask __m, const char* __lo, const char* __hi) const;
783*e4b17023SJohn Marino 
784*e4b17023SJohn Marino       /**
785*e4b17023SJohn Marino        *  @brief  Convert to uppercase.
786*e4b17023SJohn Marino        *
787*e4b17023SJohn Marino        *  This function converts the char argument to uppercase if possible.
788*e4b17023SJohn Marino        *  If not possible (for example, '2'), returns the argument.
789*e4b17023SJohn Marino        *
790*e4b17023SJohn Marino        *  toupper() acts as if it returns ctype<char>::do_toupper(c).
791*e4b17023SJohn Marino        *  do_toupper() must always return the same result for the same input.
792*e4b17023SJohn Marino        *
793*e4b17023SJohn Marino        *  @param __c  The char to convert.
794*e4b17023SJohn Marino        *  @return  The uppercase char if convertible, else @a __c.
795*e4b17023SJohn Marino       */
796*e4b17023SJohn Marino       char_type
797*e4b17023SJohn Marino       toupper(char_type __c) const
798*e4b17023SJohn Marino       { return this->do_toupper(__c); }
799*e4b17023SJohn Marino 
800*e4b17023SJohn Marino       /**
801*e4b17023SJohn Marino        *  @brief  Convert array to uppercase.
802*e4b17023SJohn Marino        *
803*e4b17023SJohn Marino        *  This function converts each char in the range [__lo,__hi) to uppercase
804*e4b17023SJohn Marino        *  if possible.  Other chars remain untouched.
805*e4b17023SJohn Marino        *
806*e4b17023SJohn Marino        *  toupper() acts as if it returns ctype<char>:: do_toupper(__lo, __hi).
807*e4b17023SJohn Marino        *  do_toupper() must always return the same result for the same input.
808*e4b17023SJohn Marino        *
809*e4b17023SJohn Marino        *  @param __lo  Pointer to first char in range.
810*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
811*e4b17023SJohn Marino        *  @return  @a __hi.
812*e4b17023SJohn Marino       */
813*e4b17023SJohn Marino       const char_type*
814*e4b17023SJohn Marino       toupper(char_type *__lo, const char_type* __hi) const
815*e4b17023SJohn Marino       { return this->do_toupper(__lo, __hi); }
816*e4b17023SJohn Marino 
817*e4b17023SJohn Marino       /**
818*e4b17023SJohn Marino        *  @brief  Convert to lowercase.
819*e4b17023SJohn Marino        *
820*e4b17023SJohn Marino        *  This function converts the char argument to lowercase if possible.
821*e4b17023SJohn Marino        *  If not possible (for example, '2'), returns the argument.
822*e4b17023SJohn Marino        *
823*e4b17023SJohn Marino        *  tolower() acts as if it returns ctype<char>::do_tolower(__c).
824*e4b17023SJohn Marino        *  do_tolower() must always return the same result for the same input.
825*e4b17023SJohn Marino        *
826*e4b17023SJohn Marino        *  @param __c  The char to convert.
827*e4b17023SJohn Marino        *  @return  The lowercase char if convertible, else @a __c.
828*e4b17023SJohn Marino       */
829*e4b17023SJohn Marino       char_type
830*e4b17023SJohn Marino       tolower(char_type __c) const
831*e4b17023SJohn Marino       { return this->do_tolower(__c); }
832*e4b17023SJohn Marino 
833*e4b17023SJohn Marino       /**
834*e4b17023SJohn Marino        *  @brief  Convert array to lowercase.
835*e4b17023SJohn Marino        *
836*e4b17023SJohn Marino        *  This function converts each char in the range [lo,hi) to lowercase
837*e4b17023SJohn Marino        *  if possible.  Other chars remain untouched.
838*e4b17023SJohn Marino        *
839*e4b17023SJohn Marino        *  tolower() acts as if it returns ctype<char>:: do_tolower(__lo, __hi).
840*e4b17023SJohn Marino        *  do_tolower() must always return the same result for the same input.
841*e4b17023SJohn Marino        *
842*e4b17023SJohn Marino        *  @param __lo  Pointer to first char in range.
843*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
844*e4b17023SJohn Marino        *  @return  @a __hi.
845*e4b17023SJohn Marino       */
846*e4b17023SJohn Marino       const char_type*
847*e4b17023SJohn Marino       tolower(char_type* __lo, const char_type* __hi) const
848*e4b17023SJohn Marino       { return this->do_tolower(__lo, __hi); }
849*e4b17023SJohn Marino 
850*e4b17023SJohn Marino       /**
851*e4b17023SJohn Marino        *  @brief  Widen char
852*e4b17023SJohn Marino        *
853*e4b17023SJohn Marino        *  This function converts the char to char_type using the simplest
854*e4b17023SJohn Marino        *  reasonable transformation.  For an underived ctype<char> facet, the
855*e4b17023SJohn Marino        *  argument will be returned unchanged.
856*e4b17023SJohn Marino        *
857*e4b17023SJohn Marino        *  This function works as if it returns ctype<char>::do_widen(c).
858*e4b17023SJohn Marino        *  do_widen() must always return the same result for the same input.
859*e4b17023SJohn Marino        *
860*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
861*e4b17023SJohn Marino        *  codecvt for that.
862*e4b17023SJohn Marino        *
863*e4b17023SJohn Marino        *  @param __c  The char to convert.
864*e4b17023SJohn Marino        *  @return  The converted character.
865*e4b17023SJohn Marino       */
866*e4b17023SJohn Marino       char_type
867*e4b17023SJohn Marino       widen(char __c) const
868*e4b17023SJohn Marino       {
869*e4b17023SJohn Marino 	if (_M_widen_ok)
870*e4b17023SJohn Marino 	  return _M_widen[static_cast<unsigned char>(__c)];
871*e4b17023SJohn Marino 	this->_M_widen_init();
872*e4b17023SJohn Marino 	return this->do_widen(__c);
873*e4b17023SJohn Marino       }
874*e4b17023SJohn Marino 
875*e4b17023SJohn Marino       /**
876*e4b17023SJohn Marino        *  @brief  Widen char array
877*e4b17023SJohn Marino        *
878*e4b17023SJohn Marino        *  This function converts each char in the input to char using the
879*e4b17023SJohn Marino        *  simplest reasonable transformation.  For an underived ctype<char>
880*e4b17023SJohn Marino        *  facet, the argument will be copied unchanged.
881*e4b17023SJohn Marino        *
882*e4b17023SJohn Marino        *  This function works as if it returns ctype<char>::do_widen(c).
883*e4b17023SJohn Marino        *  do_widen() must always return the same result for the same input.
884*e4b17023SJohn Marino        *
885*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
886*e4b17023SJohn Marino        *  codecvt for that.
887*e4b17023SJohn Marino        *
888*e4b17023SJohn Marino        *  @param __lo  Pointer to first char in range.
889*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
890*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
891*e4b17023SJohn Marino        *  @return  @a __hi.
892*e4b17023SJohn Marino       */
893*e4b17023SJohn Marino       const char*
894*e4b17023SJohn Marino       widen(const char* __lo, const char* __hi, char_type* __to) const
895*e4b17023SJohn Marino       {
896*e4b17023SJohn Marino 	if (_M_widen_ok == 1)
897*e4b17023SJohn Marino 	  {
898*e4b17023SJohn Marino 	    __builtin_memcpy(__to, __lo, __hi - __lo);
899*e4b17023SJohn Marino 	    return __hi;
900*e4b17023SJohn Marino 	  }
901*e4b17023SJohn Marino 	if (!_M_widen_ok)
902*e4b17023SJohn Marino 	  _M_widen_init();
903*e4b17023SJohn Marino 	return this->do_widen(__lo, __hi, __to);
904*e4b17023SJohn Marino       }
905*e4b17023SJohn Marino 
906*e4b17023SJohn Marino       /**
907*e4b17023SJohn Marino        *  @brief  Narrow char
908*e4b17023SJohn Marino        *
909*e4b17023SJohn Marino        *  This function converts the char to char using the simplest
910*e4b17023SJohn Marino        *  reasonable transformation.  If the conversion fails, dfault is
911*e4b17023SJohn Marino        *  returned instead.  For an underived ctype<char> facet, @a c
912*e4b17023SJohn Marino        *  will be returned unchanged.
913*e4b17023SJohn Marino        *
914*e4b17023SJohn Marino        *  This function works as if it returns ctype<char>::do_narrow(c).
915*e4b17023SJohn Marino        *  do_narrow() must always return the same result for the same input.
916*e4b17023SJohn Marino        *
917*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
918*e4b17023SJohn Marino        *  codecvt for that.
919*e4b17023SJohn Marino        *
920*e4b17023SJohn Marino        *  @param __c  The char to convert.
921*e4b17023SJohn Marino        *  @param __dfault  Char to return if conversion fails.
922*e4b17023SJohn Marino        *  @return  The converted character.
923*e4b17023SJohn Marino       */
924*e4b17023SJohn Marino       char
925*e4b17023SJohn Marino       narrow(char_type __c, char __dfault) const
926*e4b17023SJohn Marino       {
927*e4b17023SJohn Marino 	if (_M_narrow[static_cast<unsigned char>(__c)])
928*e4b17023SJohn Marino 	  return _M_narrow[static_cast<unsigned char>(__c)];
929*e4b17023SJohn Marino 	const char __t = do_narrow(__c, __dfault);
930*e4b17023SJohn Marino 	if (__t != __dfault)
931*e4b17023SJohn Marino 	  _M_narrow[static_cast<unsigned char>(__c)] = __t;
932*e4b17023SJohn Marino 	return __t;
933*e4b17023SJohn Marino       }
934*e4b17023SJohn Marino 
935*e4b17023SJohn Marino       /**
936*e4b17023SJohn Marino        *  @brief  Narrow char array
937*e4b17023SJohn Marino        *
938*e4b17023SJohn Marino        *  This function converts each char in the input to char using the
939*e4b17023SJohn Marino        *  simplest reasonable transformation and writes the results to the
940*e4b17023SJohn Marino        *  destination array.  For any char in the input that cannot be
941*e4b17023SJohn Marino        *  converted, @a dfault is used instead.  For an underived ctype<char>
942*e4b17023SJohn Marino        *  facet, the argument will be copied unchanged.
943*e4b17023SJohn Marino        *
944*e4b17023SJohn Marino        *  This function works as if it returns ctype<char>::do_narrow(lo, hi,
945*e4b17023SJohn Marino        *  dfault, to).  do_narrow() must always return the same result for the
946*e4b17023SJohn Marino        *  same input.
947*e4b17023SJohn Marino        *
948*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
949*e4b17023SJohn Marino        *  codecvt for that.
950*e4b17023SJohn Marino        *
951*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
952*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
953*e4b17023SJohn Marino        *  @param __dfault  Char to use if conversion fails.
954*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
955*e4b17023SJohn Marino        *  @return  @a __hi.
956*e4b17023SJohn Marino       */
957*e4b17023SJohn Marino       const char_type*
958*e4b17023SJohn Marino       narrow(const char_type* __lo, const char_type* __hi,
959*e4b17023SJohn Marino 	     char __dfault, char* __to) const
960*e4b17023SJohn Marino       {
961*e4b17023SJohn Marino 	if (__builtin_expect(_M_narrow_ok == 1, true))
962*e4b17023SJohn Marino 	  {
963*e4b17023SJohn Marino 	    __builtin_memcpy(__to, __lo, __hi - __lo);
964*e4b17023SJohn Marino 	    return __hi;
965*e4b17023SJohn Marino 	  }
966*e4b17023SJohn Marino 	if (!_M_narrow_ok)
967*e4b17023SJohn Marino 	  _M_narrow_init();
968*e4b17023SJohn Marino 	return this->do_narrow(__lo, __hi, __dfault, __to);
969*e4b17023SJohn Marino       }
970*e4b17023SJohn Marino 
971*e4b17023SJohn Marino       // _GLIBCXX_RESOLVE_LIB_DEFECTS
972*e4b17023SJohn Marino       // DR 695. ctype<char>::classic_table() not accessible.
973*e4b17023SJohn Marino       /// Returns a pointer to the mask table provided to the constructor, or
974*e4b17023SJohn Marino       /// the default from classic_table() if none was provided.
975*e4b17023SJohn Marino       const mask*
976*e4b17023SJohn Marino       table() const throw()
977*e4b17023SJohn Marino       { return _M_table; }
978*e4b17023SJohn Marino 
979*e4b17023SJohn Marino       /// Returns a pointer to the C locale mask table.
980*e4b17023SJohn Marino       static const mask*
981*e4b17023SJohn Marino       classic_table() throw();
982*e4b17023SJohn Marino     protected:
983*e4b17023SJohn Marino 
984*e4b17023SJohn Marino       /**
985*e4b17023SJohn Marino        *  @brief  Destructor.
986*e4b17023SJohn Marino        *
987*e4b17023SJohn Marino        *  This function deletes table() if @a del was true in the
988*e4b17023SJohn Marino        *  constructor.
989*e4b17023SJohn Marino       */
990*e4b17023SJohn Marino       virtual
991*e4b17023SJohn Marino       ~ctype();
992*e4b17023SJohn Marino 
993*e4b17023SJohn Marino       /**
994*e4b17023SJohn Marino        *  @brief  Convert to uppercase.
995*e4b17023SJohn Marino        *
996*e4b17023SJohn Marino        *  This virtual function converts the char argument to uppercase if
997*e4b17023SJohn Marino        *  possible.  If not possible (for example, '2'), returns the argument.
998*e4b17023SJohn Marino        *
999*e4b17023SJohn Marino        *  do_toupper() is a hook for a derived facet to change the behavior of
1000*e4b17023SJohn Marino        *  uppercasing.  do_toupper() must always return the same result for
1001*e4b17023SJohn Marino        *  the same input.
1002*e4b17023SJohn Marino        *
1003*e4b17023SJohn Marino        *  @param __c  The char to convert.
1004*e4b17023SJohn Marino        *  @return  The uppercase char if convertible, else @a __c.
1005*e4b17023SJohn Marino       */
1006*e4b17023SJohn Marino       virtual char_type
1007*e4b17023SJohn Marino       do_toupper(char_type __c) const;
1008*e4b17023SJohn Marino 
1009*e4b17023SJohn Marino       /**
1010*e4b17023SJohn Marino        *  @brief  Convert array to uppercase.
1011*e4b17023SJohn Marino        *
1012*e4b17023SJohn Marino        *  This virtual function converts each char in the range [lo,hi) to
1013*e4b17023SJohn Marino        *  uppercase if possible.  Other chars remain untouched.
1014*e4b17023SJohn Marino        *
1015*e4b17023SJohn Marino        *  do_toupper() is a hook for a derived facet to change the behavior of
1016*e4b17023SJohn Marino        *  uppercasing.  do_toupper() must always return the same result for
1017*e4b17023SJohn Marino        *  the same input.
1018*e4b17023SJohn Marino        *
1019*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1020*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1021*e4b17023SJohn Marino        *  @return  @a __hi.
1022*e4b17023SJohn Marino       */
1023*e4b17023SJohn Marino       virtual const char_type*
1024*e4b17023SJohn Marino       do_toupper(char_type* __lo, const char_type* __hi) const;
1025*e4b17023SJohn Marino 
1026*e4b17023SJohn Marino       /**
1027*e4b17023SJohn Marino        *  @brief  Convert to lowercase.
1028*e4b17023SJohn Marino        *
1029*e4b17023SJohn Marino        *  This virtual function converts the char argument to lowercase if
1030*e4b17023SJohn Marino        *  possible.  If not possible (for example, '2'), returns the argument.
1031*e4b17023SJohn Marino        *
1032*e4b17023SJohn Marino        *  do_tolower() is a hook for a derived facet to change the behavior of
1033*e4b17023SJohn Marino        *  lowercasing.  do_tolower() must always return the same result for
1034*e4b17023SJohn Marino        *  the same input.
1035*e4b17023SJohn Marino        *
1036*e4b17023SJohn Marino        *  @param __c  The char to convert.
1037*e4b17023SJohn Marino        *  @return  The lowercase char if convertible, else @a __c.
1038*e4b17023SJohn Marino       */
1039*e4b17023SJohn Marino       virtual char_type
1040*e4b17023SJohn Marino       do_tolower(char_type __c) const;
1041*e4b17023SJohn Marino 
1042*e4b17023SJohn Marino       /**
1043*e4b17023SJohn Marino        *  @brief  Convert array to lowercase.
1044*e4b17023SJohn Marino        *
1045*e4b17023SJohn Marino        *  This virtual function converts each char in the range [lo,hi) to
1046*e4b17023SJohn Marino        *  lowercase if possible.  Other chars remain untouched.
1047*e4b17023SJohn Marino        *
1048*e4b17023SJohn Marino        *  do_tolower() is a hook for a derived facet to change the behavior of
1049*e4b17023SJohn Marino        *  lowercasing.  do_tolower() must always return the same result for
1050*e4b17023SJohn Marino        *  the same input.
1051*e4b17023SJohn Marino        *
1052*e4b17023SJohn Marino        *  @param __lo  Pointer to first char in range.
1053*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1054*e4b17023SJohn Marino        *  @return  @a __hi.
1055*e4b17023SJohn Marino       */
1056*e4b17023SJohn Marino       virtual const char_type*
1057*e4b17023SJohn Marino       do_tolower(char_type* __lo, const char_type* __hi) const;
1058*e4b17023SJohn Marino 
1059*e4b17023SJohn Marino       /**
1060*e4b17023SJohn Marino        *  @brief  Widen char
1061*e4b17023SJohn Marino        *
1062*e4b17023SJohn Marino        *  This virtual function converts the char to char using the simplest
1063*e4b17023SJohn Marino        *  reasonable transformation.  For an underived ctype<char> facet, the
1064*e4b17023SJohn Marino        *  argument will be returned unchanged.
1065*e4b17023SJohn Marino        *
1066*e4b17023SJohn Marino        *  do_widen() is a hook for a derived facet to change the behavior of
1067*e4b17023SJohn Marino        *  widening.  do_widen() must always return the same result for the
1068*e4b17023SJohn Marino        *  same input.
1069*e4b17023SJohn Marino        *
1070*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1071*e4b17023SJohn Marino        *  codecvt for that.
1072*e4b17023SJohn Marino        *
1073*e4b17023SJohn Marino        *  @param __c  The char to convert.
1074*e4b17023SJohn Marino        *  @return  The converted character.
1075*e4b17023SJohn Marino       */
1076*e4b17023SJohn Marino       virtual char_type
1077*e4b17023SJohn Marino       do_widen(char __c) const
1078*e4b17023SJohn Marino       { return __c; }
1079*e4b17023SJohn Marino 
1080*e4b17023SJohn Marino       /**
1081*e4b17023SJohn Marino        *  @brief  Widen char array
1082*e4b17023SJohn Marino        *
1083*e4b17023SJohn Marino        *  This function converts each char in the range [lo,hi) to char using
1084*e4b17023SJohn Marino        *  the simplest reasonable transformation.  For an underived
1085*e4b17023SJohn Marino        *  ctype<char> facet, the argument will be copied unchanged.
1086*e4b17023SJohn Marino        *
1087*e4b17023SJohn Marino        *  do_widen() is a hook for a derived facet to change the behavior of
1088*e4b17023SJohn Marino        *  widening.  do_widen() must always return the same result for the
1089*e4b17023SJohn Marino        *  same input.
1090*e4b17023SJohn Marino        *
1091*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1092*e4b17023SJohn Marino        *  codecvt for that.
1093*e4b17023SJohn Marino        *
1094*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1095*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1096*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
1097*e4b17023SJohn Marino        *  @return  @a __hi.
1098*e4b17023SJohn Marino       */
1099*e4b17023SJohn Marino       virtual const char*
1100*e4b17023SJohn Marino       do_widen(const char* __lo, const char* __hi, char_type* __to) const
1101*e4b17023SJohn Marino       {
1102*e4b17023SJohn Marino 	__builtin_memcpy(__to, __lo, __hi - __lo);
1103*e4b17023SJohn Marino 	return __hi;
1104*e4b17023SJohn Marino       }
1105*e4b17023SJohn Marino 
1106*e4b17023SJohn Marino       /**
1107*e4b17023SJohn Marino        *  @brief  Narrow char
1108*e4b17023SJohn Marino        *
1109*e4b17023SJohn Marino        *  This virtual function converts the char to char using the simplest
1110*e4b17023SJohn Marino        *  reasonable transformation.  If the conversion fails, dfault is
1111*e4b17023SJohn Marino        *  returned instead.  For an underived ctype<char> facet, @a c will be
1112*e4b17023SJohn Marino        *  returned unchanged.
1113*e4b17023SJohn Marino        *
1114*e4b17023SJohn Marino        *  do_narrow() is a hook for a derived facet to change the behavior of
1115*e4b17023SJohn Marino        *  narrowing.  do_narrow() must always return the same result for the
1116*e4b17023SJohn Marino        *  same input.
1117*e4b17023SJohn Marino        *
1118*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1119*e4b17023SJohn Marino        *  codecvt for that.
1120*e4b17023SJohn Marino        *
1121*e4b17023SJohn Marino        *  @param __c  The char to convert.
1122*e4b17023SJohn Marino        *  @param __dfault  Char to return if conversion fails.
1123*e4b17023SJohn Marino        *  @return  The converted char.
1124*e4b17023SJohn Marino       */
1125*e4b17023SJohn Marino       virtual char
1126*e4b17023SJohn Marino       do_narrow(char_type __c, char __dfault) const
1127*e4b17023SJohn Marino       { return __c; }
1128*e4b17023SJohn Marino 
1129*e4b17023SJohn Marino       /**
1130*e4b17023SJohn Marino        *  @brief  Narrow char array to char array
1131*e4b17023SJohn Marino        *
1132*e4b17023SJohn Marino        *  This virtual function converts each char in the range [lo,hi) to
1133*e4b17023SJohn Marino        *  char using the simplest reasonable transformation and writes the
1134*e4b17023SJohn Marino        *  results to the destination array.  For any char in the input that
1135*e4b17023SJohn Marino        *  cannot be converted, @a dfault is used instead.  For an underived
1136*e4b17023SJohn Marino        *  ctype<char> facet, the argument will be copied unchanged.
1137*e4b17023SJohn Marino        *
1138*e4b17023SJohn Marino        *  do_narrow() is a hook for a derived facet to change the behavior of
1139*e4b17023SJohn Marino        *  narrowing.  do_narrow() must always return the same result for the
1140*e4b17023SJohn Marino        *  same input.
1141*e4b17023SJohn Marino        *
1142*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1143*e4b17023SJohn Marino        *  codecvt for that.
1144*e4b17023SJohn Marino        *
1145*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1146*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1147*e4b17023SJohn Marino        *  @param __dfault  Char to use if conversion fails.
1148*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
1149*e4b17023SJohn Marino        *  @return  @a __hi.
1150*e4b17023SJohn Marino       */
1151*e4b17023SJohn Marino       virtual const char_type*
1152*e4b17023SJohn Marino       do_narrow(const char_type* __lo, const char_type* __hi,
1153*e4b17023SJohn Marino 		char __dfault, char* __to) const
1154*e4b17023SJohn Marino       {
1155*e4b17023SJohn Marino 	__builtin_memcpy(__to, __lo, __hi - __lo);
1156*e4b17023SJohn Marino 	return __hi;
1157*e4b17023SJohn Marino       }
1158*e4b17023SJohn Marino 
1159*e4b17023SJohn Marino     private:
1160*e4b17023SJohn Marino       void _M_narrow_init() const;
1161*e4b17023SJohn Marino       void _M_widen_init() const;
1162*e4b17023SJohn Marino     };
1163*e4b17023SJohn Marino 
1164*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
1165*e4b17023SJohn Marino   /**
1166*e4b17023SJohn Marino    *  @brief  The ctype<wchar_t> specialization.
1167*e4b17023SJohn Marino    *  @ingroup locales
1168*e4b17023SJohn Marino    *
1169*e4b17023SJohn Marino    *  This class defines classification and conversion functions for the
1170*e4b17023SJohn Marino    *  wchar_t type.  It gets used by wchar_t streams for many I/O operations.
1171*e4b17023SJohn Marino    *  The wchar_t specialization provides a number of optimizations as well.
1172*e4b17023SJohn Marino    *
1173*e4b17023SJohn Marino    *  ctype<wchar_t> inherits its public methods from
1174*e4b17023SJohn Marino    *  __ctype_abstract_base<wchar_t>.
1175*e4b17023SJohn Marino   */
1176*e4b17023SJohn Marino   template<>
1177*e4b17023SJohn Marino     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
1178*e4b17023SJohn Marino     {
1179*e4b17023SJohn Marino     public:
1180*e4b17023SJohn Marino       // Types:
1181*e4b17023SJohn Marino       /// Typedef for the template parameter wchar_t.
1182*e4b17023SJohn Marino       typedef wchar_t		char_type;
1183*e4b17023SJohn Marino       typedef wctype_t		__wmask_type;
1184*e4b17023SJohn Marino 
1185*e4b17023SJohn Marino     protected:
1186*e4b17023SJohn Marino       __c_locale		_M_c_locale_ctype;
1187*e4b17023SJohn Marino 
1188*e4b17023SJohn Marino       // Pre-computed narrowed and widened chars.
1189*e4b17023SJohn Marino       bool                      _M_narrow_ok;
1190*e4b17023SJohn Marino       char                      _M_narrow[128];
1191*e4b17023SJohn Marino       wint_t                    _M_widen[1 + static_cast<unsigned char>(-1)];
1192*e4b17023SJohn Marino 
1193*e4b17023SJohn Marino       // Pre-computed elements for do_is.
1194*e4b17023SJohn Marino       mask                      _M_bit[16];
1195*e4b17023SJohn Marino       __wmask_type              _M_wmask[16];
1196*e4b17023SJohn Marino 
1197*e4b17023SJohn Marino     public:
1198*e4b17023SJohn Marino       // Data Members:
1199*e4b17023SJohn Marino       /// The facet id for ctype<wchar_t>
1200*e4b17023SJohn Marino       static locale::id		id;
1201*e4b17023SJohn Marino 
1202*e4b17023SJohn Marino       /**
1203*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
1204*e4b17023SJohn Marino        *
1205*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
1206*e4b17023SJohn Marino        *
1207*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
1208*e4b17023SJohn Marino       */
1209*e4b17023SJohn Marino       explicit
1210*e4b17023SJohn Marino       ctype(size_t __refs = 0);
1211*e4b17023SJohn Marino 
1212*e4b17023SJohn Marino       /**
1213*e4b17023SJohn Marino        *  @brief  Constructor performs static initialization.
1214*e4b17023SJohn Marino        *
1215*e4b17023SJohn Marino        *  This constructor is used to construct the initial C locale facet.
1216*e4b17023SJohn Marino        *
1217*e4b17023SJohn Marino        *  @param __cloc  Handle to C locale data.
1218*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
1219*e4b17023SJohn Marino       */
1220*e4b17023SJohn Marino       explicit
1221*e4b17023SJohn Marino       ctype(__c_locale __cloc, size_t __refs = 0);
1222*e4b17023SJohn Marino 
1223*e4b17023SJohn Marino     protected:
1224*e4b17023SJohn Marino       __wmask_type
1225*e4b17023SJohn Marino       _M_convert_to_wmask(const mask __m) const throw();
1226*e4b17023SJohn Marino 
1227*e4b17023SJohn Marino       /// Destructor
1228*e4b17023SJohn Marino       virtual
1229*e4b17023SJohn Marino       ~ctype();
1230*e4b17023SJohn Marino 
1231*e4b17023SJohn Marino       /**
1232*e4b17023SJohn Marino        *  @brief  Test wchar_t classification.
1233*e4b17023SJohn Marino        *
1234*e4b17023SJohn Marino        *  This function finds a mask M for @a c and compares it to mask @a m.
1235*e4b17023SJohn Marino        *
1236*e4b17023SJohn Marino        *  do_is() is a hook for a derived facet to change the behavior of
1237*e4b17023SJohn Marino        *  classifying.  do_is() must always return the same result for the
1238*e4b17023SJohn Marino        *  same input.
1239*e4b17023SJohn Marino        *
1240*e4b17023SJohn Marino        *  @param __c  The wchar_t to find the mask of.
1241*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
1242*e4b17023SJohn Marino        *  @return  (M & __m) != 0.
1243*e4b17023SJohn Marino       */
1244*e4b17023SJohn Marino       virtual bool
1245*e4b17023SJohn Marino       do_is(mask __m, char_type __c) const;
1246*e4b17023SJohn Marino 
1247*e4b17023SJohn Marino       /**
1248*e4b17023SJohn Marino        *  @brief  Return a mask array.
1249*e4b17023SJohn Marino        *
1250*e4b17023SJohn Marino        *  This function finds the mask for each wchar_t in the range [lo,hi)
1251*e4b17023SJohn Marino        *  and successively writes it to vec.  vec must have as many elements
1252*e4b17023SJohn Marino        *  as the input.
1253*e4b17023SJohn Marino        *
1254*e4b17023SJohn Marino        *  do_is() is a hook for a derived facet to change the behavior of
1255*e4b17023SJohn Marino        *  classifying.  do_is() must always return the same result for the
1256*e4b17023SJohn Marino        *  same input.
1257*e4b17023SJohn Marino        *
1258*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1259*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1260*e4b17023SJohn Marino        *  @param __vec  Pointer to an array of mask storage.
1261*e4b17023SJohn Marino        *  @return  @a __hi.
1262*e4b17023SJohn Marino       */
1263*e4b17023SJohn Marino       virtual const char_type*
1264*e4b17023SJohn Marino       do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const;
1265*e4b17023SJohn Marino 
1266*e4b17023SJohn Marino       /**
1267*e4b17023SJohn Marino        *  @brief  Find wchar_t matching mask
1268*e4b17023SJohn Marino        *
1269*e4b17023SJohn Marino        *  This function searches for and returns the first wchar_t c in
1270*e4b17023SJohn Marino        *  [__lo,__hi) for which is(__m,c) is true.
1271*e4b17023SJohn Marino        *
1272*e4b17023SJohn Marino        *  do_scan_is() is a hook for a derived facet to change the behavior of
1273*e4b17023SJohn Marino        *  match searching.  do_is() must always return the same result for the
1274*e4b17023SJohn Marino        *  same input.
1275*e4b17023SJohn Marino        *
1276*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
1277*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1278*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1279*e4b17023SJohn Marino        *  @return  Pointer to a matching wchar_t if found, else @a __hi.
1280*e4b17023SJohn Marino       */
1281*e4b17023SJohn Marino       virtual const char_type*
1282*e4b17023SJohn Marino       do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const;
1283*e4b17023SJohn Marino 
1284*e4b17023SJohn Marino       /**
1285*e4b17023SJohn Marino        *  @brief  Find wchar_t not matching mask
1286*e4b17023SJohn Marino        *
1287*e4b17023SJohn Marino        *  This function searches for and returns a pointer to the first
1288*e4b17023SJohn Marino        *  wchar_t c of [__lo,__hi) for which is(__m,c) is false.
1289*e4b17023SJohn Marino        *
1290*e4b17023SJohn Marino        *  do_scan_is() is a hook for a derived facet to change the behavior of
1291*e4b17023SJohn Marino        *  match searching.  do_is() must always return the same result for the
1292*e4b17023SJohn Marino        *  same input.
1293*e4b17023SJohn Marino        *
1294*e4b17023SJohn Marino        *  @param __m  The mask to compare against.
1295*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1296*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1297*e4b17023SJohn Marino        *  @return  Pointer to a non-matching wchar_t if found, else @a __hi.
1298*e4b17023SJohn Marino       */
1299*e4b17023SJohn Marino       virtual const char_type*
1300*e4b17023SJohn Marino       do_scan_not(mask __m, const char_type* __lo,
1301*e4b17023SJohn Marino 		  const char_type* __hi) const;
1302*e4b17023SJohn Marino 
1303*e4b17023SJohn Marino       /**
1304*e4b17023SJohn Marino        *  @brief  Convert to uppercase.
1305*e4b17023SJohn Marino        *
1306*e4b17023SJohn Marino        *  This virtual function converts the wchar_t argument to uppercase if
1307*e4b17023SJohn Marino        *  possible.  If not possible (for example, '2'), returns the argument.
1308*e4b17023SJohn Marino        *
1309*e4b17023SJohn Marino        *  do_toupper() is a hook for a derived facet to change the behavior of
1310*e4b17023SJohn Marino        *  uppercasing.  do_toupper() must always return the same result for
1311*e4b17023SJohn Marino        *  the same input.
1312*e4b17023SJohn Marino        *
1313*e4b17023SJohn Marino        *  @param __c  The wchar_t to convert.
1314*e4b17023SJohn Marino        *  @return  The uppercase wchar_t if convertible, else @a __c.
1315*e4b17023SJohn Marino       */
1316*e4b17023SJohn Marino       virtual char_type
1317*e4b17023SJohn Marino       do_toupper(char_type __c) const;
1318*e4b17023SJohn Marino 
1319*e4b17023SJohn Marino       /**
1320*e4b17023SJohn Marino        *  @brief  Convert array to uppercase.
1321*e4b17023SJohn Marino        *
1322*e4b17023SJohn Marino        *  This virtual function converts each wchar_t in the range [lo,hi) to
1323*e4b17023SJohn Marino        *  uppercase if possible.  Other elements remain untouched.
1324*e4b17023SJohn Marino        *
1325*e4b17023SJohn Marino        *  do_toupper() is a hook for a derived facet to change the behavior of
1326*e4b17023SJohn Marino        *  uppercasing.  do_toupper() must always return the same result for
1327*e4b17023SJohn Marino        *  the same input.
1328*e4b17023SJohn Marino        *
1329*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1330*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1331*e4b17023SJohn Marino        *  @return  @a __hi.
1332*e4b17023SJohn Marino       */
1333*e4b17023SJohn Marino       virtual const char_type*
1334*e4b17023SJohn Marino       do_toupper(char_type* __lo, const char_type* __hi) const;
1335*e4b17023SJohn Marino 
1336*e4b17023SJohn Marino       /**
1337*e4b17023SJohn Marino        *  @brief  Convert to lowercase.
1338*e4b17023SJohn Marino        *
1339*e4b17023SJohn Marino        *  This virtual function converts the argument to lowercase if
1340*e4b17023SJohn Marino        *  possible.  If not possible (for example, '2'), returns the argument.
1341*e4b17023SJohn Marino        *
1342*e4b17023SJohn Marino        *  do_tolower() is a hook for a derived facet to change the behavior of
1343*e4b17023SJohn Marino        *  lowercasing.  do_tolower() must always return the same result for
1344*e4b17023SJohn Marino        *  the same input.
1345*e4b17023SJohn Marino        *
1346*e4b17023SJohn Marino        *  @param __c  The wchar_t to convert.
1347*e4b17023SJohn Marino        *  @return  The lowercase wchar_t if convertible, else @a __c.
1348*e4b17023SJohn Marino       */
1349*e4b17023SJohn Marino       virtual char_type
1350*e4b17023SJohn Marino       do_tolower(char_type __c) const;
1351*e4b17023SJohn Marino 
1352*e4b17023SJohn Marino       /**
1353*e4b17023SJohn Marino        *  @brief  Convert array to lowercase.
1354*e4b17023SJohn Marino        *
1355*e4b17023SJohn Marino        *  This virtual function converts each wchar_t in the range [lo,hi) to
1356*e4b17023SJohn Marino        *  lowercase if possible.  Other elements remain untouched.
1357*e4b17023SJohn Marino        *
1358*e4b17023SJohn Marino        *  do_tolower() is a hook for a derived facet to change the behavior of
1359*e4b17023SJohn Marino        *  lowercasing.  do_tolower() must always return the same result for
1360*e4b17023SJohn Marino        *  the same input.
1361*e4b17023SJohn Marino        *
1362*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1363*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1364*e4b17023SJohn Marino        *  @return  @a __hi.
1365*e4b17023SJohn Marino       */
1366*e4b17023SJohn Marino       virtual const char_type*
1367*e4b17023SJohn Marino       do_tolower(char_type* __lo, const char_type* __hi) const;
1368*e4b17023SJohn Marino 
1369*e4b17023SJohn Marino       /**
1370*e4b17023SJohn Marino        *  @brief  Widen char to wchar_t
1371*e4b17023SJohn Marino        *
1372*e4b17023SJohn Marino        *  This virtual function converts the char to wchar_t using the
1373*e4b17023SJohn Marino        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
1374*e4b17023SJohn Marino        *  facet, the argument will be cast to wchar_t.
1375*e4b17023SJohn Marino        *
1376*e4b17023SJohn Marino        *  do_widen() is a hook for a derived facet to change the behavior of
1377*e4b17023SJohn Marino        *  widening.  do_widen() must always return the same result for the
1378*e4b17023SJohn Marino        *  same input.
1379*e4b17023SJohn Marino        *
1380*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1381*e4b17023SJohn Marino        *  codecvt for that.
1382*e4b17023SJohn Marino        *
1383*e4b17023SJohn Marino        *  @param __c  The char to convert.
1384*e4b17023SJohn Marino        *  @return  The converted wchar_t.
1385*e4b17023SJohn Marino       */
1386*e4b17023SJohn Marino       virtual char_type
1387*e4b17023SJohn Marino       do_widen(char __c) const;
1388*e4b17023SJohn Marino 
1389*e4b17023SJohn Marino       /**
1390*e4b17023SJohn Marino        *  @brief  Widen char array to wchar_t array
1391*e4b17023SJohn Marino        *
1392*e4b17023SJohn Marino        *  This function converts each char in the input to wchar_t using the
1393*e4b17023SJohn Marino        *  simplest reasonable transformation.  For an underived ctype<wchar_t>
1394*e4b17023SJohn Marino        *  facet, the argument will be copied, casting each element to wchar_t.
1395*e4b17023SJohn Marino        *
1396*e4b17023SJohn Marino        *  do_widen() is a hook for a derived facet to change the behavior of
1397*e4b17023SJohn Marino        *  widening.  do_widen() must always return the same result for the
1398*e4b17023SJohn Marino        *  same input.
1399*e4b17023SJohn Marino        *
1400*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1401*e4b17023SJohn Marino        *  codecvt for that.
1402*e4b17023SJohn Marino        *
1403*e4b17023SJohn Marino        *  @param __lo  Pointer to start range.
1404*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1405*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
1406*e4b17023SJohn Marino        *  @return  @a __hi.
1407*e4b17023SJohn Marino       */
1408*e4b17023SJohn Marino       virtual const char*
1409*e4b17023SJohn Marino       do_widen(const char* __lo, const char* __hi, char_type* __to) const;
1410*e4b17023SJohn Marino 
1411*e4b17023SJohn Marino       /**
1412*e4b17023SJohn Marino        *  @brief  Narrow wchar_t to char
1413*e4b17023SJohn Marino        *
1414*e4b17023SJohn Marino        *  This virtual function converts the argument to char using
1415*e4b17023SJohn Marino        *  the simplest reasonable transformation.  If the conversion
1416*e4b17023SJohn Marino        *  fails, dfault is returned instead.  For an underived
1417*e4b17023SJohn Marino        *  ctype<wchar_t> facet, @a c will be cast to char and
1418*e4b17023SJohn Marino        *  returned.
1419*e4b17023SJohn Marino        *
1420*e4b17023SJohn Marino        *  do_narrow() is a hook for a derived facet to change the
1421*e4b17023SJohn Marino        *  behavior of narrowing.  do_narrow() must always return the
1422*e4b17023SJohn Marino        *  same result for the same input.
1423*e4b17023SJohn Marino        *
1424*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1425*e4b17023SJohn Marino        *  codecvt for that.
1426*e4b17023SJohn Marino        *
1427*e4b17023SJohn Marino        *  @param __c  The wchar_t to convert.
1428*e4b17023SJohn Marino        *  @param __dfault  Char to return if conversion fails.
1429*e4b17023SJohn Marino        *  @return  The converted char.
1430*e4b17023SJohn Marino       */
1431*e4b17023SJohn Marino       virtual char
1432*e4b17023SJohn Marino       do_narrow(char_type __c, char __dfault) const;
1433*e4b17023SJohn Marino 
1434*e4b17023SJohn Marino       /**
1435*e4b17023SJohn Marino        *  @brief  Narrow wchar_t array to char array
1436*e4b17023SJohn Marino        *
1437*e4b17023SJohn Marino        *  This virtual function converts each wchar_t in the range [lo,hi) to
1438*e4b17023SJohn Marino        *  char using the simplest reasonable transformation and writes the
1439*e4b17023SJohn Marino        *  results to the destination array.  For any wchar_t in the input that
1440*e4b17023SJohn Marino        *  cannot be converted, @a dfault is used instead.  For an underived
1441*e4b17023SJohn Marino        *  ctype<wchar_t> facet, the argument will be copied, casting each
1442*e4b17023SJohn Marino        *  element to char.
1443*e4b17023SJohn Marino        *
1444*e4b17023SJohn Marino        *  do_narrow() is a hook for a derived facet to change the behavior of
1445*e4b17023SJohn Marino        *  narrowing.  do_narrow() must always return the same result for the
1446*e4b17023SJohn Marino        *  same input.
1447*e4b17023SJohn Marino        *
1448*e4b17023SJohn Marino        *  Note: this is not what you want for codepage conversions.  See
1449*e4b17023SJohn Marino        *  codecvt for that.
1450*e4b17023SJohn Marino        *
1451*e4b17023SJohn Marino        *  @param __lo  Pointer to start of range.
1452*e4b17023SJohn Marino        *  @param __hi  Pointer to end of range.
1453*e4b17023SJohn Marino        *  @param __dfault  Char to use if conversion fails.
1454*e4b17023SJohn Marino        *  @param __to  Pointer to the destination array.
1455*e4b17023SJohn Marino        *  @return  @a __hi.
1456*e4b17023SJohn Marino       */
1457*e4b17023SJohn Marino       virtual const char_type*
1458*e4b17023SJohn Marino       do_narrow(const char_type* __lo, const char_type* __hi,
1459*e4b17023SJohn Marino 		char __dfault, char* __to) const;
1460*e4b17023SJohn Marino 
1461*e4b17023SJohn Marino       // For use at construction time only.
1462*e4b17023SJohn Marino       void
1463*e4b17023SJohn Marino       _M_initialize_ctype() throw();
1464*e4b17023SJohn Marino     };
1465*e4b17023SJohn Marino #endif //_GLIBCXX_USE_WCHAR_T
1466*e4b17023SJohn Marino 
1467*e4b17023SJohn Marino   /// class ctype_byname [22.2.1.2].
1468*e4b17023SJohn Marino   template<typename _CharT>
1469*e4b17023SJohn Marino     class ctype_byname : public ctype<_CharT>
1470*e4b17023SJohn Marino     {
1471*e4b17023SJohn Marino     public:
1472*e4b17023SJohn Marino       typedef typename ctype<_CharT>::mask  mask;
1473*e4b17023SJohn Marino 
1474*e4b17023SJohn Marino       explicit
1475*e4b17023SJohn Marino       ctype_byname(const char* __s, size_t __refs = 0);
1476*e4b17023SJohn Marino 
1477*e4b17023SJohn Marino     protected:
1478*e4b17023SJohn Marino       virtual
1479*e4b17023SJohn Marino       ~ctype_byname() { };
1480*e4b17023SJohn Marino     };
1481*e4b17023SJohn Marino 
1482*e4b17023SJohn Marino   /// 22.2.1.4  Class ctype_byname specializations.
1483*e4b17023SJohn Marino   template<>
1484*e4b17023SJohn Marino     class ctype_byname<char> : public ctype<char>
1485*e4b17023SJohn Marino     {
1486*e4b17023SJohn Marino     public:
1487*e4b17023SJohn Marino       explicit
1488*e4b17023SJohn Marino       ctype_byname(const char* __s, size_t __refs = 0);
1489*e4b17023SJohn Marino 
1490*e4b17023SJohn Marino     protected:
1491*e4b17023SJohn Marino       virtual
1492*e4b17023SJohn Marino       ~ctype_byname();
1493*e4b17023SJohn Marino     };
1494*e4b17023SJohn Marino 
1495*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
1496*e4b17023SJohn Marino   template<>
1497*e4b17023SJohn Marino     class ctype_byname<wchar_t> : public ctype<wchar_t>
1498*e4b17023SJohn Marino     {
1499*e4b17023SJohn Marino     public:
1500*e4b17023SJohn Marino       explicit
1501*e4b17023SJohn Marino       ctype_byname(const char* __s, size_t __refs = 0);
1502*e4b17023SJohn Marino 
1503*e4b17023SJohn Marino     protected:
1504*e4b17023SJohn Marino       virtual
1505*e4b17023SJohn Marino       ~ctype_byname();
1506*e4b17023SJohn Marino     };
1507*e4b17023SJohn Marino #endif
1508*e4b17023SJohn Marino 
1509*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION
1510*e4b17023SJohn Marino } // namespace
1511*e4b17023SJohn Marino 
1512*e4b17023SJohn Marino // Include host and configuration specific ctype inlines.
1513*e4b17023SJohn Marino #include <bits/ctype_inline.h>
1514*e4b17023SJohn Marino 
_GLIBCXX_VISIBILITY(default)1515*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
1516*e4b17023SJohn Marino {
1517*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION
1518*e4b17023SJohn Marino 
1519*e4b17023SJohn Marino   // 22.2.2  The numeric category.
1520*e4b17023SJohn Marino   class __num_base
1521*e4b17023SJohn Marino   {
1522*e4b17023SJohn Marino   public:
1523*e4b17023SJohn Marino     // NB: Code depends on the order of _S_atoms_out elements.
1524*e4b17023SJohn Marino     // Below are the indices into _S_atoms_out.
1525*e4b17023SJohn Marino     enum
1526*e4b17023SJohn Marino       {
1527*e4b17023SJohn Marino         _S_ominus,
1528*e4b17023SJohn Marino         _S_oplus,
1529*e4b17023SJohn Marino         _S_ox,
1530*e4b17023SJohn Marino         _S_oX,
1531*e4b17023SJohn Marino         _S_odigits,
1532*e4b17023SJohn Marino         _S_odigits_end = _S_odigits + 16,
1533*e4b17023SJohn Marino         _S_oudigits = _S_odigits_end,
1534*e4b17023SJohn Marino         _S_oudigits_end = _S_oudigits + 16,
1535*e4b17023SJohn Marino         _S_oe = _S_odigits + 14,  // For scientific notation, 'e'
1536*e4b17023SJohn Marino         _S_oE = _S_oudigits + 14, // For scientific notation, 'E'
1537*e4b17023SJohn Marino 	_S_oend = _S_oudigits_end
1538*e4b17023SJohn Marino       };
1539*e4b17023SJohn Marino 
1540*e4b17023SJohn Marino     // A list of valid numeric literals for output.  This array
1541*e4b17023SJohn Marino     // contains chars that will be passed through the current locale's
1542*e4b17023SJohn Marino     // ctype<_CharT>.widen() and then used to render numbers.
1543*e4b17023SJohn Marino     // For the standard "C" locale, this is
1544*e4b17023SJohn Marino     // "-+xX0123456789abcdef0123456789ABCDEF".
1545*e4b17023SJohn Marino     static const char* _S_atoms_out;
1546*e4b17023SJohn Marino 
1547*e4b17023SJohn Marino     // String literal of acceptable (narrow) input, for num_get.
1548*e4b17023SJohn Marino     // "-+xX0123456789abcdefABCDEF"
1549*e4b17023SJohn Marino     static const char* _S_atoms_in;
1550*e4b17023SJohn Marino 
1551*e4b17023SJohn Marino     enum
1552*e4b17023SJohn Marino     {
1553*e4b17023SJohn Marino       _S_iminus,
1554*e4b17023SJohn Marino       _S_iplus,
1555*e4b17023SJohn Marino       _S_ix,
1556*e4b17023SJohn Marino       _S_iX,
1557*e4b17023SJohn Marino       _S_izero,
1558*e4b17023SJohn Marino       _S_ie = _S_izero + 14,
1559*e4b17023SJohn Marino       _S_iE = _S_izero + 20,
1560*e4b17023SJohn Marino       _S_iend = 26
1561*e4b17023SJohn Marino     };
1562*e4b17023SJohn Marino 
1563*e4b17023SJohn Marino     // num_put
1564*e4b17023SJohn Marino     // Construct and return valid scanf format for floating point types.
1565*e4b17023SJohn Marino     static void
1566*e4b17023SJohn Marino     _S_format_float(const ios_base& __io, char* __fptr, char __mod) throw();
1567*e4b17023SJohn Marino   };
1568*e4b17023SJohn Marino 
1569*e4b17023SJohn Marino   template<typename _CharT>
1570*e4b17023SJohn Marino     struct __numpunct_cache : public locale::facet
1571*e4b17023SJohn Marino     {
1572*e4b17023SJohn Marino       const char*			_M_grouping;
1573*e4b17023SJohn Marino       size_t                            _M_grouping_size;
1574*e4b17023SJohn Marino       bool				_M_use_grouping;
1575*e4b17023SJohn Marino       const _CharT*			_M_truename;
1576*e4b17023SJohn Marino       size_t                            _M_truename_size;
1577*e4b17023SJohn Marino       const _CharT*			_M_falsename;
1578*e4b17023SJohn Marino       size_t                            _M_falsename_size;
1579*e4b17023SJohn Marino       _CharT				_M_decimal_point;
1580*e4b17023SJohn Marino       _CharT				_M_thousands_sep;
1581*e4b17023SJohn Marino 
1582*e4b17023SJohn Marino       // A list of valid numeric literals for output: in the standard
1583*e4b17023SJohn Marino       // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
1584*e4b17023SJohn Marino       // This array contains the chars after having been passed
1585*e4b17023SJohn Marino       // through the current locale's ctype<_CharT>.widen().
1586*e4b17023SJohn Marino       _CharT				_M_atoms_out[__num_base::_S_oend];
1587*e4b17023SJohn Marino 
1588*e4b17023SJohn Marino       // A list of valid numeric literals for input: in the standard
1589*e4b17023SJohn Marino       // "C" locale, this is "-+xX0123456789abcdefABCDEF"
1590*e4b17023SJohn Marino       // This array contains the chars after having been passed
1591*e4b17023SJohn Marino       // through the current locale's ctype<_CharT>.widen().
1592*e4b17023SJohn Marino       _CharT				_M_atoms_in[__num_base::_S_iend];
1593*e4b17023SJohn Marino 
1594*e4b17023SJohn Marino       bool				_M_allocated;
1595*e4b17023SJohn Marino 
1596*e4b17023SJohn Marino       __numpunct_cache(size_t __refs = 0)
1597*e4b17023SJohn Marino       : facet(__refs), _M_grouping(0), _M_grouping_size(0),
1598*e4b17023SJohn Marino 	_M_use_grouping(false),
1599*e4b17023SJohn Marino 	_M_truename(0), _M_truename_size(0), _M_falsename(0),
1600*e4b17023SJohn Marino 	_M_falsename_size(0), _M_decimal_point(_CharT()),
1601*e4b17023SJohn Marino 	_M_thousands_sep(_CharT()), _M_allocated(false)
1602*e4b17023SJohn Marino         { }
1603*e4b17023SJohn Marino 
1604*e4b17023SJohn Marino       ~__numpunct_cache();
1605*e4b17023SJohn Marino 
1606*e4b17023SJohn Marino       void
1607*e4b17023SJohn Marino       _M_cache(const locale& __loc);
1608*e4b17023SJohn Marino 
1609*e4b17023SJohn Marino     private:
1610*e4b17023SJohn Marino       __numpunct_cache&
1611*e4b17023SJohn Marino       operator=(const __numpunct_cache&);
1612*e4b17023SJohn Marino 
1613*e4b17023SJohn Marino       explicit
1614*e4b17023SJohn Marino       __numpunct_cache(const __numpunct_cache&);
1615*e4b17023SJohn Marino     };
1616*e4b17023SJohn Marino 
1617*e4b17023SJohn Marino   template<typename _CharT>
1618*e4b17023SJohn Marino     __numpunct_cache<_CharT>::~__numpunct_cache()
1619*e4b17023SJohn Marino     {
1620*e4b17023SJohn Marino       if (_M_allocated)
1621*e4b17023SJohn Marino 	{
1622*e4b17023SJohn Marino 	  delete [] _M_grouping;
1623*e4b17023SJohn Marino 	  delete [] _M_truename;
1624*e4b17023SJohn Marino 	  delete [] _M_falsename;
1625*e4b17023SJohn Marino 	}
1626*e4b17023SJohn Marino     }
1627*e4b17023SJohn Marino 
1628*e4b17023SJohn Marino   /**
1629*e4b17023SJohn Marino    *  @brief  Primary class template numpunct.
1630*e4b17023SJohn Marino    *  @ingroup locales
1631*e4b17023SJohn Marino    *
1632*e4b17023SJohn Marino    *  This facet stores several pieces of information related to printing and
1633*e4b17023SJohn Marino    *  scanning numbers, such as the decimal point character.  It takes a
1634*e4b17023SJohn Marino    *  template parameter specifying the char type.  The numpunct facet is
1635*e4b17023SJohn Marino    *  used by streams for many I/O operations involving numbers.
1636*e4b17023SJohn Marino    *
1637*e4b17023SJohn Marino    *  The numpunct template uses protected virtual functions to provide the
1638*e4b17023SJohn Marino    *  actual results.  The public accessors forward the call to the virtual
1639*e4b17023SJohn Marino    *  functions.  These virtual functions are hooks for developers to
1640*e4b17023SJohn Marino    *  implement the behavior they require from a numpunct facet.
1641*e4b17023SJohn Marino   */
1642*e4b17023SJohn Marino   template<typename _CharT>
1643*e4b17023SJohn Marino     class numpunct : public locale::facet
1644*e4b17023SJohn Marino     {
1645*e4b17023SJohn Marino     public:
1646*e4b17023SJohn Marino       // Types:
1647*e4b17023SJohn Marino       //@{
1648*e4b17023SJohn Marino       /// Public typedefs
1649*e4b17023SJohn Marino       typedef _CharT			char_type;
1650*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1651*e4b17023SJohn Marino       //@}
1652*e4b17023SJohn Marino       typedef __numpunct_cache<_CharT>  __cache_type;
1653*e4b17023SJohn Marino 
1654*e4b17023SJohn Marino     protected:
1655*e4b17023SJohn Marino       __cache_type*			_M_data;
1656*e4b17023SJohn Marino 
1657*e4b17023SJohn Marino     public:
1658*e4b17023SJohn Marino       /// Numpunct facet id.
1659*e4b17023SJohn Marino       static locale::id			id;
1660*e4b17023SJohn Marino 
1661*e4b17023SJohn Marino       /**
1662*e4b17023SJohn Marino        *  @brief  Numpunct constructor.
1663*e4b17023SJohn Marino        *
1664*e4b17023SJohn Marino        *  @param  __refs  Refcount to pass to the base class.
1665*e4b17023SJohn Marino        */
1666*e4b17023SJohn Marino       explicit
1667*e4b17023SJohn Marino       numpunct(size_t __refs = 0)
1668*e4b17023SJohn Marino       : facet(__refs), _M_data(0)
1669*e4b17023SJohn Marino       { _M_initialize_numpunct(); }
1670*e4b17023SJohn Marino 
1671*e4b17023SJohn Marino       /**
1672*e4b17023SJohn Marino        *  @brief  Internal constructor.  Not for general use.
1673*e4b17023SJohn Marino        *
1674*e4b17023SJohn Marino        *  This is a constructor for use by the library itself to set up the
1675*e4b17023SJohn Marino        *  predefined locale facets.
1676*e4b17023SJohn Marino        *
1677*e4b17023SJohn Marino        *  @param  __cache  __numpunct_cache object.
1678*e4b17023SJohn Marino        *  @param  __refs  Refcount to pass to the base class.
1679*e4b17023SJohn Marino        */
1680*e4b17023SJohn Marino       explicit
1681*e4b17023SJohn Marino       numpunct(__cache_type* __cache, size_t __refs = 0)
1682*e4b17023SJohn Marino       : facet(__refs), _M_data(__cache)
1683*e4b17023SJohn Marino       { _M_initialize_numpunct(); }
1684*e4b17023SJohn Marino 
1685*e4b17023SJohn Marino       /**
1686*e4b17023SJohn Marino        *  @brief  Internal constructor.  Not for general use.
1687*e4b17023SJohn Marino        *
1688*e4b17023SJohn Marino        *  This is a constructor for use by the library itself to set up new
1689*e4b17023SJohn Marino        *  locales.
1690*e4b17023SJohn Marino        *
1691*e4b17023SJohn Marino        *  @param  __cloc  The C locale.
1692*e4b17023SJohn Marino        *  @param  __refs  Refcount to pass to the base class.
1693*e4b17023SJohn Marino        */
1694*e4b17023SJohn Marino       explicit
1695*e4b17023SJohn Marino       numpunct(__c_locale __cloc, size_t __refs = 0)
1696*e4b17023SJohn Marino       : facet(__refs), _M_data(0)
1697*e4b17023SJohn Marino       { _M_initialize_numpunct(__cloc); }
1698*e4b17023SJohn Marino 
1699*e4b17023SJohn Marino       /**
1700*e4b17023SJohn Marino        *  @brief  Return decimal point character.
1701*e4b17023SJohn Marino        *
1702*e4b17023SJohn Marino        *  This function returns a char_type to use as a decimal point.  It
1703*e4b17023SJohn Marino        *  does so by returning returning
1704*e4b17023SJohn Marino        *  numpunct<char_type>::do_decimal_point().
1705*e4b17023SJohn Marino        *
1706*e4b17023SJohn Marino        *  @return  @a char_type representing a decimal point.
1707*e4b17023SJohn Marino       */
1708*e4b17023SJohn Marino       char_type
1709*e4b17023SJohn Marino       decimal_point() const
1710*e4b17023SJohn Marino       { return this->do_decimal_point(); }
1711*e4b17023SJohn Marino 
1712*e4b17023SJohn Marino       /**
1713*e4b17023SJohn Marino        *  @brief  Return thousands separator character.
1714*e4b17023SJohn Marino        *
1715*e4b17023SJohn Marino        *  This function returns a char_type to use as a thousands
1716*e4b17023SJohn Marino        *  separator.  It does so by returning returning
1717*e4b17023SJohn Marino        *  numpunct<char_type>::do_thousands_sep().
1718*e4b17023SJohn Marino        *
1719*e4b17023SJohn Marino        *  @return  char_type representing a thousands separator.
1720*e4b17023SJohn Marino       */
1721*e4b17023SJohn Marino       char_type
1722*e4b17023SJohn Marino       thousands_sep() const
1723*e4b17023SJohn Marino       { return this->do_thousands_sep(); }
1724*e4b17023SJohn Marino 
1725*e4b17023SJohn Marino       /**
1726*e4b17023SJohn Marino        *  @brief  Return grouping specification.
1727*e4b17023SJohn Marino        *
1728*e4b17023SJohn Marino        *  This function returns a string representing groupings for the
1729*e4b17023SJohn Marino        *  integer part of a number.  Groupings indicate where thousands
1730*e4b17023SJohn Marino        *  separators should be inserted in the integer part of a number.
1731*e4b17023SJohn Marino        *
1732*e4b17023SJohn Marino        *  Each char in the return string is interpret as an integer
1733*e4b17023SJohn Marino        *  rather than a character.  These numbers represent the number
1734*e4b17023SJohn Marino        *  of digits in a group.  The first char in the string
1735*e4b17023SJohn Marino        *  represents the number of digits in the least significant
1736*e4b17023SJohn Marino        *  group.  If a char is negative, it indicates an unlimited
1737*e4b17023SJohn Marino        *  number of digits for the group.  If more chars from the
1738*e4b17023SJohn Marino        *  string are required to group a number, the last char is used
1739*e4b17023SJohn Marino        *  repeatedly.
1740*e4b17023SJohn Marino        *
1741*e4b17023SJohn Marino        *  For example, if the grouping() returns "\003\002" and is
1742*e4b17023SJohn Marino        *  applied to the number 123456789, this corresponds to
1743*e4b17023SJohn Marino        *  12,34,56,789.  Note that if the string was "32", this would
1744*e4b17023SJohn Marino        *  put more than 50 digits into the least significant group if
1745*e4b17023SJohn Marino        *  the character set is ASCII.
1746*e4b17023SJohn Marino        *
1747*e4b17023SJohn Marino        *  The string is returned by calling
1748*e4b17023SJohn Marino        *  numpunct<char_type>::do_grouping().
1749*e4b17023SJohn Marino        *
1750*e4b17023SJohn Marino        *  @return  string representing grouping specification.
1751*e4b17023SJohn Marino       */
1752*e4b17023SJohn Marino       string
1753*e4b17023SJohn Marino       grouping() const
1754*e4b17023SJohn Marino       { return this->do_grouping(); }
1755*e4b17023SJohn Marino 
1756*e4b17023SJohn Marino       /**
1757*e4b17023SJohn Marino        *  @brief  Return string representation of bool true.
1758*e4b17023SJohn Marino        *
1759*e4b17023SJohn Marino        *  This function returns a string_type containing the text
1760*e4b17023SJohn Marino        *  representation for true bool variables.  It does so by calling
1761*e4b17023SJohn Marino        *  numpunct<char_type>::do_truename().
1762*e4b17023SJohn Marino        *
1763*e4b17023SJohn Marino        *  @return  string_type representing printed form of true.
1764*e4b17023SJohn Marino       */
1765*e4b17023SJohn Marino       string_type
1766*e4b17023SJohn Marino       truename() const
1767*e4b17023SJohn Marino       { return this->do_truename(); }
1768*e4b17023SJohn Marino 
1769*e4b17023SJohn Marino       /**
1770*e4b17023SJohn Marino        *  @brief  Return string representation of bool false.
1771*e4b17023SJohn Marino        *
1772*e4b17023SJohn Marino        *  This function returns a string_type containing the text
1773*e4b17023SJohn Marino        *  representation for false bool variables.  It does so by calling
1774*e4b17023SJohn Marino        *  numpunct<char_type>::do_falsename().
1775*e4b17023SJohn Marino        *
1776*e4b17023SJohn Marino        *  @return  string_type representing printed form of false.
1777*e4b17023SJohn Marino       */
1778*e4b17023SJohn Marino       string_type
1779*e4b17023SJohn Marino       falsename() const
1780*e4b17023SJohn Marino       { return this->do_falsename(); }
1781*e4b17023SJohn Marino 
1782*e4b17023SJohn Marino     protected:
1783*e4b17023SJohn Marino       /// Destructor.
1784*e4b17023SJohn Marino       virtual
1785*e4b17023SJohn Marino       ~numpunct();
1786*e4b17023SJohn Marino 
1787*e4b17023SJohn Marino       /**
1788*e4b17023SJohn Marino        *  @brief  Return decimal point character.
1789*e4b17023SJohn Marino        *
1790*e4b17023SJohn Marino        *  Returns a char_type to use as a decimal point.  This function is a
1791*e4b17023SJohn Marino        *  hook for derived classes to change the value returned.
1792*e4b17023SJohn Marino        *
1793*e4b17023SJohn Marino        *  @return  @a char_type representing a decimal point.
1794*e4b17023SJohn Marino       */
1795*e4b17023SJohn Marino       virtual char_type
1796*e4b17023SJohn Marino       do_decimal_point() const
1797*e4b17023SJohn Marino       { return _M_data->_M_decimal_point; }
1798*e4b17023SJohn Marino 
1799*e4b17023SJohn Marino       /**
1800*e4b17023SJohn Marino        *  @brief  Return thousands separator character.
1801*e4b17023SJohn Marino        *
1802*e4b17023SJohn Marino        *  Returns a char_type to use as a thousands separator.  This function
1803*e4b17023SJohn Marino        *  is a hook for derived classes to change the value returned.
1804*e4b17023SJohn Marino        *
1805*e4b17023SJohn Marino        *  @return  @a char_type representing a thousands separator.
1806*e4b17023SJohn Marino       */
1807*e4b17023SJohn Marino       virtual char_type
1808*e4b17023SJohn Marino       do_thousands_sep() const
1809*e4b17023SJohn Marino       { return _M_data->_M_thousands_sep; }
1810*e4b17023SJohn Marino 
1811*e4b17023SJohn Marino       /**
1812*e4b17023SJohn Marino        *  @brief  Return grouping specification.
1813*e4b17023SJohn Marino        *
1814*e4b17023SJohn Marino        *  Returns a string representing groupings for the integer part of a
1815*e4b17023SJohn Marino        *  number.  This function is a hook for derived classes to change the
1816*e4b17023SJohn Marino        *  value returned.  @see grouping() for details.
1817*e4b17023SJohn Marino        *
1818*e4b17023SJohn Marino        *  @return  String representing grouping specification.
1819*e4b17023SJohn Marino       */
1820*e4b17023SJohn Marino       virtual string
1821*e4b17023SJohn Marino       do_grouping() const
1822*e4b17023SJohn Marino       { return _M_data->_M_grouping; }
1823*e4b17023SJohn Marino 
1824*e4b17023SJohn Marino       /**
1825*e4b17023SJohn Marino        *  @brief  Return string representation of bool true.
1826*e4b17023SJohn Marino        *
1827*e4b17023SJohn Marino        *  Returns a string_type containing the text representation for true
1828*e4b17023SJohn Marino        *  bool variables.  This function is a hook for derived classes to
1829*e4b17023SJohn Marino        *  change the value returned.
1830*e4b17023SJohn Marino        *
1831*e4b17023SJohn Marino        *  @return  string_type representing printed form of true.
1832*e4b17023SJohn Marino       */
1833*e4b17023SJohn Marino       virtual string_type
1834*e4b17023SJohn Marino       do_truename() const
1835*e4b17023SJohn Marino       { return _M_data->_M_truename; }
1836*e4b17023SJohn Marino 
1837*e4b17023SJohn Marino       /**
1838*e4b17023SJohn Marino        *  @brief  Return string representation of bool false.
1839*e4b17023SJohn Marino        *
1840*e4b17023SJohn Marino        *  Returns a string_type containing the text representation for false
1841*e4b17023SJohn Marino        *  bool variables.  This function is a hook for derived classes to
1842*e4b17023SJohn Marino        *  change the value returned.
1843*e4b17023SJohn Marino        *
1844*e4b17023SJohn Marino        *  @return  string_type representing printed form of false.
1845*e4b17023SJohn Marino       */
1846*e4b17023SJohn Marino       virtual string_type
1847*e4b17023SJohn Marino       do_falsename() const
1848*e4b17023SJohn Marino       { return _M_data->_M_falsename; }
1849*e4b17023SJohn Marino 
1850*e4b17023SJohn Marino       // For use at construction time only.
1851*e4b17023SJohn Marino       void
1852*e4b17023SJohn Marino       _M_initialize_numpunct(__c_locale __cloc = 0);
1853*e4b17023SJohn Marino     };
1854*e4b17023SJohn Marino 
1855*e4b17023SJohn Marino   template<typename _CharT>
1856*e4b17023SJohn Marino     locale::id numpunct<_CharT>::id;
1857*e4b17023SJohn Marino 
1858*e4b17023SJohn Marino   template<>
1859*e4b17023SJohn Marino     numpunct<char>::~numpunct();
1860*e4b17023SJohn Marino 
1861*e4b17023SJohn Marino   template<>
1862*e4b17023SJohn Marino     void
1863*e4b17023SJohn Marino     numpunct<char>::_M_initialize_numpunct(__c_locale __cloc);
1864*e4b17023SJohn Marino 
1865*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_WCHAR_T
1866*e4b17023SJohn Marino   template<>
1867*e4b17023SJohn Marino     numpunct<wchar_t>::~numpunct();
1868*e4b17023SJohn Marino 
1869*e4b17023SJohn Marino   template<>
1870*e4b17023SJohn Marino     void
1871*e4b17023SJohn Marino     numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc);
1872*e4b17023SJohn Marino #endif
1873*e4b17023SJohn Marino 
1874*e4b17023SJohn Marino   /// class numpunct_byname [22.2.3.2].
1875*e4b17023SJohn Marino   template<typename _CharT>
1876*e4b17023SJohn Marino     class numpunct_byname : public numpunct<_CharT>
1877*e4b17023SJohn Marino     {
1878*e4b17023SJohn Marino     public:
1879*e4b17023SJohn Marino       typedef _CharT			char_type;
1880*e4b17023SJohn Marino       typedef basic_string<_CharT>	string_type;
1881*e4b17023SJohn Marino 
1882*e4b17023SJohn Marino       explicit
1883*e4b17023SJohn Marino       numpunct_byname(const char* __s, size_t __refs = 0)
1884*e4b17023SJohn Marino       : numpunct<_CharT>(__refs)
1885*e4b17023SJohn Marino       {
1886*e4b17023SJohn Marino 	if (__builtin_strcmp(__s, "C") != 0
1887*e4b17023SJohn Marino 	    && __builtin_strcmp(__s, "POSIX") != 0)
1888*e4b17023SJohn Marino 	  {
1889*e4b17023SJohn Marino 	    __c_locale __tmp;
1890*e4b17023SJohn Marino 	    this->_S_create_c_locale(__tmp, __s);
1891*e4b17023SJohn Marino 	    this->_M_initialize_numpunct(__tmp);
1892*e4b17023SJohn Marino 	    this->_S_destroy_c_locale(__tmp);
1893*e4b17023SJohn Marino 	  }
1894*e4b17023SJohn Marino       }
1895*e4b17023SJohn Marino 
1896*e4b17023SJohn Marino     protected:
1897*e4b17023SJohn Marino       virtual
1898*e4b17023SJohn Marino       ~numpunct_byname() { }
1899*e4b17023SJohn Marino     };
1900*e4b17023SJohn Marino 
1901*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_LDBL
1902*e4b17023SJohn Marino 
1903*e4b17023SJohn Marino   /**
1904*e4b17023SJohn Marino    *  @brief  Primary class template num_get.
1905*e4b17023SJohn Marino    *  @ingroup locales
1906*e4b17023SJohn Marino    *
1907*e4b17023SJohn Marino    *  This facet encapsulates the code to parse and return a number
1908*e4b17023SJohn Marino    *  from a string.  It is used by the istream numeric extraction
1909*e4b17023SJohn Marino    *  operators.
1910*e4b17023SJohn Marino    *
1911*e4b17023SJohn Marino    *  The num_get template uses protected virtual functions to provide the
1912*e4b17023SJohn Marino    *  actual results.  The public accessors forward the call to the virtual
1913*e4b17023SJohn Marino    *  functions.  These virtual functions are hooks for developers to
1914*e4b17023SJohn Marino    *  implement the behavior they require from the num_get facet.
1915*e4b17023SJohn Marino   */
1916*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
1917*e4b17023SJohn Marino     class num_get : public locale::facet
1918*e4b17023SJohn Marino     {
1919*e4b17023SJohn Marino     public:
1920*e4b17023SJohn Marino       // Types:
1921*e4b17023SJohn Marino       //@{
1922*e4b17023SJohn Marino       /// Public typedefs
1923*e4b17023SJohn Marino       typedef _CharT			char_type;
1924*e4b17023SJohn Marino       typedef _InIter			iter_type;
1925*e4b17023SJohn Marino       //@}
1926*e4b17023SJohn Marino 
1927*e4b17023SJohn Marino       /// Numpunct facet id.
1928*e4b17023SJohn Marino       static locale::id			id;
1929*e4b17023SJohn Marino 
1930*e4b17023SJohn Marino       /**
1931*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
1932*e4b17023SJohn Marino        *
1933*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
1934*e4b17023SJohn Marino        *
1935*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
1936*e4b17023SJohn Marino       */
1937*e4b17023SJohn Marino       explicit
1938*e4b17023SJohn Marino       num_get(size_t __refs = 0) : facet(__refs) { }
1939*e4b17023SJohn Marino 
1940*e4b17023SJohn Marino       /**
1941*e4b17023SJohn Marino        *  @brief  Numeric parsing.
1942*e4b17023SJohn Marino        *
1943*e4b17023SJohn Marino        *  Parses the input stream into the bool @a v.  It does so by calling
1944*e4b17023SJohn Marino        *  num_get::do_get().
1945*e4b17023SJohn Marino        *
1946*e4b17023SJohn Marino        *  If ios_base::boolalpha is set, attempts to read
1947*e4b17023SJohn Marino        *  ctype<CharT>::truename() or ctype<CharT>::falsename().  Sets
1948*e4b17023SJohn Marino        *  @a v to true or false if successful.  Sets err to
1949*e4b17023SJohn Marino        *  ios_base::failbit if reading the string fails.  Sets err to
1950*e4b17023SJohn Marino        *  ios_base::eofbit if the stream is emptied.
1951*e4b17023SJohn Marino        *
1952*e4b17023SJohn Marino        *  If ios_base::boolalpha is not set, proceeds as with reading a long,
1953*e4b17023SJohn Marino        *  except if the value is 1, sets @a v to true, if the value is 0, sets
1954*e4b17023SJohn Marino        *  @a v to false, and otherwise set err to ios_base::failbit.
1955*e4b17023SJohn Marino        *
1956*e4b17023SJohn Marino        *  @param  __in  Start of input stream.
1957*e4b17023SJohn Marino        *  @param  __end  End of input stream.
1958*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
1959*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
1960*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
1961*e4b17023SJohn Marino        *  @return  Iterator after reading.
1962*e4b17023SJohn Marino       */
1963*e4b17023SJohn Marino       iter_type
1964*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
1965*e4b17023SJohn Marino 	  ios_base::iostate& __err, bool& __v) const
1966*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
1967*e4b17023SJohn Marino 
1968*e4b17023SJohn Marino       //@{
1969*e4b17023SJohn Marino       /**
1970*e4b17023SJohn Marino        *  @brief  Numeric parsing.
1971*e4b17023SJohn Marino        *
1972*e4b17023SJohn Marino        *  Parses the input stream into the integral variable @a v.  It does so
1973*e4b17023SJohn Marino        *  by calling num_get::do_get().
1974*e4b17023SJohn Marino        *
1975*e4b17023SJohn Marino        *  Parsing is affected by the flag settings in @a io.
1976*e4b17023SJohn Marino        *
1977*e4b17023SJohn Marino        *  The basic parse is affected by the value of io.flags() &
1978*e4b17023SJohn Marino        *  ios_base::basefield.  If equal to ios_base::oct, parses like the
1979*e4b17023SJohn Marino        *  scanf %o specifier.  Else if equal to ios_base::hex, parses like %X
1980*e4b17023SJohn Marino        *  specifier.  Else if basefield equal to 0, parses like the %i
1981*e4b17023SJohn Marino        *  specifier.  Otherwise, parses like %d for signed and %u for unsigned
1982*e4b17023SJohn Marino        *  types.  The matching type length modifier is also used.
1983*e4b17023SJohn Marino        *
1984*e4b17023SJohn Marino        *  Digit grouping is interpreted according to numpunct::grouping() and
1985*e4b17023SJohn Marino        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
1986*e4b17023SJohn Marino        *  consistent, sets err to ios_base::failbit.
1987*e4b17023SJohn Marino        *
1988*e4b17023SJohn Marino        *  If parsing the string yields a valid value for @a v, @a v is set.
1989*e4b17023SJohn Marino        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
1990*e4b17023SJohn Marino        *  Sets err to ios_base::eofbit if the stream is emptied.
1991*e4b17023SJohn Marino        *
1992*e4b17023SJohn Marino        *  @param  __in  Start of input stream.
1993*e4b17023SJohn Marino        *  @param  __end  End of input stream.
1994*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
1995*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
1996*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
1997*e4b17023SJohn Marino        *  @return  Iterator after reading.
1998*e4b17023SJohn Marino       */
1999*e4b17023SJohn Marino       iter_type
2000*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2001*e4b17023SJohn Marino 	  ios_base::iostate& __err, long& __v) const
2002*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2003*e4b17023SJohn Marino 
2004*e4b17023SJohn Marino       iter_type
2005*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2006*e4b17023SJohn Marino 	  ios_base::iostate& __err, unsigned short& __v) const
2007*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2008*e4b17023SJohn Marino 
2009*e4b17023SJohn Marino       iter_type
2010*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2011*e4b17023SJohn Marino 	  ios_base::iostate& __err, unsigned int& __v)   const
2012*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2013*e4b17023SJohn Marino 
2014*e4b17023SJohn Marino       iter_type
2015*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2016*e4b17023SJohn Marino 	  ios_base::iostate& __err, unsigned long& __v)  const
2017*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2018*e4b17023SJohn Marino 
2019*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_LONG_LONG
2020*e4b17023SJohn Marino       iter_type
2021*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2022*e4b17023SJohn Marino 	  ios_base::iostate& __err, long long& __v) const
2023*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2024*e4b17023SJohn Marino 
2025*e4b17023SJohn Marino       iter_type
2026*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2027*e4b17023SJohn Marino 	  ios_base::iostate& __err, unsigned long long& __v)  const
2028*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2029*e4b17023SJohn Marino #endif
2030*e4b17023SJohn Marino       //@}
2031*e4b17023SJohn Marino 
2032*e4b17023SJohn Marino       //@{
2033*e4b17023SJohn Marino       /**
2034*e4b17023SJohn Marino        *  @brief  Numeric parsing.
2035*e4b17023SJohn Marino        *
2036*e4b17023SJohn Marino        *  Parses the input stream into the integral variable @a v.  It does so
2037*e4b17023SJohn Marino        *  by calling num_get::do_get().
2038*e4b17023SJohn Marino        *
2039*e4b17023SJohn Marino        *  The input characters are parsed like the scanf %g specifier.  The
2040*e4b17023SJohn Marino        *  matching type length modifier is also used.
2041*e4b17023SJohn Marino        *
2042*e4b17023SJohn Marino        *  The decimal point character used is numpunct::decimal_point().
2043*e4b17023SJohn Marino        *  Digit grouping is interpreted according to numpunct::grouping() and
2044*e4b17023SJohn Marino        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
2045*e4b17023SJohn Marino        *  consistent, sets err to ios_base::failbit.
2046*e4b17023SJohn Marino        *
2047*e4b17023SJohn Marino        *  If parsing the string yields a valid value for @a v, @a v is set.
2048*e4b17023SJohn Marino        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2049*e4b17023SJohn Marino        *  Sets err to ios_base::eofbit if the stream is emptied.
2050*e4b17023SJohn Marino        *
2051*e4b17023SJohn Marino        *  @param  __in  Start of input stream.
2052*e4b17023SJohn Marino        *  @param  __end  End of input stream.
2053*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2054*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
2055*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2056*e4b17023SJohn Marino        *  @return  Iterator after reading.
2057*e4b17023SJohn Marino       */
2058*e4b17023SJohn Marino       iter_type
2059*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2060*e4b17023SJohn Marino 	  ios_base::iostate& __err, float& __v) const
2061*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2062*e4b17023SJohn Marino 
2063*e4b17023SJohn Marino       iter_type
2064*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2065*e4b17023SJohn Marino 	  ios_base::iostate& __err, double& __v) const
2066*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2067*e4b17023SJohn Marino 
2068*e4b17023SJohn Marino       iter_type
2069*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2070*e4b17023SJohn Marino 	  ios_base::iostate& __err, long double& __v) const
2071*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2072*e4b17023SJohn Marino       //@}
2073*e4b17023SJohn Marino 
2074*e4b17023SJohn Marino       /**
2075*e4b17023SJohn Marino        *  @brief  Numeric parsing.
2076*e4b17023SJohn Marino        *
2077*e4b17023SJohn Marino        *  Parses the input stream into the pointer variable @a v.  It does so
2078*e4b17023SJohn Marino        *  by calling num_get::do_get().
2079*e4b17023SJohn Marino        *
2080*e4b17023SJohn Marino        *  The input characters are parsed like the scanf %p specifier.
2081*e4b17023SJohn Marino        *
2082*e4b17023SJohn Marino        *  Digit grouping is interpreted according to numpunct::grouping() and
2083*e4b17023SJohn Marino        *  numpunct::thousands_sep().  If the pattern of digit groups isn't
2084*e4b17023SJohn Marino        *  consistent, sets err to ios_base::failbit.
2085*e4b17023SJohn Marino        *
2086*e4b17023SJohn Marino        *  Note that the digit grouping effect for pointers is a bit ambiguous
2087*e4b17023SJohn Marino        *  in the standard and shouldn't be relied on.  See DR 344.
2088*e4b17023SJohn Marino        *
2089*e4b17023SJohn Marino        *  If parsing the string yields a valid value for @a v, @a v is set.
2090*e4b17023SJohn Marino        *  Otherwise, sets err to ios_base::failbit and leaves @a v unaltered.
2091*e4b17023SJohn Marino        *  Sets err to ios_base::eofbit if the stream is emptied.
2092*e4b17023SJohn Marino        *
2093*e4b17023SJohn Marino        *  @param  __in  Start of input stream.
2094*e4b17023SJohn Marino        *  @param  __end  End of input stream.
2095*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2096*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
2097*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2098*e4b17023SJohn Marino        *  @return  Iterator after reading.
2099*e4b17023SJohn Marino       */
2100*e4b17023SJohn Marino       iter_type
2101*e4b17023SJohn Marino       get(iter_type __in, iter_type __end, ios_base& __io,
2102*e4b17023SJohn Marino 	  ios_base::iostate& __err, void*& __v) const
2103*e4b17023SJohn Marino       { return this->do_get(__in, __end, __io, __err, __v); }
2104*e4b17023SJohn Marino 
2105*e4b17023SJohn Marino     protected:
2106*e4b17023SJohn Marino       /// Destructor.
2107*e4b17023SJohn Marino       virtual ~num_get() { }
2108*e4b17023SJohn Marino 
2109*e4b17023SJohn Marino       iter_type
2110*e4b17023SJohn Marino       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&,
2111*e4b17023SJohn Marino 		       string&) const;
2112*e4b17023SJohn Marino 
2113*e4b17023SJohn Marino       template<typename _ValueT>
2114*e4b17023SJohn Marino         iter_type
2115*e4b17023SJohn Marino         _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&,
2116*e4b17023SJohn Marino 		       _ValueT&) const;
2117*e4b17023SJohn Marino 
2118*e4b17023SJohn Marino       template<typename _CharT2>
2119*e4b17023SJohn Marino       typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type
2120*e4b17023SJohn Marino         _M_find(const _CharT2*, size_t __len, _CharT2 __c) const
2121*e4b17023SJohn Marino         {
2122*e4b17023SJohn Marino 	  int __ret = -1;
2123*e4b17023SJohn Marino 	  if (__len <= 10)
2124*e4b17023SJohn Marino 	    {
2125*e4b17023SJohn Marino 	      if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len))
2126*e4b17023SJohn Marino 		__ret = __c - _CharT2('0');
2127*e4b17023SJohn Marino 	    }
2128*e4b17023SJohn Marino 	  else
2129*e4b17023SJohn Marino 	    {
2130*e4b17023SJohn Marino 	      if (__c >= _CharT2('0') && __c <= _CharT2('9'))
2131*e4b17023SJohn Marino 		__ret = __c - _CharT2('0');
2132*e4b17023SJohn Marino 	      else if (__c >= _CharT2('a') && __c <= _CharT2('f'))
2133*e4b17023SJohn Marino 		__ret = 10 + (__c - _CharT2('a'));
2134*e4b17023SJohn Marino 	      else if (__c >= _CharT2('A') && __c <= _CharT2('F'))
2135*e4b17023SJohn Marino 		__ret = 10 + (__c - _CharT2('A'));
2136*e4b17023SJohn Marino 	    }
2137*e4b17023SJohn Marino 	  return __ret;
2138*e4b17023SJohn Marino 	}
2139*e4b17023SJohn Marino 
2140*e4b17023SJohn Marino       template<typename _CharT2>
2141*e4b17023SJohn Marino       typename __gnu_cxx::__enable_if<!__is_char<_CharT2>::__value,
2142*e4b17023SJohn Marino 				      int>::__type
2143*e4b17023SJohn Marino         _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const
2144*e4b17023SJohn Marino         {
2145*e4b17023SJohn Marino 	  int __ret = -1;
2146*e4b17023SJohn Marino 	  const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c);
2147*e4b17023SJohn Marino 	  if (__q)
2148*e4b17023SJohn Marino 	    {
2149*e4b17023SJohn Marino 	      __ret = __q - __zero;
2150*e4b17023SJohn Marino 	      if (__ret > 15)
2151*e4b17023SJohn Marino 		__ret -= 6;
2152*e4b17023SJohn Marino 	    }
2153*e4b17023SJohn Marino 	  return __ret;
2154*e4b17023SJohn Marino 	}
2155*e4b17023SJohn Marino 
2156*e4b17023SJohn Marino       //@{
2157*e4b17023SJohn Marino       /**
2158*e4b17023SJohn Marino        *  @brief  Numeric parsing.
2159*e4b17023SJohn Marino        *
2160*e4b17023SJohn Marino        *  Parses the input stream into the variable @a v.  This function is a
2161*e4b17023SJohn Marino        *  hook for derived classes to change the value returned.  @see get()
2162*e4b17023SJohn Marino        *  for more details.
2163*e4b17023SJohn Marino        *
2164*e4b17023SJohn Marino        *  @param  __beg  Start of input stream.
2165*e4b17023SJohn Marino        *  @param  __end  End of input stream.
2166*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2167*e4b17023SJohn Marino        *  @param  __err  Error flags to set.
2168*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2169*e4b17023SJohn Marino        *  @return  Iterator after reading.
2170*e4b17023SJohn Marino       */
2171*e4b17023SJohn Marino       virtual iter_type
2172*e4b17023SJohn Marino       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
2173*e4b17023SJohn Marino 
2174*e4b17023SJohn Marino       virtual iter_type
2175*e4b17023SJohn Marino       do_get(iter_type __beg, iter_type __end, ios_base& __io,
2176*e4b17023SJohn Marino 	     ios_base::iostate& __err, long& __v) const
2177*e4b17023SJohn Marino       { return _M_extract_int(__beg, __end, __io, __err, __v); }
2178*e4b17023SJohn Marino 
2179*e4b17023SJohn Marino       virtual iter_type
2180*e4b17023SJohn Marino       do_get(iter_type __beg, iter_type __end, ios_base& __io,
2181*e4b17023SJohn Marino 	     ios_base::iostate& __err, unsigned short& __v) const
2182*e4b17023SJohn Marino       { return _M_extract_int(__beg, __end, __io, __err, __v); }
2183*e4b17023SJohn Marino 
2184*e4b17023SJohn Marino       virtual iter_type
2185*e4b17023SJohn Marino       do_get(iter_type __beg, iter_type __end, ios_base& __io,
2186*e4b17023SJohn Marino 	     ios_base::iostate& __err, unsigned int& __v) const
2187*e4b17023SJohn Marino       { return _M_extract_int(__beg, __end, __io, __err, __v); }
2188*e4b17023SJohn Marino 
2189*e4b17023SJohn Marino       virtual iter_type
2190*e4b17023SJohn Marino       do_get(iter_type __beg, iter_type __end, ios_base& __io,
2191*e4b17023SJohn Marino 	     ios_base::iostate& __err, unsigned long& __v) const
2192*e4b17023SJohn Marino       { return _M_extract_int(__beg, __end, __io, __err, __v); }
2193*e4b17023SJohn Marino 
2194*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_LONG_LONG
2195*e4b17023SJohn Marino       virtual iter_type
2196*e4b17023SJohn Marino       do_get(iter_type __beg, iter_type __end, ios_base& __io,
2197*e4b17023SJohn Marino 	     ios_base::iostate& __err, long long& __v) const
2198*e4b17023SJohn Marino       { return _M_extract_int(__beg, __end, __io, __err, __v); }
2199*e4b17023SJohn Marino 
2200*e4b17023SJohn Marino       virtual iter_type
2201*e4b17023SJohn Marino       do_get(iter_type __beg, iter_type __end, ios_base& __io,
2202*e4b17023SJohn Marino 	     ios_base::iostate& __err, unsigned long long& __v) const
2203*e4b17023SJohn Marino       { return _M_extract_int(__beg, __end, __io, __err, __v); }
2204*e4b17023SJohn Marino #endif
2205*e4b17023SJohn Marino 
2206*e4b17023SJohn Marino       virtual iter_type
2207*e4b17023SJohn Marino       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, float&) const;
2208*e4b17023SJohn Marino 
2209*e4b17023SJohn Marino       virtual iter_type
2210*e4b17023SJohn Marino       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2211*e4b17023SJohn Marino 	     double&) const;
2212*e4b17023SJohn Marino 
2213*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
2214*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2215*e4b17023SJohn Marino       virtual iter_type
2216*e4b17023SJohn Marino       __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2217*e4b17023SJohn Marino 	       double&) const;
2218*e4b17023SJohn Marino #else
2219*e4b17023SJohn Marino       virtual iter_type
2220*e4b17023SJohn Marino       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2221*e4b17023SJohn Marino 	     long double&) const;
2222*e4b17023SJohn Marino #endif
2223*e4b17023SJohn Marino 
2224*e4b17023SJohn Marino       virtual iter_type
2225*e4b17023SJohn Marino       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, void*&) const;
2226*e4b17023SJohn Marino 
2227*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
2228*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2229*e4b17023SJohn Marino       virtual iter_type
2230*e4b17023SJohn Marino       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
2231*e4b17023SJohn Marino 	     long double&) const;
2232*e4b17023SJohn Marino #endif
2233*e4b17023SJohn Marino       //@}
2234*e4b17023SJohn Marino     };
2235*e4b17023SJohn Marino 
2236*e4b17023SJohn Marino   template<typename _CharT, typename _InIter>
2237*e4b17023SJohn Marino     locale::id num_get<_CharT, _InIter>::id;
2238*e4b17023SJohn Marino 
2239*e4b17023SJohn Marino 
2240*e4b17023SJohn Marino   /**
2241*e4b17023SJohn Marino    *  @brief  Primary class template num_put.
2242*e4b17023SJohn Marino    *  @ingroup locales
2243*e4b17023SJohn Marino    *
2244*e4b17023SJohn Marino    *  This facet encapsulates the code to convert a number to a string.  It is
2245*e4b17023SJohn Marino    *  used by the ostream numeric insertion operators.
2246*e4b17023SJohn Marino    *
2247*e4b17023SJohn Marino    *  The num_put template uses protected virtual functions to provide the
2248*e4b17023SJohn Marino    *  actual results.  The public accessors forward the call to the virtual
2249*e4b17023SJohn Marino    *  functions.  These virtual functions are hooks for developers to
2250*e4b17023SJohn Marino    *  implement the behavior they require from the num_put facet.
2251*e4b17023SJohn Marino   */
2252*e4b17023SJohn Marino   template<typename _CharT, typename _OutIter>
2253*e4b17023SJohn Marino     class num_put : public locale::facet
2254*e4b17023SJohn Marino     {
2255*e4b17023SJohn Marino     public:
2256*e4b17023SJohn Marino       // Types:
2257*e4b17023SJohn Marino       //@{
2258*e4b17023SJohn Marino       /// Public typedefs
2259*e4b17023SJohn Marino       typedef _CharT		char_type;
2260*e4b17023SJohn Marino       typedef _OutIter		iter_type;
2261*e4b17023SJohn Marino       //@}
2262*e4b17023SJohn Marino 
2263*e4b17023SJohn Marino       /// Numpunct facet id.
2264*e4b17023SJohn Marino       static locale::id		id;
2265*e4b17023SJohn Marino 
2266*e4b17023SJohn Marino       /**
2267*e4b17023SJohn Marino        *  @brief  Constructor performs initialization.
2268*e4b17023SJohn Marino        *
2269*e4b17023SJohn Marino        *  This is the constructor provided by the standard.
2270*e4b17023SJohn Marino        *
2271*e4b17023SJohn Marino        *  @param __refs  Passed to the base facet class.
2272*e4b17023SJohn Marino       */
2273*e4b17023SJohn Marino       explicit
2274*e4b17023SJohn Marino       num_put(size_t __refs = 0) : facet(__refs) { }
2275*e4b17023SJohn Marino 
2276*e4b17023SJohn Marino       /**
2277*e4b17023SJohn Marino        *  @brief  Numeric formatting.
2278*e4b17023SJohn Marino        *
2279*e4b17023SJohn Marino        *  Formats the boolean @a v and inserts it into a stream.  It does so
2280*e4b17023SJohn Marino        *  by calling num_put::do_put().
2281*e4b17023SJohn Marino        *
2282*e4b17023SJohn Marino        *  If ios_base::boolalpha is set, writes ctype<CharT>::truename() or
2283*e4b17023SJohn Marino        *  ctype<CharT>::falsename().  Otherwise formats @a v as an int.
2284*e4b17023SJohn Marino        *
2285*e4b17023SJohn Marino        *  @param  __s  Stream to write to.
2286*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2287*e4b17023SJohn Marino        *  @param  __fill  Char_type to use for filling.
2288*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2289*e4b17023SJohn Marino        *  @return  Iterator after writing.
2290*e4b17023SJohn Marino       */
2291*e4b17023SJohn Marino       iter_type
2292*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const
2293*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2294*e4b17023SJohn Marino 
2295*e4b17023SJohn Marino       //@{
2296*e4b17023SJohn Marino       /**
2297*e4b17023SJohn Marino        *  @brief  Numeric formatting.
2298*e4b17023SJohn Marino        *
2299*e4b17023SJohn Marino        *  Formats the integral value @a v and inserts it into a
2300*e4b17023SJohn Marino        *  stream.  It does so by calling num_put::do_put().
2301*e4b17023SJohn Marino        *
2302*e4b17023SJohn Marino        *  Formatting is affected by the flag settings in @a io.
2303*e4b17023SJohn Marino        *
2304*e4b17023SJohn Marino        *  The basic format is affected by the value of io.flags() &
2305*e4b17023SJohn Marino        *  ios_base::basefield.  If equal to ios_base::oct, formats like the
2306*e4b17023SJohn Marino        *  printf %o specifier.  Else if equal to ios_base::hex, formats like
2307*e4b17023SJohn Marino        *  %x or %X with ios_base::uppercase unset or set respectively.
2308*e4b17023SJohn Marino        *  Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu
2309*e4b17023SJohn Marino        *  for unsigned values.  Note that if both oct and hex are set, neither
2310*e4b17023SJohn Marino        *  will take effect.
2311*e4b17023SJohn Marino        *
2312*e4b17023SJohn Marino        *  If ios_base::showpos is set, '+' is output before positive values.
2313*e4b17023SJohn Marino        *  If ios_base::showbase is set, '0' precedes octal values (except 0)
2314*e4b17023SJohn Marino        *  and '0[xX]' precedes hex values.
2315*e4b17023SJohn Marino        *
2316*e4b17023SJohn Marino        *  Thousands separators are inserted according to numpunct::grouping()
2317*e4b17023SJohn Marino        *  and numpunct::thousands_sep().  The decimal point character used is
2318*e4b17023SJohn Marino        *  numpunct::decimal_point().
2319*e4b17023SJohn Marino        *
2320*e4b17023SJohn Marino        *  If io.width() is non-zero, enough @a fill characters are inserted to
2321*e4b17023SJohn Marino        *  make the result at least that wide.  If
2322*e4b17023SJohn Marino        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2323*e4b17023SJohn Marino        *  padded at the end.  If ios_base::internal, then padding occurs
2324*e4b17023SJohn Marino        *  immediately after either a '+' or '-' or after '0x' or '0X'.
2325*e4b17023SJohn Marino        *  Otherwise, padding occurs at the beginning.
2326*e4b17023SJohn Marino        *
2327*e4b17023SJohn Marino        *  @param  __s  Stream to write to.
2328*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2329*e4b17023SJohn Marino        *  @param  __fill  Char_type to use for filling.
2330*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2331*e4b17023SJohn Marino        *  @return  Iterator after writing.
2332*e4b17023SJohn Marino       */
2333*e4b17023SJohn Marino       iter_type
2334*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
2335*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2336*e4b17023SJohn Marino 
2337*e4b17023SJohn Marino       iter_type
2338*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill,
2339*e4b17023SJohn Marino 	  unsigned long __v) const
2340*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2341*e4b17023SJohn Marino 
2342*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_LONG_LONG
2343*e4b17023SJohn Marino       iter_type
2344*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const
2345*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2346*e4b17023SJohn Marino 
2347*e4b17023SJohn Marino       iter_type
2348*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill,
2349*e4b17023SJohn Marino 	  unsigned long long __v) const
2350*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2351*e4b17023SJohn Marino #endif
2352*e4b17023SJohn Marino       //@}
2353*e4b17023SJohn Marino 
2354*e4b17023SJohn Marino       //@{
2355*e4b17023SJohn Marino       /**
2356*e4b17023SJohn Marino        *  @brief  Numeric formatting.
2357*e4b17023SJohn Marino        *
2358*e4b17023SJohn Marino        *  Formats the floating point value @a v and inserts it into a stream.
2359*e4b17023SJohn Marino        *  It does so by calling num_put::do_put().
2360*e4b17023SJohn Marino        *
2361*e4b17023SJohn Marino        *  Formatting is affected by the flag settings in @a io.
2362*e4b17023SJohn Marino        *
2363*e4b17023SJohn Marino        *  The basic format is affected by the value of io.flags() &
2364*e4b17023SJohn Marino        *  ios_base::floatfield.  If equal to ios_base::fixed, formats like the
2365*e4b17023SJohn Marino        *  printf %f specifier.  Else if equal to ios_base::scientific, formats
2366*e4b17023SJohn Marino        *  like %e or %E with ios_base::uppercase unset or set respectively.
2367*e4b17023SJohn Marino        *  Otherwise, formats like %g or %G depending on uppercase.  Note that
2368*e4b17023SJohn Marino        *  if both fixed and scientific are set, the effect will also be like
2369*e4b17023SJohn Marino        *  %g or %G.
2370*e4b17023SJohn Marino        *
2371*e4b17023SJohn Marino        *  The output precision is given by io.precision().  This precision is
2372*e4b17023SJohn Marino        *  capped at numeric_limits::digits10 + 2 (different for double and
2373*e4b17023SJohn Marino        *  long double).  The default precision is 6.
2374*e4b17023SJohn Marino        *
2375*e4b17023SJohn Marino        *  If ios_base::showpos is set, '+' is output before positive values.
2376*e4b17023SJohn Marino        *  If ios_base::showpoint is set, a decimal point will always be
2377*e4b17023SJohn Marino        *  output.
2378*e4b17023SJohn Marino        *
2379*e4b17023SJohn Marino        *  Thousands separators are inserted according to numpunct::grouping()
2380*e4b17023SJohn Marino        *  and numpunct::thousands_sep().  The decimal point character used is
2381*e4b17023SJohn Marino        *  numpunct::decimal_point().
2382*e4b17023SJohn Marino        *
2383*e4b17023SJohn Marino        *  If io.width() is non-zero, enough @a fill characters are inserted to
2384*e4b17023SJohn Marino        *  make the result at least that wide.  If
2385*e4b17023SJohn Marino        *  (io.flags() & ios_base::adjustfield) == ios_base::left, result is
2386*e4b17023SJohn Marino        *  padded at the end.  If ios_base::internal, then padding occurs
2387*e4b17023SJohn Marino        *  immediately after either a '+' or '-' or after '0x' or '0X'.
2388*e4b17023SJohn Marino        *  Otherwise, padding occurs at the beginning.
2389*e4b17023SJohn Marino        *
2390*e4b17023SJohn Marino        *  @param  __s  Stream to write to.
2391*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2392*e4b17023SJohn Marino        *  @param  __fill  Char_type to use for filling.
2393*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2394*e4b17023SJohn Marino        *  @return  Iterator after writing.
2395*e4b17023SJohn Marino       */
2396*e4b17023SJohn Marino       iter_type
2397*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
2398*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2399*e4b17023SJohn Marino 
2400*e4b17023SJohn Marino       iter_type
2401*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill,
2402*e4b17023SJohn Marino 	  long double __v) const
2403*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2404*e4b17023SJohn Marino       //@}
2405*e4b17023SJohn Marino 
2406*e4b17023SJohn Marino       /**
2407*e4b17023SJohn Marino        *  @brief  Numeric formatting.
2408*e4b17023SJohn Marino        *
2409*e4b17023SJohn Marino        *  Formats the pointer value @a v and inserts it into a stream.  It
2410*e4b17023SJohn Marino        *  does so by calling num_put::do_put().
2411*e4b17023SJohn Marino        *
2412*e4b17023SJohn Marino        *  This function formats @a v as an unsigned long with ios_base::hex
2413*e4b17023SJohn Marino        *  and ios_base::showbase set.
2414*e4b17023SJohn Marino        *
2415*e4b17023SJohn Marino        *  @param  __s  Stream to write to.
2416*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2417*e4b17023SJohn Marino        *  @param  __fill  Char_type to use for filling.
2418*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2419*e4b17023SJohn Marino        *  @return  Iterator after writing.
2420*e4b17023SJohn Marino       */
2421*e4b17023SJohn Marino       iter_type
2422*e4b17023SJohn Marino       put(iter_type __s, ios_base& __io, char_type __fill,
2423*e4b17023SJohn Marino 	  const void* __v) const
2424*e4b17023SJohn Marino       { return this->do_put(__s, __io, __fill, __v); }
2425*e4b17023SJohn Marino 
2426*e4b17023SJohn Marino     protected:
2427*e4b17023SJohn Marino       template<typename _ValueT>
2428*e4b17023SJohn Marino         iter_type
2429*e4b17023SJohn Marino         _M_insert_float(iter_type, ios_base& __io, char_type __fill,
2430*e4b17023SJohn Marino 			char __mod, _ValueT __v) const;
2431*e4b17023SJohn Marino 
2432*e4b17023SJohn Marino       void
2433*e4b17023SJohn Marino       _M_group_float(const char* __grouping, size_t __grouping_size,
2434*e4b17023SJohn Marino 		     char_type __sep, const char_type* __p, char_type* __new,
2435*e4b17023SJohn Marino 		     char_type* __cs, int& __len) const;
2436*e4b17023SJohn Marino 
2437*e4b17023SJohn Marino       template<typename _ValueT>
2438*e4b17023SJohn Marino         iter_type
2439*e4b17023SJohn Marino         _M_insert_int(iter_type, ios_base& __io, char_type __fill,
2440*e4b17023SJohn Marino 		      _ValueT __v) const;
2441*e4b17023SJohn Marino 
2442*e4b17023SJohn Marino       void
2443*e4b17023SJohn Marino       _M_group_int(const char* __grouping, size_t __grouping_size,
2444*e4b17023SJohn Marino 		   char_type __sep, ios_base& __io, char_type* __new,
2445*e4b17023SJohn Marino 		   char_type* __cs, int& __len) const;
2446*e4b17023SJohn Marino 
2447*e4b17023SJohn Marino       void
2448*e4b17023SJohn Marino       _M_pad(char_type __fill, streamsize __w, ios_base& __io,
2449*e4b17023SJohn Marino 	     char_type* __new, const char_type* __cs, int& __len) const;
2450*e4b17023SJohn Marino 
2451*e4b17023SJohn Marino       /// Destructor.
2452*e4b17023SJohn Marino       virtual
2453*e4b17023SJohn Marino       ~num_put() { };
2454*e4b17023SJohn Marino 
2455*e4b17023SJohn Marino       //@{
2456*e4b17023SJohn Marino       /**
2457*e4b17023SJohn Marino        *  @brief  Numeric formatting.
2458*e4b17023SJohn Marino        *
2459*e4b17023SJohn Marino        *  These functions do the work of formatting numeric values and
2460*e4b17023SJohn Marino        *  inserting them into a stream. This function is a hook for derived
2461*e4b17023SJohn Marino        *  classes to change the value returned.
2462*e4b17023SJohn Marino        *
2463*e4b17023SJohn Marino        *  @param  __s  Stream to write to.
2464*e4b17023SJohn Marino        *  @param  __io  Source of locale and flags.
2465*e4b17023SJohn Marino        *  @param  __fill  Char_type to use for filling.
2466*e4b17023SJohn Marino        *  @param  __v  Value to format and insert.
2467*e4b17023SJohn Marino        *  @return  Iterator after writing.
2468*e4b17023SJohn Marino       */
2469*e4b17023SJohn Marino       virtual iter_type
2470*e4b17023SJohn Marino       do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const;
2471*e4b17023SJohn Marino 
2472*e4b17023SJohn Marino       virtual iter_type
2473*e4b17023SJohn Marino       do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
2474*e4b17023SJohn Marino       { return _M_insert_int(__s, __io, __fill, __v); }
2475*e4b17023SJohn Marino 
2476*e4b17023SJohn Marino       virtual iter_type
2477*e4b17023SJohn Marino       do_put(iter_type __s, ios_base& __io, char_type __fill,
2478*e4b17023SJohn Marino 	     unsigned long __v) const
2479*e4b17023SJohn Marino       { return _M_insert_int(__s, __io, __fill, __v); }
2480*e4b17023SJohn Marino 
2481*e4b17023SJohn Marino #ifdef _GLIBCXX_USE_LONG_LONG
2482*e4b17023SJohn Marino       virtual iter_type
2483*e4b17023SJohn Marino       do_put(iter_type __s, ios_base& __io, char_type __fill,
2484*e4b17023SJohn Marino 	     long long __v) const
2485*e4b17023SJohn Marino       { return _M_insert_int(__s, __io, __fill, __v); }
2486*e4b17023SJohn Marino 
2487*e4b17023SJohn Marino       virtual iter_type
2488*e4b17023SJohn Marino       do_put(iter_type __s, ios_base& __io, char_type __fill,
2489*e4b17023SJohn Marino 	     unsigned long long __v) const
2490*e4b17023SJohn Marino       { return _M_insert_int(__s, __io, __fill, __v); }
2491*e4b17023SJohn Marino #endif
2492*e4b17023SJohn Marino 
2493*e4b17023SJohn Marino       virtual iter_type
2494*e4b17023SJohn Marino       do_put(iter_type, ios_base&, char_type, double) const;
2495*e4b17023SJohn Marino 
2496*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
2497*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2498*e4b17023SJohn Marino       virtual iter_type
2499*e4b17023SJohn Marino       __do_put(iter_type, ios_base&, char_type, double) const;
2500*e4b17023SJohn Marino #else
2501*e4b17023SJohn Marino       virtual iter_type
2502*e4b17023SJohn Marino       do_put(iter_type, ios_base&, char_type, long double) const;
2503*e4b17023SJohn Marino #endif
2504*e4b17023SJohn Marino 
2505*e4b17023SJohn Marino       virtual iter_type
2506*e4b17023SJohn Marino       do_put(iter_type, ios_base&, char_type, const void*) const;
2507*e4b17023SJohn Marino 
2508*e4b17023SJohn Marino       // XXX GLIBCXX_ABI Deprecated
2509*e4b17023SJohn Marino #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
2510*e4b17023SJohn Marino       virtual iter_type
2511*e4b17023SJohn Marino       do_put(iter_type, ios_base&, char_type, long double) const;
2512*e4b17023SJohn Marino #endif
2513*e4b17023SJohn Marino       //@}
2514*e4b17023SJohn Marino     };
2515*e4b17023SJohn Marino 
2516*e4b17023SJohn Marino   template <typename _CharT, typename _OutIter>
2517*e4b17023SJohn Marino     locale::id num_put<_CharT, _OutIter>::id;
2518*e4b17023SJohn Marino 
2519*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_LDBL
2520*e4b17023SJohn Marino 
2521*e4b17023SJohn Marino   // Subclause convenience interfaces, inlines.
2522*e4b17023SJohn Marino   // NB: These are inline because, when used in a loop, some compilers
2523*e4b17023SJohn Marino   // can hoist the body out of the loop; then it's just as fast as the
2524*e4b17023SJohn Marino   // C is*() function.
2525*e4b17023SJohn Marino 
2526*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::space, __c).
2527*e4b17023SJohn Marino   template<typename _CharT>
2528*e4b17023SJohn Marino     inline bool
2529*e4b17023SJohn Marino     isspace(_CharT __c, const locale& __loc)
2530*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
2531*e4b17023SJohn Marino 
2532*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::print, __c).
2533*e4b17023SJohn Marino   template<typename _CharT>
2534*e4b17023SJohn Marino     inline bool
2535*e4b17023SJohn Marino     isprint(_CharT __c, const locale& __loc)
2536*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
2537*e4b17023SJohn Marino 
2538*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::cntrl, __c).
2539*e4b17023SJohn Marino   template<typename _CharT>
2540*e4b17023SJohn Marino     inline bool
2541*e4b17023SJohn Marino     iscntrl(_CharT __c, const locale& __loc)
2542*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
2543*e4b17023SJohn Marino 
2544*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::upper, __c).
2545*e4b17023SJohn Marino   template<typename _CharT>
2546*e4b17023SJohn Marino     inline bool
2547*e4b17023SJohn Marino     isupper(_CharT __c, const locale& __loc)
2548*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
2549*e4b17023SJohn Marino 
2550*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::lower, __c).
2551*e4b17023SJohn Marino   template<typename _CharT>
2552*e4b17023SJohn Marino     inline bool
2553*e4b17023SJohn Marino     islower(_CharT __c, const locale& __loc)
2554*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
2555*e4b17023SJohn Marino 
2556*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::alpha, __c).
2557*e4b17023SJohn Marino   template<typename _CharT>
2558*e4b17023SJohn Marino     inline bool
2559*e4b17023SJohn Marino     isalpha(_CharT __c, const locale& __loc)
2560*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
2561*e4b17023SJohn Marino 
2562*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::digit, __c).
2563*e4b17023SJohn Marino   template<typename _CharT>
2564*e4b17023SJohn Marino     inline bool
2565*e4b17023SJohn Marino     isdigit(_CharT __c, const locale& __loc)
2566*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
2567*e4b17023SJohn Marino 
2568*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::punct, __c).
2569*e4b17023SJohn Marino   template<typename _CharT>
2570*e4b17023SJohn Marino     inline bool
2571*e4b17023SJohn Marino     ispunct(_CharT __c, const locale& __loc)
2572*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
2573*e4b17023SJohn Marino 
2574*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::xdigit, __c).
2575*e4b17023SJohn Marino   template<typename _CharT>
2576*e4b17023SJohn Marino     inline bool
2577*e4b17023SJohn Marino     isxdigit(_CharT __c, const locale& __loc)
2578*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
2579*e4b17023SJohn Marino 
2580*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::alnum, __c).
2581*e4b17023SJohn Marino   template<typename _CharT>
2582*e4b17023SJohn Marino     inline bool
2583*e4b17023SJohn Marino     isalnum(_CharT __c, const locale& __loc)
2584*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
2585*e4b17023SJohn Marino 
2586*e4b17023SJohn Marino   /// Convenience interface to ctype.is(ctype_base::graph, __c).
2587*e4b17023SJohn Marino   template<typename _CharT>
2588*e4b17023SJohn Marino     inline bool
2589*e4b17023SJohn Marino     isgraph(_CharT __c, const locale& __loc)
2590*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
2591*e4b17023SJohn Marino 
2592*e4b17023SJohn Marino   /// Convenience interface to ctype.toupper(__c).
2593*e4b17023SJohn Marino   template<typename _CharT>
2594*e4b17023SJohn Marino     inline _CharT
2595*e4b17023SJohn Marino     toupper(_CharT __c, const locale& __loc)
2596*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
2597*e4b17023SJohn Marino 
2598*e4b17023SJohn Marino   /// Convenience interface to ctype.tolower(__c).
2599*e4b17023SJohn Marino   template<typename _CharT>
2600*e4b17023SJohn Marino     inline _CharT
2601*e4b17023SJohn Marino     tolower(_CharT __c, const locale& __loc)
2602*e4b17023SJohn Marino     { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
2603*e4b17023SJohn Marino 
2604*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION
2605*e4b17023SJohn Marino } // namespace std
2606*e4b17023SJohn Marino 
2607*e4b17023SJohn Marino # include <bits/locale_facets.tcc>
2608*e4b17023SJohn Marino 
2609*e4b17023SJohn Marino #endif
2610