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