libstdc++: locale_facets.h Source File

libstdc++

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