1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
32 // ISO C++ 14882: 22.1 Locales
35 /** @file locale_facets.h
36 * This is an internal header file, included by other library headers.
37 * You should not attempt to use it directly.
40 #ifndef _LOCALE_FACETS_H
41 #define _LOCALE_FACETS_H 1
43 #pragma GCC system_header
45 #include <ctime> // For struct tm
46 #include <cwctype> // For wctype_t
48 #include <bits/ios_base.h> // For ios_base, ios_base::iostate
53 // NB: Don't instantiate required wchar_t facets if no wchar_t support.
54 #ifdef _GLIBCXX_USE_WCHAR_T
55 # define _GLIBCXX_NUM_FACETS 28
57 # define _GLIBCXX_NUM_FACETS 14
60 // Convert string to numeric value of type _Tv and store results.
61 // NB: This is specialized for all required types, there is no
62 // generic definition.
63 template<typename _Tv
>
65 __convert_to_v(const char* __in
, _Tv
& __out
, ios_base::iostate
& __err
,
66 const __c_locale
& __cloc
);
68 // Explicit specializations for required types.
71 __convert_to_v(const char*, float&, ios_base::iostate
&,
76 __convert_to_v(const char*, double&, ios_base::iostate
&,
81 __convert_to_v(const char*, long double&, ios_base::iostate
&,
84 // NB: __pad is a struct, rather than a function, so it can be
85 // partially-specialized.
86 template<typename _CharT
, typename _Traits
>
90 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
91 const _CharT
* __olds
, const streamsize __newlen
,
92 const streamsize __oldlen
, const bool __num
);
95 // Used by both numeric and monetary facets.
96 // Check to make sure that the __grouping_tmp string constructed in
97 // money_get or num_get matches the canonical grouping for a given
99 // __grouping_tmp is parsed L to R
100 // 1,222,444 == __grouping_tmp of "\1\3\3"
101 // __grouping is parsed R to L
102 // 1,222,444 == __grouping of "\3" == "\3\3\3"
103 template<typename _CharT
>
105 __verify_grouping(const basic_string
<_CharT
>& __grouping
,
106 const basic_string
<_CharT
>& __grouping_tmp
);
108 // Used by both numeric and monetary facets.
109 // Inserts "group separator" characters into an array of characters.
110 // It's recursive, one iteration per group. It moves the characters
111 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
112 // only with __gbeg != __gend.
113 template<typename _CharT
>
115 __add_grouping(_CharT
* __s
, _CharT __sep
,
116 const char* __gbeg
, const char* __gend
,
117 const _CharT
* __first
, const _CharT
* __last
);
119 // This template permits specializing facet output code for
120 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
121 // significantly more efficient than incrementing iterators.
122 template<typename _CharT
>
124 ostreambuf_iterator
<_CharT
>
125 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
127 __s
._M_put(__ws
, __len
);
131 // This is the unspecialized form of the template.
132 template<typename _CharT
, typename _OutIter
>
135 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
137 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
143 // 22.2.1.1 Template class ctype
144 // Include host and configuration specific ctype enums for ctype_base.
145 #include <bits/ctype_base.h>
147 // Common base for ctype<_CharT>.
148 template<typename _CharT
>
149 class __ctype_abstract_base
: public locale::facet
, public ctype_base
153 typedef _CharT char_type
;
156 is(mask __m
, char_type __c
) const
157 { return this->do_is(__m
, __c
); }
160 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
161 { return this->do_is(__lo
, __hi
, __vec
); }
164 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
165 { return this->do_scan_is(__m
, __lo
, __hi
); }
168 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
169 { return this->do_scan_not(__m
, __lo
, __hi
); }
172 toupper(char_type __c
) const
173 { return this->do_toupper(__c
); }
176 toupper(char_type
*__lo
, const char_type
* __hi
) const
177 { return this->do_toupper(__lo
, __hi
); }
180 tolower(char_type __c
) const
181 { return this->do_tolower(__c
); }
184 tolower(char_type
* __lo
, const char_type
* __hi
) const
185 { return this->do_tolower(__lo
, __hi
); }
188 widen(char __c
) const
189 { return this->do_widen(__c
); }
192 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
193 { return this->do_widen(__lo
, __hi
, __to
); }
196 narrow(char_type __c
, char __dfault
) const
197 { return this->do_narrow(__c
, __dfault
); }
200 narrow(const char_type
* __lo
, const char_type
* __hi
,
201 char __dfault
, char *__to
) const
202 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
206 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
209 ~__ctype_abstract_base() { }
212 do_is(mask __m
, char_type __c
) const = 0;
214 virtual const char_type
*
215 do_is(const char_type
* __lo
, const char_type
* __hi
,
216 mask
* __vec
) const = 0;
218 virtual const char_type
*
219 do_scan_is(mask __m
, const char_type
* __lo
,
220 const char_type
* __hi
) const = 0;
222 virtual const char_type
*
223 do_scan_not(mask __m
, const char_type
* __lo
,
224 const char_type
* __hi
) const = 0;
227 do_toupper(char_type
) const = 0;
229 virtual const char_type
*
230 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
233 do_tolower(char_type
) const = 0;
235 virtual const char_type
*
236 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
239 do_widen(char) const = 0;
242 do_widen(const char* __lo
, const char* __hi
,
243 char_type
* __dest
) const = 0;
246 do_narrow(char_type
, char __dfault
) const = 0;
248 virtual const char_type
*
249 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
250 char __dfault
, char* __dest
) const = 0;
253 // NB: Generic, mostly useless implementation.
254 template<typename _CharT
>
255 class ctype
: public __ctype_abstract_base
<_CharT
>
259 typedef _CharT char_type
;
260 typedef typename
ctype::mask mask
;
262 static locale::id id
;
265 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
272 do_is(mask __m
, char_type __c
) const;
274 virtual const char_type
*
275 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
277 virtual const char_type
*
278 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
280 virtual const char_type
*
281 do_scan_not(mask __m
, const char_type
* __lo
,
282 const char_type
* __hi
) const;
285 do_toupper(char_type __c
) const;
287 virtual const char_type
*
288 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
291 do_tolower(char_type __c
) const;
293 virtual const char_type
*
294 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
297 do_widen(char __c
) const;
300 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
303 do_narrow(char_type
, char __dfault
) const;
305 virtual const char_type
*
306 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
307 char __dfault
, char* __dest
) const;
310 template<typename _CharT
>
311 locale::id ctype
<_CharT
>::id
;
313 // 22.2.1.3 ctype<char> specialization.
315 class ctype
<char> : public locale::facet
, public ctype_base
319 typedef char char_type
;
323 __c_locale _M_c_locale_ctype
;
325 __to_type _M_toupper
;
326 __to_type _M_tolower
;
327 const mask
* _M_table
;
330 static locale::id id
;
331 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
334 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
337 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
341 is(mask __m
, char __c
) const;
344 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
347 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
350 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
353 toupper(char_type __c
) const
354 { return this->do_toupper(__c
); }
357 toupper(char_type
*__lo
, const char_type
* __hi
) const
358 { return this->do_toupper(__lo
, __hi
); }
361 tolower(char_type __c
) const
362 { return this->do_tolower(__c
); }
365 tolower(char_type
* __lo
, const char_type
* __hi
) const
366 { return this->do_tolower(__lo
, __hi
); }
369 widen(char __c
) const
370 { return this->do_widen(__c
); }
373 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
374 { return this->do_widen(__lo
, __hi
, __to
); }
377 narrow(char_type __c
, char __dfault
) const
378 { return this->do_narrow(__c
, __dfault
); }
381 narrow(const char_type
* __lo
, const char_type
* __hi
,
382 char __dfault
, char *__to
) const
383 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
387 table() const throw()
391 classic_table() throw();
397 do_toupper(char_type
) const;
399 virtual const char_type
*
400 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
403 do_tolower(char_type
) const;
405 virtual const char_type
*
406 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
409 do_widen(char __c
) const
413 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const
415 memcpy(__dest
, __lo
, __hi
- __lo
);
420 do_narrow(char_type __c
, char) const
423 virtual const char_type
*
424 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
425 char, char* __dest
) const
427 memcpy(__dest
, __lo
, __hi
- __lo
);
434 use_facet
<ctype
<char> >(const locale
& __loc
);
436 #ifdef _GLIBCXX_USE_WCHAR_T
437 // 22.2.1.3 ctype<wchar_t> specialization
439 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
443 typedef wchar_t char_type
;
444 typedef wctype_t __wmask_type
;
447 __c_locale _M_c_locale_ctype
;
449 // Pre-computed narrowed and widened chars.
452 wint_t _M_widen
[1 + static_cast<unsigned char>(-1)];
456 static locale::id id
;
459 ctype(size_t __refs
= 0);
462 ctype(__c_locale __cloc
, size_t __refs
= 0);
466 _M_convert_to_wmask(const mask __m
) const;
472 do_is(mask __m
, char_type __c
) const;
474 virtual const char_type
*
475 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
477 virtual const char_type
*
478 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
480 virtual const char_type
*
481 do_scan_not(mask __m
, const char_type
* __lo
,
482 const char_type
* __hi
) const;
485 do_toupper(char_type
) const;
487 virtual const char_type
*
488 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
491 do_tolower(char_type
) const;
493 virtual const char_type
*
494 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
497 do_widen(char) const;
500 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
503 do_narrow(char_type
, char __dfault
) const;
505 virtual const char_type
*
506 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
507 char __dfault
, char* __dest
) const;
509 // For use at construction time only.
511 _M_initialize_ctype();
515 const ctype
<wchar_t>&
516 use_facet
<ctype
<wchar_t> >(const locale
& __loc
);
517 #endif //_GLIBCXX_USE_WCHAR_T
519 // Include host and configuration specific ctype inlines.
520 #include <bits/ctype_inline.h>
522 // 22.2.1.2 Template class ctype_byname
523 template<typename _CharT
>
524 class ctype_byname
: public ctype
<_CharT
>
527 typedef _CharT char_type
;
530 ctype_byname(const char* __s
, size_t __refs
= 0);
537 // 22.2.1.4 Class ctype_byname specializations.
539 ctype_byname
<char>::ctype_byname(const char*, size_t refs
);
542 ctype_byname
<wchar_t>::ctype_byname(const char*, size_t refs
);
544 // 22.2.1.5 Template class codecvt
545 #include <bits/codecvt.h>
547 // 22.2.2 The numeric category.
551 // NB: Code depends on the order of _S_atoms_out elements.
552 // Below are the indices into _S_atoms_out.
560 _S_odigits_end
= _S_odigits
+ 16,
561 _S_oudigits
= _S_odigits_end
,
562 _S_oudigits_end
= _S_oudigits
+ 16,
563 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
564 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
565 _S_oend
= _S_oudigits_end
568 // A list of valid numeric literals for output. This array
569 // contains chars that will be passed through the current locale's
570 // ctype<_CharT>.widen() and then used to render numbers.
571 // For the standard "C" locale, this is
572 // "-+xX0123456789abcdef0123456789ABCDEF".
573 static const char* _S_atoms_out
;
575 // String literal of acceptable (narrow) input, for num_get.
576 // "-+xX0123456789abcdefABCDEF"
577 static const char* _S_atoms_in
;
586 _S_ie
= _S_izero
+ 14,
587 _S_iE
= _S_izero
+ 20,
592 // Construct and return valid scanf format for floating point types.
594 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
);
597 template<typename _CharT
>
598 struct __numpunct_cache
: public locale::facet
600 const char* _M_grouping
;
601 bool _M_use_grouping
;
602 const _CharT
* _M_truename
;
603 const _CharT
* _M_falsename
;
604 _CharT _M_decimal_point
;
605 _CharT _M_thousands_sep
;
607 // A list of valid numeric literals for output: in the standard
608 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
609 // This array contains the chars after having been passed
610 // through the current locale's ctype<_CharT>.widen().
611 _CharT _M_atoms_out
[__num_base::_S_oend
+ 1];
613 // A list of valid numeric literals for input: in the standard
614 // "C" locale, this is "-+xX0123456789abcdefABCDEF"
615 // This array contains the chars after having been passed
616 // through the current locale's ctype<_CharT>.widen().
617 _CharT _M_atoms_in
[__num_base::_S_iend
+ 1];
621 __numpunct_cache(size_t __refs
= 0) : facet(__refs
),
622 _M_grouping(NULL
), _M_use_grouping(false), _M_truename(NULL
),
623 _M_falsename(NULL
), _M_decimal_point(_CharT()),
624 _M_thousands_sep(_CharT()), _M_allocated(false)
630 _M_cache(const locale
& __loc
);
633 template<typename _CharT
>
635 __numpunct_cache
<_CharT
>::_M_cache(const locale
& __loc
)
639 const numpunct
<_CharT
>& __np
= use_facet
<numpunct
<_CharT
> >(__loc
);
641 const string::size_type __len
= __np
.grouping().size();
642 char* __grouping
= new char[__len
+ 1];
643 __np
.grouping().copy(__grouping
, __len
);
644 __grouping
[__len
] = char();
645 _M_grouping
= __grouping
;
646 _M_use_grouping
= __len
&& __np
.grouping()[0] != 0;
648 typedef basic_string
<_CharT
> __string_type
;
649 typename
__string_type::size_type __lentf
= __np
.truename().size();
650 _CharT
* __truename
= new _CharT
[__lentf
+ 1];
651 __np
.truename().copy(__truename
, __lentf
);
652 __truename
[__lentf
] = _CharT();
653 _M_truename
= __truename
;
655 __lentf
= __np
.falsename().size();
656 _CharT
* __falsename
= new _CharT
[__lentf
+ 1];
657 __np
.falsename().copy(__falsename
, __lentf
);
658 __falsename
[__lentf
] = _CharT();
659 _M_falsename
= __falsename
;
661 _M_decimal_point
= __np
.decimal_point();
662 _M_thousands_sep
= __np
.thousands_sep();
664 const ctype
<_CharT
>& __ct
= use_facet
<ctype
<_CharT
> >(__loc
);
665 __ct
.widen(__num_base::_S_atoms_out
,
666 __num_base::_S_atoms_out
+ __num_base::_S_oend
, _M_atoms_out
);
667 _M_atoms_out
[__num_base::_S_oend
] = _CharT();
668 __ct
.widen(__num_base::_S_atoms_in
,
669 __num_base::_S_atoms_in
+ __num_base::_S_iend
, _M_atoms_in
);
670 _M_atoms_in
[__num_base::_S_iend
] = _CharT();
673 template<typename _CharT
>
674 __numpunct_cache
<_CharT
>::~__numpunct_cache()
678 delete [] _M_grouping
;
679 delete [] _M_truename
;
680 delete [] _M_falsename
;
684 template<typename _CharT
>
685 class numpunct
: public locale::facet
689 typedef _CharT char_type
;
690 typedef basic_string
<_CharT
> string_type
;
691 typedef __numpunct_cache
<_CharT
> __cache_type
;
694 __cache_type
* _M_data
;
697 static locale::id id
;
700 numpunct(size_t __refs
= 0) : facet(__refs
), _M_data(NULL
)
701 { _M_initialize_numpunct(); }
704 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
705 : facet(__refs
), _M_data(__cache
)
706 { _M_initialize_numpunct(); }
709 numpunct(__c_locale __cloc
, size_t __refs
= 0)
710 : facet(__refs
), _M_data(NULL
)
711 { _M_initialize_numpunct(__cloc
); }
714 decimal_point() const
715 { return this->do_decimal_point(); }
718 thousands_sep() const
719 { return this->do_thousands_sep(); }
723 { return this->do_grouping(); }
727 { return this->do_truename(); }
731 { return this->do_falsename(); }
738 do_decimal_point() const
739 { return _M_data
->_M_decimal_point
; }
742 do_thousands_sep() const
743 { return _M_data
->_M_thousands_sep
; }
747 { return _M_data
->_M_grouping
; }
751 { return _M_data
->_M_truename
; }
755 { return _M_data
->_M_falsename
; }
757 // For use at construction time only.
759 _M_initialize_numpunct(__c_locale __cloc
= NULL
);
762 template<typename _CharT
>
763 locale::id numpunct
<_CharT
>::id
;
766 numpunct
<char>::~numpunct();
770 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
772 #ifdef _GLIBCXX_USE_WCHAR_T
774 numpunct
<wchar_t>::~numpunct();
778 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
781 template<typename _CharT
>
782 class numpunct_byname
: public numpunct
<_CharT
>
785 typedef _CharT char_type
;
786 typedef basic_string
<_CharT
> string_type
;
789 numpunct_byname(const char* __s
, size_t __refs
= 0)
790 : numpunct
<_CharT
>(__refs
)
792 if (std::strcmp(__s
, "C") != 0 && std::strcmp(__s
, "POSIX") != 0)
795 this->_S_create_c_locale(__tmp
, __s
);
796 this->_M_initialize_numpunct(__tmp
);
797 this->_S_destroy_c_locale(__tmp
);
803 ~numpunct_byname() { }
806 template<typename _CharT
, typename _InIter
>
807 class num_get
: public locale::facet
, public __num_base
811 typedef _CharT char_type
;
812 typedef _InIter iter_type
;
814 static locale::id id
;
817 num_get(size_t __refs
= 0) : facet(__refs
) { }
820 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
821 ios_base::iostate
& __err
, bool& __v
) const
822 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
825 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
826 ios_base::iostate
& __err
, long& __v
) const
827 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
830 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
831 ios_base::iostate
& __err
, unsigned short& __v
) const
832 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
835 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
836 ios_base::iostate
& __err
, unsigned int& __v
) const
837 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
840 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
841 ios_base::iostate
& __err
, unsigned long& __v
) const
842 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
844 #ifdef _GLIBCXX_USE_LONG_LONG
846 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
847 ios_base::iostate
& __err
, long long& __v
) const
848 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
851 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
852 ios_base::iostate
& __err
, unsigned long long& __v
) const
853 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
857 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
858 ios_base::iostate
& __err
, float& __v
) const
859 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
862 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
863 ios_base::iostate
& __err
, double& __v
) const
864 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
867 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
868 ios_base::iostate
& __err
, long double& __v
) const
869 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
872 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
873 ios_base::iostate
& __err
, void*& __v
) const
874 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
877 virtual ~num_get() { }
880 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
881 string
& __xtrc
) const;
883 template<typename _ValueT
>
885 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
889 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
893 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, long&) const;
896 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
897 unsigned short&) const;
900 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
901 unsigned int&) const;
904 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
905 unsigned long&) const;
907 #ifdef _GLIBCXX_USE_LONG_LONG
909 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
913 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
914 unsigned long long&) const;
918 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
922 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
926 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
930 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
934 template<typename _CharT
, typename _InIter
>
935 locale::id num_get
<_CharT
, _InIter
>::id
;
938 template<typename _CharT
, typename _OutIter
>
939 class num_put
: public locale::facet
, public __num_base
943 typedef _CharT char_type
;
944 typedef _OutIter iter_type
;
945 static locale::id id
;
948 num_put(size_t __refs
= 0) : facet(__refs
) { }
951 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
952 { return this->do_put(__s
, __f
, __fill
, __v
); }
955 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
956 { return this->do_put(__s
, __f
, __fill
, __v
); }
959 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
960 unsigned long __v
) const
961 { return this->do_put(__s
, __f
, __fill
, __v
); }
963 #ifdef _GLIBCXX_USE_LONG_LONG
965 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
966 { return this->do_put(__s
, __f
, __fill
, __v
); }
969 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
970 unsigned long long __v
) const
971 { return this->do_put(__s
, __f
, __fill
, __v
); }
975 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
976 { return this->do_put(__s
, __f
, __fill
, __v
); }
979 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
980 long double __v
) const
981 { return this->do_put(__s
, __f
, __fill
, __v
); }
984 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
985 const void* __v
) const
986 { return this->do_put(__s
, __f
, __fill
, __v
); }
989 template<typename _ValueT
>
991 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
992 char __mod
, _ValueT __v
) const;
995 _M_group_float(const string
& __grouping
, char_type __sep
,
996 const char_type
* __p
, char_type
* __new
, char_type
* __cs
,
999 template<typename _ValueT
>
1001 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
1005 _M_group_int(const string
& __grouping
, char_type __sep
,
1006 ios_base
& __io
, char_type
* __new
, char_type
* __cs
,
1010 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
1011 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
1017 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
1020 do_put(iter_type
, ios_base
&, char_type __fill
, long __v
) const;
1023 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long) const;
1025 #ifdef _GLIBCXX_USE_LONG_LONG
1027 do_put(iter_type
, ios_base
&, char_type __fill
, long long __v
) const;
1030 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long long) const;
1034 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
1037 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
1040 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
1043 template <typename _CharT
, typename _OutIter
>
1044 locale::id num_put
<_CharT
, _OutIter
>::id
;
1047 template<typename _CharT
>
1048 class collate
: public locale::facet
1052 typedef _CharT char_type
;
1053 typedef basic_string
<_CharT
> string_type
;
1056 // Underlying "C" library locale information saved from
1057 // initialization, needed by collate_byname as well.
1058 __c_locale _M_c_locale_collate
;
1061 static locale::id id
;
1064 collate(size_t __refs
= 0)
1066 { _M_c_locale_collate
= _S_get_c_locale(); }
1069 collate(__c_locale __cloc
, size_t __refs
= 0)
1071 { _M_c_locale_collate
= _S_clone_c_locale(__cloc
); }
1074 compare(const _CharT
* __lo1
, const _CharT
* __hi1
,
1075 const _CharT
* __lo2
, const _CharT
* __hi2
) const
1076 { return this->do_compare(__lo1
, __hi1
, __lo2
, __hi2
); }
1079 transform(const _CharT
* __lo
, const _CharT
* __hi
) const
1080 { return this->do_transform(__lo
, __hi
); }
1083 hash(const _CharT
* __lo
, const _CharT
* __hi
) const
1084 { return this->do_hash(__lo
, __hi
); }
1086 // Used to abstract out _CharT bits in virtual member functions, below.
1088 _M_compare(const _CharT
*, const _CharT
*) const;
1091 _M_transform(_CharT
*, const _CharT
*, size_t) const;
1096 { _S_destroy_c_locale(_M_c_locale_collate
); }
1099 do_compare(const _CharT
* __lo1
, const _CharT
* __hi1
,
1100 const _CharT
* __lo2
, const _CharT
* __hi2
) const;
1103 do_transform(const _CharT
* __lo
, const _CharT
* __hi
) const;
1106 do_hash(const _CharT
* __lo
, const _CharT
* __hi
) const;
1109 template<typename _CharT
>
1110 locale::id collate
<_CharT
>::id
;
1115 collate
<char>::_M_compare(const char*, const char*) const;
1119 collate
<char>::_M_transform(char*, const char*, size_t) const;
1121 #ifdef _GLIBCXX_USE_WCHAR_T
1124 collate
<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
1128 collate
<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
1131 template<typename _CharT
>
1132 class collate_byname
: public collate
<_CharT
>
1135 typedef _CharT char_type
;
1136 typedef basic_string
<_CharT
> string_type
;
1139 collate_byname(const char* __s
, size_t __refs
= 0)
1140 : collate
<_CharT
>(__refs
)
1142 if (std::strcmp(__s
, "C") != 0 && std::strcmp(__s
, "POSIX") != 0)
1144 this->_S_destroy_c_locale(this->_M_c_locale_collate
);
1145 this->_S_create_c_locale(this->_M_c_locale_collate
, __s
);
1151 ~collate_byname() { }
1158 enum dateorder
{ no_order
, dmy
, mdy
, ymd
, ydm
};
1161 template<typename _CharT
>
1162 struct __timepunct_cache
: public locale::facet
1164 // List of all known timezones, with GMT first.
1165 static const _CharT
* _S_timezones
[14];
1167 const _CharT
* _M_date_format
;
1168 const _CharT
* _M_date_era_format
;
1169 const _CharT
* _M_time_format
;
1170 const _CharT
* _M_time_era_format
;
1171 const _CharT
* _M_date_time_format
;
1172 const _CharT
* _M_date_time_era_format
;
1173 const _CharT
* _M_am
;
1174 const _CharT
* _M_pm
;
1175 const _CharT
* _M_am_pm_format
;
1177 // Day names, starting with "C"'s Sunday.
1178 const _CharT
* _M_day1
;
1179 const _CharT
* _M_day2
;
1180 const _CharT
* _M_day3
;
1181 const _CharT
* _M_day4
;
1182 const _CharT
* _M_day5
;
1183 const _CharT
* _M_day6
;
1184 const _CharT
* _M_day7
;
1186 // Abbreviated day names, starting with "C"'s Sun.
1187 const _CharT
* _M_aday1
;
1188 const _CharT
* _M_aday2
;
1189 const _CharT
* _M_aday3
;
1190 const _CharT
* _M_aday4
;
1191 const _CharT
* _M_aday5
;
1192 const _CharT
* _M_aday6
;
1193 const _CharT
* _M_aday7
;
1195 // Month names, starting with "C"'s January.
1196 const _CharT
* _M_month01
;
1197 const _CharT
* _M_month02
;
1198 const _CharT
* _M_month03
;
1199 const _CharT
* _M_month04
;
1200 const _CharT
* _M_month05
;
1201 const _CharT
* _M_month06
;
1202 const _CharT
* _M_month07
;
1203 const _CharT
* _M_month08
;
1204 const _CharT
* _M_month09
;
1205 const _CharT
* _M_month10
;
1206 const _CharT
* _M_month11
;
1207 const _CharT
* _M_month12
;
1209 // Abbreviated month names, starting with "C"'s Jan.
1210 const _CharT
* _M_amonth01
;
1211 const _CharT
* _M_amonth02
;
1212 const _CharT
* _M_amonth03
;
1213 const _CharT
* _M_amonth04
;
1214 const _CharT
* _M_amonth05
;
1215 const _CharT
* _M_amonth06
;
1216 const _CharT
* _M_amonth07
;
1217 const _CharT
* _M_amonth08
;
1218 const _CharT
* _M_amonth09
;
1219 const _CharT
* _M_amonth10
;
1220 const _CharT
* _M_amonth11
;
1221 const _CharT
* _M_amonth12
;
1225 __timepunct_cache(size_t __refs
= 0) : facet(__refs
),
1226 _M_date_format(NULL
), _M_date_era_format(NULL
), _M_time_format(NULL
),
1227 _M_time_era_format(NULL
), _M_date_time_format(NULL
),
1228 _M_date_time_era_format(NULL
), _M_am(NULL
), _M_pm(NULL
),
1229 _M_am_pm_format(NULL
), _M_day1(NULL
), _M_day2(NULL
), _M_day3(NULL
),
1230 _M_day4(NULL
), _M_day5(NULL
), _M_day6(NULL
), _M_day7(NULL
),
1231 _M_aday1(NULL
), _M_aday2(NULL
), _M_aday3(NULL
), _M_aday4(NULL
),
1232 _M_aday5(NULL
), _M_aday6(NULL
), _M_aday7(NULL
), _M_month01(NULL
),
1233 _M_month02(NULL
), _M_month03(NULL
), _M_month04(NULL
), _M_month05(NULL
),
1234 _M_month06(NULL
), _M_month07(NULL
), _M_month08(NULL
), _M_month09(NULL
),
1235 _M_month10(NULL
), _M_month11(NULL
), _M_month12(NULL
), _M_amonth01(NULL
),
1236 _M_amonth02(NULL
), _M_amonth03(NULL
), _M_amonth04(NULL
),
1237 _M_amonth05(NULL
), _M_amonth06(NULL
), _M_amonth07(NULL
),
1238 _M_amonth08(NULL
), _M_amonth09(NULL
), _M_amonth10(NULL
),
1239 _M_amonth11(NULL
), _M_amonth12(NULL
), _M_allocated(false)
1242 ~__timepunct_cache();
1245 _M_cache(const locale
& __loc
);
1248 template<typename _CharT
>
1249 __timepunct_cache
<_CharT
>::~__timepunct_cache()
1260 __timepunct_cache
<char>::_S_timezones
[14];
1262 #ifdef _GLIBCXX_USE_WCHAR_T
1265 __timepunct_cache
<wchar_t>::_S_timezones
[14];
1269 template<typename _CharT
>
1270 const _CharT
* __timepunct_cache
<_CharT
>::_S_timezones
[14];
1272 template<typename _CharT
>
1273 class __timepunct
: public locale::facet
1277 typedef _CharT __char_type
;
1278 typedef basic_string
<_CharT
> __string_type
;
1279 typedef __timepunct_cache
<_CharT
> __cache_type
;
1282 __cache_type
* _M_data
;
1283 __c_locale _M_c_locale_timepunct
;
1284 const char* _M_name_timepunct
;
1287 static locale::id id
;
1290 __timepunct(size_t __refs
= 0);
1293 __timepunct(__cache_type
* __cache
, size_t __refs
= 0);
1296 __timepunct(__c_locale __cloc
, const char* __s
, size_t __refs
= 0);
1299 _M_put(_CharT
* __s
, size_t __maxlen
, const _CharT
* __format
,
1300 const tm
* __tm
) const;
1303 _M_date_formats(const _CharT
** __date
) const
1305 // Always have default first.
1306 __date
[0] = _M_data
->_M_date_format
;
1307 __date
[1] = _M_data
->_M_date_era_format
;
1311 _M_time_formats(const _CharT
** __time
) const
1313 // Always have default first.
1314 __time
[0] = _M_data
->_M_time_format
;
1315 __time
[1] = _M_data
->_M_time_era_format
;
1319 _M_ampm(const _CharT
** __ampm
) const
1321 __ampm
[0] = _M_data
->_M_am
;
1322 __ampm
[1] = _M_data
->_M_pm
;
1326 _M_date_time_formats(const _CharT
** __dt
) const
1328 // Always have default first.
1329 __dt
[0] = _M_data
->_M_date_time_format
;
1330 __dt
[1] = _M_data
->_M_date_time_era_format
;
1334 _M_days(const _CharT
** __days
) const
1336 __days
[0] = _M_data
->_M_day1
;
1337 __days
[1] = _M_data
->_M_day2
;
1338 __days
[2] = _M_data
->_M_day3
;
1339 __days
[3] = _M_data
->_M_day4
;
1340 __days
[4] = _M_data
->_M_day5
;
1341 __days
[5] = _M_data
->_M_day6
;
1342 __days
[6] = _M_data
->_M_day7
;
1346 _M_days_abbreviated(const _CharT
** __days
) const
1348 __days
[0] = _M_data
->_M_aday1
;
1349 __days
[1] = _M_data
->_M_aday2
;
1350 __days
[2] = _M_data
->_M_aday3
;
1351 __days
[3] = _M_data
->_M_aday4
;
1352 __days
[4] = _M_data
->_M_aday5
;
1353 __days
[5] = _M_data
->_M_aday6
;
1354 __days
[6] = _M_data
->_M_aday7
;
1358 _M_months(const _CharT
** __months
) const
1360 __months
[0] = _M_data
->_M_month01
;
1361 __months
[1] = _M_data
->_M_month02
;
1362 __months
[2] = _M_data
->_M_month03
;
1363 __months
[3] = _M_data
->_M_month04
;
1364 __months
[4] = _M_data
->_M_month05
;
1365 __months
[5] = _M_data
->_M_month06
;
1366 __months
[6] = _M_data
->_M_month07
;
1367 __months
[7] = _M_data
->_M_month08
;
1368 __months
[8] = _M_data
->_M_month09
;
1369 __months
[9] = _M_data
->_M_month10
;
1370 __months
[10] = _M_data
->_M_month11
;
1371 __months
[11] = _M_data
->_M_month12
;
1375 _M_months_abbreviated(const _CharT
** __months
) const
1377 __months
[0] = _M_data
->_M_amonth01
;
1378 __months
[1] = _M_data
->_M_amonth02
;
1379 __months
[2] = _M_data
->_M_amonth03
;
1380 __months
[3] = _M_data
->_M_amonth04
;
1381 __months
[4] = _M_data
->_M_amonth05
;
1382 __months
[5] = _M_data
->_M_amonth06
;
1383 __months
[6] = _M_data
->_M_amonth07
;
1384 __months
[7] = _M_data
->_M_amonth08
;
1385 __months
[8] = _M_data
->_M_amonth09
;
1386 __months
[9] = _M_data
->_M_amonth10
;
1387 __months
[10] = _M_data
->_M_amonth11
;
1388 __months
[11] = _M_data
->_M_amonth12
;
1395 // For use at construction time only.
1397 _M_initialize_timepunct(__c_locale __cloc
= NULL
);
1400 template<typename _CharT
>
1401 locale::id __timepunct
<_CharT
>::id
;
1406 __timepunct
<char>::_M_initialize_timepunct(__c_locale __cloc
);
1410 __timepunct
<char>::_M_put(char*, size_t, const char*, const tm
*) const;
1412 #ifdef _GLIBCXX_USE_WCHAR_T
1415 __timepunct
<wchar_t>::_M_initialize_timepunct(__c_locale __cloc
);
1419 __timepunct
<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
1423 // Include host and configuration specific timepunct functions.
1424 #include <bits/time_members.h>
1426 template<typename _CharT
, typename _InIter
>
1427 class time_get
: public locale::facet
, public time_base
1431 typedef _CharT char_type
;
1432 typedef _InIter iter_type
;
1433 typedef basic_string
<_CharT
> __string_type
;
1435 static locale::id id
;
1438 time_get(size_t __refs
= 0)
1439 : facet (__refs
) { }
1443 { return this->do_date_order(); }
1446 get_time(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1447 ios_base::iostate
& __err
, tm
* __tm
) const
1448 { return this->do_get_time(__beg
, __end
, __io
, __err
, __tm
); }
1451 get_date(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1452 ios_base::iostate
& __err
, tm
* __tm
) const
1453 { return this->do_get_date(__beg
, __end
, __io
, __err
, __tm
); }
1456 get_weekday(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1457 ios_base::iostate
& __err
, tm
* __tm
) const
1458 { return this->do_get_weekday(__beg
, __end
, __io
, __err
, __tm
); }
1461 get_monthname(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1462 ios_base::iostate
& __err
, tm
* __tm
) const
1463 { return this->do_get_monthname(__beg
, __end
, __io
, __err
, __tm
); }
1466 get_year(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1467 ios_base::iostate
& __err
, tm
* __tm
) const
1468 { return this->do_get_year(__beg
, __end
, __io
, __err
, __tm
); }
1475 do_date_order() const;
1478 do_get_time(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1479 ios_base::iostate
& __err
, tm
* __tm
) const;
1482 do_get_date(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1483 ios_base::iostate
& __err
, tm
* __tm
) const;
1486 do_get_weekday(iter_type __beg
, iter_type __end
, ios_base
&,
1487 ios_base::iostate
& __err
, tm
* __tm
) const;
1490 do_get_monthname(iter_type __beg
, iter_type __end
, ios_base
&,
1491 ios_base::iostate
& __err
, tm
* __tm
) const;
1494 do_get_year(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1495 ios_base::iostate
& __err
, tm
* __tm
) const;
1497 // Extract numeric component of length __len.
1499 _M_extract_num(iter_type
& __beg
, iter_type
& __end
, int& __member
,
1500 int __min
, int __max
, size_t __len
,
1501 const ctype
<_CharT
>& __ctype
,
1502 ios_base::iostate
& __err
) const;
1504 // Extract day or month name, or any unique array of string
1505 // literals in a const _CharT* array.
1507 _M_extract_name(iter_type
& __beg
, iter_type
& __end
, int& __member
,
1508 const _CharT
** __names
, size_t __indexlen
,
1509 const ctype
<_CharT
>& __ctype
,
1510 ios_base::iostate
& __err
) const;
1512 // Extract on a component-by-component basis, via __format argument.
1514 _M_extract_via_format(iter_type
& __beg
, iter_type
& __end
, ios_base
& __io
,
1515 ios_base::iostate
& __err
, tm
* __tm
,
1516 const _CharT
* __format
) const;
1519 template<typename _CharT
, typename _InIter
>
1520 locale::id time_get
<_CharT
, _InIter
>::id
;
1522 template<typename _CharT
, typename _InIter
>
1523 class time_get_byname
: public time_get
<_CharT
, _InIter
>
1527 typedef _CharT char_type
;
1528 typedef _InIter iter_type
;
1531 time_get_byname(const char*, size_t __refs
= 0)
1532 : time_get
<_CharT
, _InIter
>(__refs
) { }
1536 ~time_get_byname() { }
1539 template<typename _CharT
, typename _OutIter
>
1540 class time_put
: public locale::facet
, public time_base
1544 typedef _CharT char_type
;
1545 typedef _OutIter iter_type
;
1547 static locale::id id
;
1550 time_put(size_t __refs
= 0)
1554 put(iter_type __s
, ios_base
& __io
, char_type __fill
, const tm
* __tm
,
1555 const _CharT
* __beg
, const _CharT
* __end
) const;
1558 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
1559 const tm
* __tm
, char __format
, char __mod
= 0) const
1560 { return this->do_put(__s
, __io
, __fill
, __tm
, __format
, __mod
); }
1568 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, const tm
* __tm
,
1569 char __format
, char __mod
) const;
1572 template<typename _CharT
, typename _OutIter
>
1573 locale::id time_put
<_CharT
, _OutIter
>::id
;
1575 template<typename _CharT
, typename _OutIter
>
1576 class time_put_byname
: public time_put
<_CharT
, _OutIter
>
1580 typedef _CharT char_type
;
1581 typedef _OutIter iter_type
;
1584 time_put_byname(const char*, size_t __refs
= 0)
1585 : time_put
<_CharT
, _OutIter
>(__refs
)
1590 ~time_put_byname() { }
1597 enum part
{ none
, space
, symbol
, sign
, value
};
1598 struct pattern
{ char field
[4]; };
1600 static const pattern _S_default_pattern
;
1602 // Construct and return valid pattern consisting of some combination of:
1603 // space none symbol sign value
1605 _S_construct_pattern(char __precedes
, char __space
, char __posn
);
1608 template<typename _CharT
>
1609 struct __moneypunct_cache
: public locale::facet
1611 const char* _M_grouping
;
1612 bool _M_use_grouping
;
1613 _CharT _M_decimal_point
;
1614 _CharT _M_thousands_sep
;
1615 const _CharT
* _M_curr_symbol
;
1616 const _CharT
* _M_positive_sign
;
1617 const _CharT
* _M_negative_sign
;
1619 money_base::pattern _M_pos_format
;
1620 money_base::pattern _M_neg_format
;
1624 __moneypunct_cache(size_t __refs
= 0) : facet(__refs
),
1625 _M_grouping(NULL
), _M_use_grouping(false), _M_decimal_point(_CharT()),
1626 _M_thousands_sep(_CharT()), _M_curr_symbol(NULL
), _M_positive_sign(NULL
),
1627 _M_negative_sign(NULL
), _M_frac_digits(0),
1628 _M_pos_format(money_base::pattern()),
1629 _M_neg_format(money_base::pattern()), _M_allocated(false)
1632 ~__moneypunct_cache();
1635 _M_cache(const locale
& __loc
);
1638 template<typename _CharT
>
1639 __moneypunct_cache
<_CharT
>::~__moneypunct_cache()
1647 template<typename _CharT
, bool _Intl
>
1648 class moneypunct
: public locale::facet
, public money_base
1652 typedef _CharT char_type
;
1653 typedef basic_string
<_CharT
> string_type
;
1654 typedef __moneypunct_cache
<_CharT
> __cache_type
;
1657 __cache_type
* _M_data
;
1660 static const bool intl
= _Intl
;
1661 static locale::id id
;
1664 moneypunct(size_t __refs
= 0) : facet(__refs
), _M_data(NULL
)
1665 { _M_initialize_moneypunct(); }
1668 moneypunct(__cache_type
* __cache
, size_t __refs
= 0)
1669 : facet(__refs
), _M_data(__cache
)
1670 { _M_initialize_moneypunct(); }
1673 moneypunct(__c_locale __cloc
, const char* __s
, size_t __refs
= 0)
1674 : facet(__refs
), _M_data(NULL
)
1675 { _M_initialize_moneypunct(__cloc
, __s
); }
1678 decimal_point() const
1679 { return this->do_decimal_point(); }
1682 thousands_sep() const
1683 { return this->do_thousands_sep(); }
1687 { return this->do_grouping(); }
1691 { return this->do_curr_symbol(); }
1694 positive_sign() const
1695 { return this->do_positive_sign(); }
1698 negative_sign() const
1699 { return this->do_negative_sign(); }
1703 { return this->do_frac_digits(); }
1707 { return this->do_pos_format(); }
1711 { return this->do_neg_format(); }
1718 do_decimal_point() const
1719 { return _M_data
->_M_decimal_point
; }
1722 do_thousands_sep() const
1723 { return _M_data
->_M_thousands_sep
; }
1727 { return _M_data
->_M_grouping
; }
1730 do_curr_symbol() const
1731 { return _M_data
->_M_curr_symbol
; }
1734 do_positive_sign() const
1735 { return _M_data
->_M_positive_sign
; }
1738 do_negative_sign() const
1739 { return _M_data
->_M_negative_sign
; }
1742 do_frac_digits() const
1743 { return _M_data
->_M_frac_digits
; }
1746 do_pos_format() const
1747 { return _M_data
->_M_pos_format
; }
1750 do_neg_format() const
1751 { return _M_data
->_M_neg_format
; }
1753 // For use at construction time only.
1755 _M_initialize_moneypunct(__c_locale __cloc
= NULL
,
1756 const char* __name
= NULL
);
1759 template<typename _CharT
, bool _Intl
>
1760 locale::id moneypunct
<_CharT
, _Intl
>::id
;
1762 template<typename _CharT
, bool _Intl
>
1763 const bool moneypunct
<_CharT
, _Intl
>::intl
;
1766 moneypunct
<char, true>::~moneypunct();
1769 moneypunct
<char, false>::~moneypunct();
1773 moneypunct
<char, true>::_M_initialize_moneypunct(__c_locale
, const char*);
1777 moneypunct
<char, false>::_M_initialize_moneypunct(__c_locale
, const char*);
1779 #ifdef _GLIBCXX_USE_WCHAR_T
1781 moneypunct
<wchar_t, true>::~moneypunct();
1784 moneypunct
<wchar_t, false>::~moneypunct();
1788 moneypunct
<wchar_t, true>::_M_initialize_moneypunct(__c_locale
,
1793 moneypunct
<wchar_t, false>::_M_initialize_moneypunct(__c_locale
,
1797 template<typename _CharT
, bool _Intl
>
1798 class moneypunct_byname
: public moneypunct
<_CharT
, _Intl
>
1801 typedef _CharT char_type
;
1802 typedef basic_string
<_CharT
> string_type
;
1804 static const bool intl
= _Intl
;
1807 moneypunct_byname(const char* __s
, size_t __refs
= 0)
1808 : moneypunct
<_CharT
, _Intl
>(__refs
)
1810 if (std::strcmp(__s
, "C") != 0 && std::strcmp(__s
, "POSIX") != 0)
1813 this->_S_create_c_locale(__tmp
, __s
);
1814 this->_M_initialize_moneypunct(__tmp
);
1815 this->_S_destroy_c_locale(__tmp
);
1821 ~moneypunct_byname() { }
1824 template<typename _CharT
, bool _Intl
>
1825 const bool moneypunct_byname
<_CharT
, _Intl
>::intl
;
1827 template<typename _CharT
, typename _InIter
>
1828 class money_get
: public locale::facet
1832 typedef _CharT char_type
;
1833 typedef _InIter iter_type
;
1834 typedef basic_string
<_CharT
> string_type
;
1836 static locale::id id
;
1839 money_get(size_t __refs
= 0) : facet(__refs
) { }
1842 get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1843 ios_base::iostate
& __err
, long double& __units
) const
1844 { return this->do_get(__s
, __end
, __intl
, __io
, __err
, __units
); }
1847 get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1848 ios_base::iostate
& __err
, string_type
& __digits
) const
1849 { return this->do_get(__s
, __end
, __intl
, __io
, __err
, __digits
); }
1856 do_get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1857 ios_base::iostate
& __err
, long double& __units
) const;
1860 do_get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1861 ios_base::iostate
& __err
, string_type
& __digits
) const;
1864 template<typename _CharT
, typename _InIter
>
1865 locale::id money_get
<_CharT
, _InIter
>::id
;
1867 template<typename _CharT
, typename _OutIter
>
1868 class money_put
: public locale::facet
1871 typedef _CharT char_type
;
1872 typedef _OutIter iter_type
;
1873 typedef basic_string
<_CharT
> string_type
;
1875 static locale::id id
;
1878 money_put(size_t __refs
= 0) : facet(__refs
) { }
1881 put(iter_type __s
, bool __intl
, ios_base
& __io
,
1882 char_type __fill
, long double __units
) const
1883 { return this->do_put(__s
, __intl
, __io
, __fill
, __units
); }
1886 put(iter_type __s
, bool __intl
, ios_base
& __io
,
1887 char_type __fill
, const string_type
& __digits
) const
1888 { return this->do_put(__s
, __intl
, __io
, __fill
, __digits
); }
1895 do_put(iter_type __s
, bool __intl
, ios_base
& __io
, char_type __fill
,
1896 long double __units
) const;
1899 do_put(iter_type __s
, bool __intl
, ios_base
& __io
, char_type __fill
,
1900 const string_type
& __digits
) const;
1903 template<typename _CharT
, typename _OutIter
>
1904 locale::id money_put
<_CharT
, _OutIter
>::id
;
1907 struct messages_base
1909 typedef int catalog
;
1912 template<typename _CharT
>
1913 class messages
: public locale::facet
, public messages_base
1917 typedef _CharT char_type
;
1918 typedef basic_string
<_CharT
> string_type
;
1921 // Underlying "C" library locale information saved from
1922 // initialization, needed by messages_byname as well.
1923 __c_locale _M_c_locale_messages
;
1924 const char* _M_name_messages
;
1927 static locale::id id
;
1930 messages(size_t __refs
= 0);
1934 messages(__c_locale __cloc
, const char* __s
, size_t __refs
= 0);
1937 open(const basic_string
<char>& __s
, const locale
& __loc
) const
1938 { return this->do_open(__s
, __loc
); }
1940 // Non-standard and unorthodox, yet effective.
1942 open(const basic_string
<char>&, const locale
&, const char*) const;
1945 get(catalog __c
, int __set
, int __msgid
, const string_type
& __s
) const
1946 { return this->do_get(__c
, __set
, __msgid
, __s
); }
1949 close(catalog __c
) const
1950 { return this->do_close(__c
); }
1957 do_open(const basic_string
<char>&, const locale
&) const;
1960 do_get(catalog
, int, int, const string_type
& __dfault
) const;
1963 do_close(catalog
) const;
1965 // Returns a locale and codeset-converted string, given a char* message.
1967 _M_convert_to_char(const string_type
& __msg
) const
1970 return reinterpret_cast<char*>(const_cast<_CharT
*>(__msg
.c_str()));
1973 // Returns a locale and codeset-converted string, given a char* message.
1975 _M_convert_from_char(char* __msg
) const
1977 // Length of message string without terminating null.
1978 size_t __len
= char_traits
<char>::length(__msg
) - 1;
1980 // "everybody can easily convert the string using
1981 // mbsrtowcs/wcsrtombs or with iconv()"
1983 // Convert char* to _CharT in locale used to open catalog.
1984 // XXX need additional template parameter on messages class for this..
1985 // typedef typename codecvt<char, _CharT, _StateT> __codecvt_type;
1986 typedef typename codecvt
<char, _CharT
, mbstate_t> __codecvt_type
;
1988 __codecvt_type::state_type __state
;
1989 // XXX may need to initialize state.
1990 //initialize_state(__state._M_init());
1993 // XXX what size for this string?
1994 _CharT
* __to
= static_cast<_CharT
*>(__builtin_alloca(__len
+ 1));
1995 const __codecvt_type
& __cvt
= use_facet
<__codecvt_type
>(_M_locale_conv
);
1996 __cvt
.out(__state
, __msg
, __msg
+ __len
, __from_next
,
1997 __to
, __to
+ __len
+ 1, __to_next
);
1998 return string_type(__to
);
2001 typedef ctype
<_CharT
> __ctype_type
;
2002 // const __ctype_type& __cvt = use_facet<__ctype_type>(_M_locale_msg);
2003 const __ctype_type
& __cvt
= use_facet
<__ctype_type
>(locale());
2004 // XXX Again, proper length of converted string an issue here.
2005 // For now, assume the converted length is not larger.
2006 _CharT
* __dest
= static_cast<_CharT
*>(__builtin_alloca(__len
+ 1));
2007 __cvt
.widen(__msg
, __msg
+ __len
, __dest
);
2008 return basic_string
<_CharT
>(__dest
);
2010 return string_type();
2014 template<typename _CharT
>
2015 locale::id messages
<_CharT
>::id
;
2017 // Specializations for required instantiations.
2020 messages
<char>::do_get(catalog
, int, int, const string
&) const;
2022 #ifdef _GLIBCXX_USE_WCHAR_T
2025 messages
<wchar_t>::do_get(catalog
, int, int, const wstring
&) const;
2028 template<typename _CharT
>
2029 class messages_byname
: public messages
<_CharT
>
2032 typedef _CharT char_type
;
2033 typedef basic_string
<_CharT
> string_type
;
2036 messages_byname(const char* __s
, size_t __refs
= 0);
2044 // Include host and configuration specific messages functions.
2045 #include <bits/messages_members.h>
2048 // Subclause convenience interfaces, inlines.
2049 // NB: These are inline because, when used in a loop, some compilers
2050 // can hoist the body out of the loop; then it's just as fast as the
2051 // C is*() function.
2052 template<typename _CharT
>
2054 isspace(_CharT __c
, const locale
& __loc
)
2055 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2057 template<typename _CharT
>
2059 isprint(_CharT __c
, const locale
& __loc
)
2060 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2062 template<typename _CharT
>
2064 iscntrl(_CharT __c
, const locale
& __loc
)
2065 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2067 template<typename _CharT
>
2069 isupper(_CharT __c
, const locale
& __loc
)
2070 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2072 template<typename _CharT
>
2073 inline bool islower(_CharT __c
, const locale
& __loc
)
2074 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2076 template<typename _CharT
>
2078 isalpha(_CharT __c
, const locale
& __loc
)
2079 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2081 template<typename _CharT
>
2083 isdigit(_CharT __c
, const locale
& __loc
)
2084 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2086 template<typename _CharT
>
2088 ispunct(_CharT __c
, const locale
& __loc
)
2089 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2091 template<typename _CharT
>
2093 isxdigit(_CharT __c
, const locale
& __loc
)
2094 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2096 template<typename _CharT
>
2098 isalnum(_CharT __c
, const locale
& __loc
)
2099 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2101 template<typename _CharT
>
2103 isgraph(_CharT __c
, const locale
& __loc
)
2104 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2106 template<typename _CharT
>
2108 toupper(_CharT __c
, const locale
& __loc
)
2109 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2111 template<typename _CharT
>
2113 tolower(_CharT __c
, const locale
& __loc
)
2114 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }