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
, int __base
= 10);
68 // Explicit specializations for required types.
71 __convert_to_v(const char*, long&, ios_base::iostate
&,
72 const __c_locale
&, int);
76 __convert_to_v(const char*, unsigned long&, ios_base::iostate
&,
77 const __c_locale
&, int);
79 #ifdef _GLIBCXX_USE_LONG_LONG
82 __convert_to_v(const char*, long long&, ios_base::iostate
&,
83 const __c_locale
&, int);
87 __convert_to_v(const char*, unsigned long long&, ios_base::iostate
&,
88 const __c_locale
&, int);
93 __convert_to_v(const char*, float&, ios_base::iostate
&,
94 const __c_locale
&, int);
98 __convert_to_v(const char*, double&, ios_base::iostate
&,
99 const __c_locale
&, int);
103 __convert_to_v(const char*, long double&, ios_base::iostate
&,
104 const __c_locale
&, int);
106 // NB: __pad is a struct, rather than a function, so it can be
107 // partially-specialized.
108 template<typename _CharT
, typename _Traits
>
112 _S_pad(ios_base
& __io
, _CharT __fill
, _CharT
* __news
,
113 const _CharT
* __olds
, const streamsize __newlen
,
114 const streamsize __oldlen
, const bool __num
);
117 // Used by both numeric and monetary facets.
118 // Check to make sure that the __grouping_tmp string constructed in
119 // money_get or num_get matches the canonical grouping for a given
121 // __grouping_tmp is parsed L to R
122 // 1,222,444 == __grouping_tmp of "\1\3\3"
123 // __grouping is parsed R to L
124 // 1,222,444 == __grouping of "\3" == "\3\3\3"
125 template<typename _CharT
>
127 __verify_grouping(const basic_string
<_CharT
>& __grouping
,
128 basic_string
<_CharT
>& __grouping_tmp
);
130 // Used by both numeric and monetary facets.
131 // Inserts "group separator" characters into an array of characters.
132 // It's recursive, one iteration per group. It moves the characters
133 // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
134 // only with __gbeg != __gend.
135 template<typename _CharT
>
137 __add_grouping(_CharT
* __s
, _CharT __sep
,
138 const char* __gbeg
, const char* __gend
,
139 const _CharT
* __first
, const _CharT
* __last
);
141 // This template permits specializing facet output code for
142 // ostreambuf_iterator. For ostreambuf_iterator, sputn is
143 // significantly more efficient than incrementing iterators.
144 template<typename _CharT
>
146 ostreambuf_iterator
<_CharT
>
147 __write(ostreambuf_iterator
<_CharT
> __s
, const _CharT
* __ws
, int __len
)
149 __s
._M_put(__ws
, __len
);
153 // This is the unspecialized form of the template.
154 template<typename _CharT
, typename _OutIter
>
157 __write(_OutIter __s
, const _CharT
* __ws
, int __len
)
159 for (int __j
= 0; __j
< __len
; __j
++, ++__s
)
165 // 22.2.1.1 Template class ctype
166 // Include host and configuration specific ctype enums for ctype_base.
167 #include <bits/ctype_base.h>
169 // Common base for ctype<_CharT>.
170 template<typename _CharT
>
171 class __ctype_abstract_base
: public locale::facet
, public ctype_base
175 typedef _CharT char_type
;
178 is(mask __m
, char_type __c
) const
179 { return this->do_is(__m
, __c
); }
182 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
183 { return this->do_is(__lo
, __hi
, __vec
); }
186 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
187 { return this->do_scan_is(__m
, __lo
, __hi
); }
190 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
191 { return this->do_scan_not(__m
, __lo
, __hi
); }
194 toupper(char_type __c
) const
195 { return this->do_toupper(__c
); }
198 toupper(char_type
*__lo
, const char_type
* __hi
) const
199 { return this->do_toupper(__lo
, __hi
); }
202 tolower(char_type __c
) const
203 { return this->do_tolower(__c
); }
206 tolower(char_type
* __lo
, const char_type
* __hi
) const
207 { return this->do_tolower(__lo
, __hi
); }
210 widen(char __c
) const
211 { return this->do_widen(__c
); }
214 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
215 { return this->do_widen(__lo
, __hi
, __to
); }
218 narrow(char_type __c
, char __dfault
) const
219 { return this->do_narrow(__c
, __dfault
); }
222 narrow(const char_type
* __lo
, const char_type
* __hi
,
223 char __dfault
, char *__to
) const
224 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
228 __ctype_abstract_base(size_t __refs
= 0): facet(__refs
) { }
231 ~__ctype_abstract_base() { }
234 do_is(mask __m
, char_type __c
) const = 0;
236 virtual const char_type
*
237 do_is(const char_type
* __lo
, const char_type
* __hi
,
238 mask
* __vec
) const = 0;
240 virtual const char_type
*
241 do_scan_is(mask __m
, const char_type
* __lo
,
242 const char_type
* __hi
) const = 0;
244 virtual const char_type
*
245 do_scan_not(mask __m
, const char_type
* __lo
,
246 const char_type
* __hi
) const = 0;
249 do_toupper(char_type
) const = 0;
251 virtual const char_type
*
252 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
255 do_tolower(char_type
) const = 0;
257 virtual const char_type
*
258 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
261 do_widen(char) const = 0;
264 do_widen(const char* __lo
, const char* __hi
,
265 char_type
* __dest
) const = 0;
268 do_narrow(char_type
, char __dfault
) const = 0;
270 virtual const char_type
*
271 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
272 char __dfault
, char* __dest
) const = 0;
275 // NB: Generic, mostly useless implementation.
276 template<typename _CharT
>
277 class ctype
: public __ctype_abstract_base
<_CharT
>
281 typedef _CharT char_type
;
282 typedef typename
ctype::mask mask
;
284 static locale::id id
;
287 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
294 do_is(mask __m
, char_type __c
) const;
296 virtual const char_type
*
297 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
299 virtual const char_type
*
300 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
302 virtual const char_type
*
303 do_scan_not(mask __m
, const char_type
* __lo
,
304 const char_type
* __hi
) const;
307 do_toupper(char_type __c
) const;
309 virtual const char_type
*
310 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
313 do_tolower(char_type __c
) const;
315 virtual const char_type
*
316 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
319 do_widen(char __c
) const;
322 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
325 do_narrow(char_type
, char __dfault
) const;
327 virtual const char_type
*
328 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
329 char __dfault
, char* __dest
) const;
332 template<typename _CharT
>
333 locale::id ctype
<_CharT
>::id
;
335 // 22.2.1.3 ctype<char> specialization.
337 class ctype
<char> : public locale::facet
, public ctype_base
341 typedef char char_type
;
345 __c_locale _M_c_locale_ctype
;
347 __to_type _M_toupper
;
348 __to_type _M_tolower
;
349 const mask
* _M_table
;
352 static locale::id id
;
353 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
356 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
359 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
363 is(mask __m
, char __c
) const;
366 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
369 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
372 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
375 toupper(char_type __c
) const
376 { return this->do_toupper(__c
); }
379 toupper(char_type
*__lo
, const char_type
* __hi
) const
380 { return this->do_toupper(__lo
, __hi
); }
383 tolower(char_type __c
) const
384 { return this->do_tolower(__c
); }
387 tolower(char_type
* __lo
, const char_type
* __hi
) const
388 { return this->do_tolower(__lo
, __hi
); }
391 widen(char __c
) const
392 { return this->do_widen(__c
); }
395 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
396 { return this->do_widen(__lo
, __hi
, __to
); }
399 narrow(char_type __c
, char __dfault
) const
400 { return this->do_narrow(__c
, __dfault
); }
403 narrow(const char_type
* __lo
, const char_type
* __hi
,
404 char __dfault
, char *__to
) const
405 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
409 table() const throw()
413 classic_table() throw();
419 do_toupper(char_type
) const;
421 virtual const char_type
*
422 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
425 do_tolower(char_type
) const;
427 virtual const char_type
*
428 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
431 do_widen(char __c
) const
435 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const
437 memcpy(__dest
, __lo
, __hi
- __lo
);
442 do_narrow(char_type __c
, char) const
445 virtual const char_type
*
446 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
447 char, char* __dest
) const
449 memcpy(__dest
, __lo
, __hi
- __lo
);
456 use_facet
<ctype
<char> >(const locale
& __loc
);
458 #ifdef _GLIBCXX_USE_WCHAR_T
459 // 22.2.1.3 ctype<wchar_t> specialization
461 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
465 typedef wchar_t char_type
;
466 typedef wctype_t __wmask_type
;
469 __c_locale _M_c_locale_ctype
;
473 static locale::id id
;
476 ctype(size_t __refs
= 0);
479 ctype(__c_locale __cloc
, size_t __refs
= 0);
483 _M_convert_to_wmask(const mask __m
) const;
489 do_is(mask __m
, char_type __c
) const;
491 virtual const char_type
*
492 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
494 virtual const char_type
*
495 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
497 virtual const char_type
*
498 do_scan_not(mask __m
, const char_type
* __lo
,
499 const char_type
* __hi
) const;
502 do_toupper(char_type
) const;
504 virtual const char_type
*
505 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
508 do_tolower(char_type
) const;
510 virtual const char_type
*
511 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
514 do_widen(char) const;
517 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
520 do_narrow(char_type
, char __dfault
) const;
522 virtual const char_type
*
523 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
524 char __dfault
, char* __dest
) const;
528 const ctype
<wchar_t>&
529 use_facet
<ctype
<wchar_t> >(const locale
& __loc
);
530 #endif //_GLIBCXX_USE_WCHAR_T
532 // Include host and configuration specific ctype inlines.
533 #include <bits/ctype_inline.h>
535 // 22.2.1.2 Template class ctype_byname
536 template<typename _CharT
>
537 class ctype_byname
: public ctype
<_CharT
>
540 typedef _CharT char_type
;
543 ctype_byname(const char* __s
, size_t __refs
= 0);
550 // 22.2.1.4 Class ctype_byname specializations.
552 ctype_byname
<char>::ctype_byname(const char*, size_t refs
);
555 ctype_byname
<wchar_t>::ctype_byname(const char*, size_t refs
);
557 // 22.2.1.5 Template class codecvt
558 #include <bits/codecvt.h>
560 // 22.2.2 The numeric category.
564 // NB: Code depends on the order of _S_atoms_out elements.
565 // Below are the indices into _S_atoms_out.
573 _S_odigits_end
= _S_odigits
+ 16,
574 _S_oudigits
= _S_odigits_end
,
575 _S_oudigits_end
= _S_oudigits
+ 16,
576 _S_oe
= _S_odigits
+ 14, // For scientific notation, 'e'
577 _S_oE
= _S_oudigits
+ 14, // For scientific notation, 'E'
578 _S_oend
= _S_oudigits_end
581 // A list of valid numeric literals for output. This array
582 // contains chars that will be passed through the current locale's
583 // ctype<_CharT>.widen() and then used to render numbers.
584 // For the standard "C" locale, this is
585 // "-+xX0123456789abcdef0123456789ABCDEF".
586 static const char* _S_atoms_out
;
588 // String literal of acceptable (narrow) input, for num_get.
589 // "-+xX0123456789eEabcdfABCDF"
590 static const char* _S_atoms_in
;
599 _S_ie
= _S_izero
+ 10,
600 _S_iE
= _S_izero
+ 11,
605 // Construct and return valid scanf format for floating point types.
607 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
);
610 template<typename _CharT
>
611 struct __numpunct_cache
: public locale::facet
613 const char* _M_grouping
;
614 bool _M_use_grouping
;
615 const _CharT
* _M_truename
;
616 const _CharT
* _M_falsename
;
617 _CharT _M_decimal_point
;
618 _CharT _M_thousands_sep
;
620 // A list of valid numeric literals for output: in the standard
621 // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF".
622 // This array contains the chars after having been passed
623 // through the current locale's ctype<_CharT>.widen().
624 _CharT _M_atoms_out
[__num_base::_S_oend
+ 1];
626 // A list of valid numeric literals for input: in the standard
627 // "C" locale, this is "-+xX0123456789eEabcdfABCDF"
628 // This array contains the chars after having been passed
629 // through the current locale's ctype<_CharT>.widen().
630 _CharT _M_atoms_in
[__num_base::_S_iend
+ 1];
634 __numpunct_cache(size_t __refs
= 0) : facet(__refs
),
635 _M_grouping(NULL
), _M_use_grouping(false), _M_truename(NULL
),
636 _M_falsename(NULL
), _M_decimal_point(_CharT()),
637 _M_thousands_sep(_CharT()), _M_allocated(false)
643 _M_cache(const locale
& __loc
);
646 template<typename _CharT
>
648 __numpunct_cache
<_CharT
>::_M_cache(const locale
& __loc
)
650 const numpunct
<_CharT
>& __np
= use_facet
<numpunct
<_CharT
> >(__loc
);
651 string __grouping
= __np
.grouping();
652 char* __group
= new char[__grouping
.length() + 1];
653 __grouping
.copy(__group
, __grouping
.length());
654 __group
[__grouping
.length()] = char();
655 _M_grouping
= __group
;
657 _M_use_grouping
= __grouping
.length() != 0 && __grouping
.data()[0] != 0;
659 typedef basic_string
<_CharT
> __string_type
;
661 __string_type __true
= __np
.truename();
662 _CharT
* __truename
= new _CharT
[__true
.length() + 1];
663 __true
.copy(__truename
, __true
.length());
664 __truename
[__true
.length()] = _CharT();
665 _M_truename
= __truename
;
667 __string_type __false
= __np
.falsename();
668 _CharT
* __falsename
= new _CharT
[__false
.length() + 1];
669 __false
.copy(__falsename
, __false
.length());
670 __falsename
[__false
.length()] = _CharT();
671 _M_falsename
= __falsename
;
673 _M_decimal_point
= __np
.decimal_point();
674 _M_thousands_sep
= __np
.thousands_sep();
676 const ctype
<_CharT
>& __ct
= use_facet
<ctype
<_CharT
> >(__loc
);
677 __ct
.widen(__num_base::_S_atoms_out
,
678 __num_base::_S_atoms_out
+ __num_base::_S_oend
, _M_atoms_out
);
679 _M_atoms_out
[__num_base::_S_oend
] = _CharT();
680 __ct
.widen(__num_base::_S_atoms_in
,
681 __num_base::_S_atoms_in
+ __num_base::_S_iend
, _M_atoms_in
);
682 _M_atoms_in
[__num_base::_S_iend
] = _CharT();
687 template<typename _CharT
>
688 __numpunct_cache
<_CharT
>::~__numpunct_cache()
692 delete [] _M_grouping
;
693 delete [] _M_truename
;
694 delete [] _M_falsename
;
698 template<typename _CharT
>
699 class numpunct
: public locale::facet
703 typedef _CharT char_type
;
704 typedef basic_string
<_CharT
> string_type
;
705 typedef __numpunct_cache
<_CharT
> __cache_type
;
708 __cache_type
* _M_data
;
711 static locale::id id
;
714 numpunct(size_t __refs
= 0) : facet(__refs
), _M_data(NULL
)
715 { _M_initialize_numpunct(); }
718 numpunct(__cache_type
* __cache
, size_t __refs
= 0)
719 : facet(__refs
), _M_data(__cache
)
720 { _M_initialize_numpunct(); }
723 numpunct(__c_locale __cloc
, size_t __refs
= 0)
724 : facet(__refs
), _M_data(NULL
)
725 { _M_initialize_numpunct(__cloc
); }
728 decimal_point() const
729 { return this->do_decimal_point(); }
732 thousands_sep() const
733 { return this->do_thousands_sep(); }
737 { return this->do_grouping(); }
741 { return this->do_truename(); }
745 { return this->do_falsename(); }
752 do_decimal_point() const
753 { return _M_data
->_M_decimal_point
; }
756 do_thousands_sep() const
757 { return _M_data
->_M_thousands_sep
; }
761 { return _M_data
->_M_grouping
; }
765 { return _M_data
->_M_truename
; }
769 { return _M_data
->_M_falsename
; }
771 // For use at construction time only.
773 _M_initialize_numpunct(__c_locale __cloc
= NULL
);
776 template<typename _CharT
>
777 locale::id numpunct
<_CharT
>::id
;
780 numpunct
<char>::~numpunct();
784 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
786 #ifdef _GLIBCXX_USE_WCHAR_T
788 numpunct
<wchar_t>::~numpunct();
792 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
795 template<typename _CharT
>
796 class numpunct_byname
: public numpunct
<_CharT
>
799 __c_locale _M_c_locale_numpunct
;
802 typedef _CharT char_type
;
803 typedef basic_string
<_CharT
> string_type
;
806 numpunct_byname(const char* __s
, size_t __refs
= 0)
807 : numpunct
<_CharT
>(__refs
)
809 this->_S_create_c_locale(_M_c_locale_numpunct
, __s
);
810 this->_M_initialize_numpunct(_M_c_locale_numpunct
);
816 { this->_S_destroy_c_locale(_M_c_locale_numpunct
); }
819 template<typename _CharT
, typename _InIter
>
820 class num_get
: public locale::facet
, public __num_base
824 typedef _CharT char_type
;
825 typedef _InIter iter_type
;
827 static locale::id id
;
830 num_get(size_t __refs
= 0) : facet(__refs
) { }
833 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
834 ios_base::iostate
& __err
, bool& __v
) const
835 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
838 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
839 ios_base::iostate
& __err
, long& __v
) const
840 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
843 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
844 ios_base::iostate
& __err
, unsigned short& __v
) const
845 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
848 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
849 ios_base::iostate
& __err
, unsigned int& __v
) const
850 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
853 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
854 ios_base::iostate
& __err
, unsigned long& __v
) const
855 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
857 #ifdef _GLIBCXX_USE_LONG_LONG
859 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
860 ios_base::iostate
& __err
, long long& __v
) const
861 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
864 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
865 ios_base::iostate
& __err
, unsigned long long& __v
) const
866 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
870 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
871 ios_base::iostate
& __err
, float& __v
) const
872 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
875 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
876 ios_base::iostate
& __err
, double& __v
) const
877 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
880 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
881 ios_base::iostate
& __err
, long double& __v
) const
882 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
885 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
886 ios_base::iostate
& __err
, void*& __v
) const
887 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
890 virtual ~num_get() { }
893 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
894 string
& __xtrc
) const;
897 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
898 string
& __xtrc
, int& __base
) const;
901 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
905 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, long&) const;
908 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
909 unsigned short&) const;
912 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
913 unsigned int&) const;
916 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
917 unsigned long&) const;
919 #ifdef _GLIBCXX_USE_LONG_LONG
921 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
925 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
926 unsigned long long&) const;
930 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
934 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
938 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
942 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
946 template<typename _CharT
, typename _InIter
>
947 locale::id num_get
<_CharT
, _InIter
>::id
;
950 template<typename _CharT
, typename _OutIter
>
951 class num_put
: public locale::facet
, public __num_base
955 typedef _CharT char_type
;
956 typedef _OutIter iter_type
;
957 static locale::id id
;
960 num_put(size_t __refs
= 0) : facet(__refs
) { }
963 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
964 { return this->do_put(__s
, __f
, __fill
, __v
); }
967 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
968 { return this->do_put(__s
, __f
, __fill
, __v
); }
971 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
972 unsigned long __v
) const
973 { return this->do_put(__s
, __f
, __fill
, __v
); }
975 #ifdef _GLIBCXX_USE_LONG_LONG
977 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
978 { return this->do_put(__s
, __f
, __fill
, __v
); }
981 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
982 unsigned long long __v
) const
983 { return this->do_put(__s
, __f
, __fill
, __v
); }
987 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
988 { return this->do_put(__s
, __f
, __fill
, __v
); }
991 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
992 long double __v
) const
993 { return this->do_put(__s
, __f
, __fill
, __v
); }
996 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
997 const void* __v
) const
998 { return this->do_put(__s
, __f
, __fill
, __v
); }
1001 template<typename _ValueT
>
1003 _M_insert_float(iter_type
, ios_base
& __io
, char_type __fill
,
1004 char __mod
, _ValueT __v
) const;
1007 _M_group_float(const string
& __grouping
, char_type __sep
,
1008 const char_type
* __p
, char_type
* __new
, char_type
* __cs
,
1011 template<typename _ValueT
>
1013 _M_insert_int(iter_type
, ios_base
& __io
, char_type __fill
,
1017 _M_group_int(const string
& __grouping
, char_type __sep
,
1018 ios_base
& __io
, char_type
* __new
, char_type
* __cs
,
1022 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
1023 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
1029 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
1032 do_put(iter_type
, ios_base
&, char_type __fill
, long __v
) const;
1035 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long) const;
1037 #ifdef _GLIBCXX_USE_LONG_LONG
1039 do_put(iter_type
, ios_base
&, char_type __fill
, long long __v
) const;
1042 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long long) const;
1046 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
1049 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
1052 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
1055 template <typename _CharT
, typename _OutIter
>
1056 locale::id num_put
<_CharT
, _OutIter
>::id
;
1059 template<typename _CharT
>
1060 class collate
: public locale::facet
1064 typedef _CharT char_type
;
1065 typedef basic_string
<_CharT
> string_type
;
1068 // Underlying "C" library locale information saved from
1069 // initialization, needed by collate_byname as well.
1070 __c_locale _M_c_locale_collate
;
1073 static locale::id id
;
1076 collate(size_t __refs
= 0)
1078 { _M_c_locale_collate
= _S_get_c_locale(); }
1081 collate(__c_locale __cloc
, size_t __refs
= 0)
1083 { _M_c_locale_collate
= _S_clone_c_locale(__cloc
); }
1086 compare(const _CharT
* __lo1
, const _CharT
* __hi1
,
1087 const _CharT
* __lo2
, const _CharT
* __hi2
) const
1088 { return this->do_compare(__lo1
, __hi1
, __lo2
, __hi2
); }
1091 transform(const _CharT
* __lo
, const _CharT
* __hi
) const
1092 { return this->do_transform(__lo
, __hi
); }
1095 hash(const _CharT
* __lo
, const _CharT
* __hi
) const
1096 { return this->do_hash(__lo
, __hi
); }
1098 // Used to abstract out _CharT bits in virtual member functions, below.
1100 _M_compare(const _CharT
*, const _CharT
*) const;
1103 _M_transform(_CharT
*, const _CharT
*, size_t) const;
1108 { _S_destroy_c_locale(_M_c_locale_collate
); }
1111 do_compare(const _CharT
* __lo1
, const _CharT
* __hi1
,
1112 const _CharT
* __lo2
, const _CharT
* __hi2
) const;
1115 do_transform(const _CharT
* __lo
, const _CharT
* __hi
) const;
1118 do_hash(const _CharT
* __lo
, const _CharT
* __hi
) const;
1121 template<typename _CharT
>
1122 locale::id collate
<_CharT
>::id
;
1127 collate
<char>::_M_compare(const char*, const char*) const;
1131 collate
<char>::_M_transform(char*, const char*, size_t) const;
1133 #ifdef _GLIBCXX_USE_WCHAR_T
1136 collate
<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
1140 collate
<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
1143 template<typename _CharT
>
1144 class collate_byname
: public collate
<_CharT
>
1147 typedef _CharT char_type
;
1148 typedef basic_string
<_CharT
> string_type
;
1151 collate_byname(const char* __s
, size_t __refs
= 0)
1152 : collate
<_CharT
>(__refs
)
1154 this->_S_destroy_c_locale(this->_M_c_locale_collate
);
1155 this->_S_create_c_locale(this->_M_c_locale_collate
, __s
);
1160 ~collate_byname() { }
1167 enum dateorder
{ no_order
, dmy
, mdy
, ymd
, ydm
};
1170 template<typename _CharT
>
1171 struct __timepunct_cache
: public locale::facet
1173 // List of all known timezones, with GMT first.
1174 static const _CharT
* _S_timezones
[14];
1176 const _CharT
* _M_date_format
;
1177 const _CharT
* _M_date_era_format
;
1178 const _CharT
* _M_time_format
;
1179 const _CharT
* _M_time_era_format
;
1180 const _CharT
* _M_date_time_format
;
1181 const _CharT
* _M_date_time_era_format
;
1182 const _CharT
* _M_am
;
1183 const _CharT
* _M_pm
;
1184 const _CharT
* _M_am_pm_format
;
1186 // Day names, starting with "C"'s Sunday.
1187 const _CharT
* _M_day1
;
1188 const _CharT
* _M_day2
;
1189 const _CharT
* _M_day3
;
1190 const _CharT
* _M_day4
;
1191 const _CharT
* _M_day5
;
1192 const _CharT
* _M_day6
;
1193 const _CharT
* _M_day7
;
1195 // Abbreviated day names, starting with "C"'s Sun.
1196 const _CharT
* _M_aday1
;
1197 const _CharT
* _M_aday2
;
1198 const _CharT
* _M_aday3
;
1199 const _CharT
* _M_aday4
;
1200 const _CharT
* _M_aday5
;
1201 const _CharT
* _M_aday6
;
1202 const _CharT
* _M_aday7
;
1204 // Month names, starting with "C"'s January.
1205 const _CharT
* _M_month01
;
1206 const _CharT
* _M_month02
;
1207 const _CharT
* _M_month03
;
1208 const _CharT
* _M_month04
;
1209 const _CharT
* _M_month05
;
1210 const _CharT
* _M_month06
;
1211 const _CharT
* _M_month07
;
1212 const _CharT
* _M_month08
;
1213 const _CharT
* _M_month09
;
1214 const _CharT
* _M_month10
;
1215 const _CharT
* _M_month11
;
1216 const _CharT
* _M_month12
;
1218 // Abbreviated month names, starting with "C"'s Jan.
1219 const _CharT
* _M_amonth01
;
1220 const _CharT
* _M_amonth02
;
1221 const _CharT
* _M_amonth03
;
1222 const _CharT
* _M_amonth04
;
1223 const _CharT
* _M_amonth05
;
1224 const _CharT
* _M_amonth06
;
1225 const _CharT
* _M_amonth07
;
1226 const _CharT
* _M_amonth08
;
1227 const _CharT
* _M_amonth09
;
1228 const _CharT
* _M_amonth10
;
1229 const _CharT
* _M_amonth11
;
1230 const _CharT
* _M_amonth12
;
1234 __timepunct_cache(size_t __refs
= 0) : facet(__refs
),
1235 _M_date_format(NULL
), _M_date_era_format(NULL
), _M_time_format(NULL
),
1236 _M_time_era_format(NULL
), _M_date_time_format(NULL
),
1237 _M_date_time_era_format(NULL
), _M_am(NULL
), _M_pm(NULL
),
1238 _M_am_pm_format(NULL
), _M_day1(NULL
), _M_day2(NULL
), _M_day3(NULL
),
1239 _M_day4(NULL
), _M_day5(NULL
), _M_day6(NULL
), _M_day7(NULL
),
1240 _M_aday1(NULL
), _M_aday2(NULL
), _M_aday3(NULL
), _M_aday4(NULL
),
1241 _M_aday5(NULL
), _M_aday6(NULL
), _M_aday7(NULL
), _M_month01(NULL
),
1242 _M_month02(NULL
), _M_month03(NULL
), _M_month04(NULL
), _M_month05(NULL
),
1243 _M_month06(NULL
), _M_month07(NULL
), _M_month08(NULL
), _M_month09(NULL
),
1244 _M_month10(NULL
), _M_month11(NULL
), _M_month12(NULL
), _M_amonth01(NULL
),
1245 _M_amonth02(NULL
), _M_amonth03(NULL
), _M_amonth04(NULL
),
1246 _M_amonth05(NULL
), _M_amonth06(NULL
), _M_amonth07(NULL
),
1247 _M_amonth08(NULL
), _M_amonth09(NULL
), _M_amonth10(NULL
),
1248 _M_amonth11(NULL
), _M_amonth12(NULL
), _M_allocated(false)
1251 ~__timepunct_cache();
1254 _M_cache(const locale
& __loc
);
1257 template<typename _CharT
>
1258 __timepunct_cache
<_CharT
>::~__timepunct_cache()
1269 __timepunct_cache
<char>::_S_timezones
[14];
1271 #ifdef _GLIBCXX_USE_WCHAR_T
1274 __timepunct_cache
<wchar_t>::_S_timezones
[14];
1278 template<typename _CharT
>
1279 const _CharT
* __timepunct_cache
<_CharT
>::_S_timezones
[14];
1281 template<typename _CharT
>
1282 class __timepunct
: public locale::facet
1286 typedef _CharT __char_type
;
1287 typedef basic_string
<_CharT
> __string_type
;
1288 typedef __timepunct_cache
<_CharT
> __cache_type
;
1291 __cache_type
* _M_data
;
1292 __c_locale _M_c_locale_timepunct
;
1293 const char* _M_name_timepunct
;
1296 static locale::id id
;
1299 __timepunct(size_t __refs
= 0);
1302 __timepunct(__cache_type
* __cache
, size_t __refs
= 0);
1305 __timepunct(__c_locale __cloc
, const char* __s
, size_t __refs
= 0);
1308 _M_put(_CharT
* __s
, size_t __maxlen
, const _CharT
* __format
,
1309 const tm
* __tm
) const;
1312 _M_date_formats(const _CharT
** __date
) const
1314 // Always have default first.
1315 __date
[0] = _M_data
->_M_date_format
;
1316 __date
[1] = _M_data
->_M_date_era_format
;
1320 _M_time_formats(const _CharT
** __time
) const
1322 // Always have default first.
1323 __time
[0] = _M_data
->_M_time_format
;
1324 __time
[1] = _M_data
->_M_time_era_format
;
1328 _M_ampm(const _CharT
** __ampm
) const
1330 __ampm
[0] = _M_data
->_M_am
;
1331 __ampm
[1] = _M_data
->_M_pm
;
1335 _M_date_time_formats(const _CharT
** __dt
) const
1337 // Always have default first.
1338 __dt
[0] = _M_data
->_M_date_time_format
;
1339 __dt
[1] = _M_data
->_M_date_time_era_format
;
1343 _M_days(const _CharT
** __days
) const
1345 __days
[0] = _M_data
->_M_day1
;
1346 __days
[1] = _M_data
->_M_day2
;
1347 __days
[2] = _M_data
->_M_day3
;
1348 __days
[3] = _M_data
->_M_day4
;
1349 __days
[4] = _M_data
->_M_day5
;
1350 __days
[5] = _M_data
->_M_day6
;
1351 __days
[6] = _M_data
->_M_day7
;
1355 _M_days_abbreviated(const _CharT
** __days
) const
1357 __days
[0] = _M_data
->_M_aday1
;
1358 __days
[1] = _M_data
->_M_aday2
;
1359 __days
[2] = _M_data
->_M_aday3
;
1360 __days
[3] = _M_data
->_M_aday4
;
1361 __days
[4] = _M_data
->_M_aday5
;
1362 __days
[5] = _M_data
->_M_aday6
;
1363 __days
[6] = _M_data
->_M_aday7
;
1367 _M_months(const _CharT
** __months
) const
1369 __months
[0] = _M_data
->_M_month01
;
1370 __months
[1] = _M_data
->_M_month02
;
1371 __months
[2] = _M_data
->_M_month03
;
1372 __months
[3] = _M_data
->_M_month04
;
1373 __months
[4] = _M_data
->_M_month05
;
1374 __months
[5] = _M_data
->_M_month06
;
1375 __months
[6] = _M_data
->_M_month07
;
1376 __months
[7] = _M_data
->_M_month08
;
1377 __months
[8] = _M_data
->_M_month09
;
1378 __months
[9] = _M_data
->_M_month10
;
1379 __months
[10] = _M_data
->_M_month11
;
1380 __months
[11] = _M_data
->_M_month12
;
1384 _M_months_abbreviated(const _CharT
** __months
) const
1386 __months
[0] = _M_data
->_M_amonth01
;
1387 __months
[1] = _M_data
->_M_amonth02
;
1388 __months
[2] = _M_data
->_M_amonth03
;
1389 __months
[3] = _M_data
->_M_amonth04
;
1390 __months
[4] = _M_data
->_M_amonth05
;
1391 __months
[5] = _M_data
->_M_amonth06
;
1392 __months
[6] = _M_data
->_M_amonth07
;
1393 __months
[7] = _M_data
->_M_amonth08
;
1394 __months
[8] = _M_data
->_M_amonth09
;
1395 __months
[9] = _M_data
->_M_amonth10
;
1396 __months
[10] = _M_data
->_M_amonth11
;
1397 __months
[11] = _M_data
->_M_amonth12
;
1404 // For use at construction time only.
1406 _M_initialize_timepunct(__c_locale __cloc
= NULL
);
1409 template<typename _CharT
>
1410 locale::id __timepunct
<_CharT
>::id
;
1415 __timepunct
<char>::_M_initialize_timepunct(__c_locale __cloc
);
1419 __timepunct
<char>::_M_put(char*, size_t, const char*, const tm
*) const;
1421 #ifdef _GLIBCXX_USE_WCHAR_T
1424 __timepunct
<wchar_t>::_M_initialize_timepunct(__c_locale __cloc
);
1428 __timepunct
<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
1432 // Include host and configuration specific timepunct functions.
1433 #include <bits/time_members.h>
1435 template<typename _CharT
, typename _InIter
>
1436 class time_get
: public locale::facet
, public time_base
1440 typedef _CharT char_type
;
1441 typedef _InIter iter_type
;
1442 typedef basic_string
<_CharT
> __string_type
;
1444 static locale::id id
;
1447 time_get(size_t __refs
= 0)
1448 : facet (__refs
) { }
1452 { return this->do_date_order(); }
1455 get_time(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1456 ios_base::iostate
& __err
, tm
* __tm
) const
1457 { return this->do_get_time(__beg
, __end
, __io
, __err
, __tm
); }
1460 get_date(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1461 ios_base::iostate
& __err
, tm
* __tm
) const
1462 { return this->do_get_date(__beg
, __end
, __io
, __err
, __tm
); }
1465 get_weekday(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1466 ios_base::iostate
& __err
, tm
* __tm
) const
1467 { return this->do_get_weekday(__beg
, __end
, __io
, __err
, __tm
); }
1470 get_monthname(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1471 ios_base::iostate
& __err
, tm
* __tm
) const
1472 { return this->do_get_monthname(__beg
, __end
, __io
, __err
, __tm
); }
1475 get_year(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1476 ios_base::iostate
& __err
, tm
* __tm
) const
1477 { return this->do_get_year(__beg
, __end
, __io
, __err
, __tm
); }
1484 do_date_order() const;
1487 do_get_time(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1488 ios_base::iostate
& __err
, tm
* __tm
) const;
1491 do_get_date(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1492 ios_base::iostate
& __err
, tm
* __tm
) const;
1495 do_get_weekday(iter_type __beg
, iter_type __end
, ios_base
&,
1496 ios_base::iostate
& __err
, tm
* __tm
) const;
1499 do_get_monthname(iter_type __beg
, iter_type __end
, ios_base
&,
1500 ios_base::iostate
& __err
, tm
* __tm
) const;
1503 do_get_year(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1504 ios_base::iostate
& __err
, tm
* __tm
) const;
1506 // Extract numeric component of length __len.
1508 _M_extract_num(iter_type
& __beg
, iter_type
& __end
, int& __member
,
1509 int __min
, int __max
, size_t __len
,
1510 const ctype
<_CharT
>& __ctype
,
1511 ios_base::iostate
& __err
) const;
1513 // Extract day or month name, or any unique array of string
1514 // literals in a const _CharT* array.
1516 _M_extract_name(iter_type
& __beg
, iter_type
& __end
, int& __member
,
1517 const _CharT
** __names
, size_t __indexlen
,
1518 ios_base::iostate
& __err
) const;
1520 // Extract on a component-by-component basis, via __format argument.
1522 _M_extract_via_format(iter_type
& __beg
, iter_type
& __end
, ios_base
& __io
,
1523 ios_base::iostate
& __err
, tm
* __tm
,
1524 const _CharT
* __format
) const;
1527 template<typename _CharT
, typename _InIter
>
1528 locale::id time_get
<_CharT
, _InIter
>::id
;
1530 template<typename _CharT
, typename _InIter
>
1531 class time_get_byname
: public time_get
<_CharT
, _InIter
>
1535 typedef _CharT char_type
;
1536 typedef _InIter iter_type
;
1539 time_get_byname(const char*, size_t __refs
= 0)
1540 : time_get
<_CharT
, _InIter
>(__refs
) { }
1544 ~time_get_byname() { }
1547 template<typename _CharT
, typename _OutIter
>
1548 class time_put
: public locale::facet
, public time_base
1552 typedef _CharT char_type
;
1553 typedef _OutIter iter_type
;
1555 static locale::id id
;
1558 time_put(size_t __refs
= 0)
1562 put(iter_type __s
, ios_base
& __io
, char_type __fill
, const tm
* __tm
,
1563 const _CharT
* __beg
, const _CharT
* __end
) const;
1566 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
1567 const tm
* __tm
, char __format
, char __mod
= 0) const
1568 { return this->do_put(__s
, __io
, __fill
, __tm
, __format
, __mod
); }
1576 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, const tm
* __tm
,
1577 char __format
, char __mod
) const;
1580 template<typename _CharT
, typename _OutIter
>
1581 locale::id time_put
<_CharT
, _OutIter
>::id
;
1583 template<typename _CharT
, typename _OutIter
>
1584 class time_put_byname
: public time_put
<_CharT
, _OutIter
>
1588 typedef _CharT char_type
;
1589 typedef _OutIter iter_type
;
1592 time_put_byname(const char* /*__s*/, size_t __refs
= 0)
1593 : time_put
<_CharT
, _OutIter
>(__refs
)
1598 ~time_put_byname() { }
1605 enum part
{ none
, space
, symbol
, sign
, value
};
1606 struct pattern
{ char field
[4]; };
1608 static const pattern _S_default_pattern
;
1610 // Construct and return valid pattern consisting of some combination of:
1611 // space none symbol sign value
1613 _S_construct_pattern(char __precedes
, char __space
, char __posn
);
1616 template<typename _CharT
>
1617 struct __moneypunct_cache
: public locale::facet
1619 const char* _M_grouping
;
1620 bool _M_use_grouping
;
1621 _CharT _M_decimal_point
;
1622 _CharT _M_thousands_sep
;
1623 const _CharT
* _M_curr_symbol
;
1624 const _CharT
* _M_positive_sign
;
1625 const _CharT
* _M_negative_sign
;
1627 money_base::pattern _M_pos_format
;
1628 money_base::pattern _M_neg_format
;
1632 __moneypunct_cache(size_t __refs
= 0) : facet(__refs
),
1633 _M_grouping(NULL
), _M_use_grouping(false), _M_decimal_point(_CharT()),
1634 _M_thousands_sep(_CharT()), _M_curr_symbol(NULL
), _M_positive_sign(NULL
),
1635 _M_negative_sign(NULL
), _M_frac_digits(0),
1636 _M_pos_format(money_base::pattern()),
1637 _M_neg_format(money_base::pattern()), _M_allocated(false)
1640 ~__moneypunct_cache();
1643 _M_cache(const locale
& __loc
);
1646 template<typename _CharT
>
1647 __moneypunct_cache
<_CharT
>::~__moneypunct_cache()
1655 template<typename _CharT
, bool _Intl
>
1656 class moneypunct
: public locale::facet
, public money_base
1660 typedef _CharT char_type
;
1661 typedef basic_string
<_CharT
> string_type
;
1662 typedef __moneypunct_cache
<_CharT
> __cache_type
;
1665 __cache_type
* _M_data
;
1668 static const bool intl
= _Intl
;
1669 static locale::id id
;
1672 moneypunct(size_t __refs
= 0) : facet(__refs
), _M_data(NULL
)
1673 { _M_initialize_moneypunct(); }
1676 moneypunct(__cache_type
* __cache
, size_t __refs
= 0)
1677 : facet(__refs
), _M_data(__cache
)
1678 { _M_initialize_moneypunct(); }
1681 moneypunct(__c_locale __cloc
, const char* __s
, size_t __refs
= 0)
1682 : facet(__refs
), _M_data(NULL
)
1683 { _M_initialize_moneypunct(__cloc
, __s
); }
1686 decimal_point() const
1687 { return this->do_decimal_point(); }
1690 thousands_sep() const
1691 { return this->do_thousands_sep(); }
1695 { return this->do_grouping(); }
1699 { return this->do_curr_symbol(); }
1702 positive_sign() const
1703 { return this->do_positive_sign(); }
1706 negative_sign() const
1707 { return this->do_negative_sign(); }
1711 { return this->do_frac_digits(); }
1715 { return this->do_pos_format(); }
1719 { return this->do_neg_format(); }
1726 do_decimal_point() const
1727 { return _M_data
->_M_decimal_point
; }
1730 do_thousands_sep() const
1731 { return _M_data
->_M_thousands_sep
; }
1735 { return _M_data
->_M_grouping
; }
1738 do_curr_symbol() const
1739 { return _M_data
->_M_curr_symbol
; }
1742 do_positive_sign() const
1743 { return _M_data
->_M_positive_sign
; }
1746 do_negative_sign() const
1747 { return _M_data
->_M_negative_sign
; }
1750 do_frac_digits() const
1751 { return _M_data
->_M_frac_digits
; }
1754 do_pos_format() const
1755 { return _M_data
->_M_pos_format
; }
1758 do_neg_format() const
1759 { return _M_data
->_M_neg_format
; }
1761 // For use at construction time only.
1763 _M_initialize_moneypunct(__c_locale __cloc
= NULL
,
1764 const char* __name
= NULL
);
1767 template<typename _CharT
, bool _Intl
>
1768 locale::id moneypunct
<_CharT
, _Intl
>::id
;
1770 template<typename _CharT
, bool _Intl
>
1771 const bool moneypunct
<_CharT
, _Intl
>::intl
;
1774 moneypunct
<char, true>::~moneypunct();
1777 moneypunct
<char, false>::~moneypunct();
1781 moneypunct
<char, true>::_M_initialize_moneypunct(__c_locale
, const char*);
1785 moneypunct
<char, false>::_M_initialize_moneypunct(__c_locale
, const char*);
1787 #ifdef _GLIBCXX_USE_WCHAR_T
1789 moneypunct
<wchar_t, true>::~moneypunct();
1792 moneypunct
<wchar_t, false>::~moneypunct();
1796 moneypunct
<wchar_t, true>::_M_initialize_moneypunct(__c_locale
,
1801 moneypunct
<wchar_t, false>::_M_initialize_moneypunct(__c_locale
,
1805 template<typename _CharT
, bool _Intl
>
1806 class moneypunct_byname
: public moneypunct
<_CharT
, _Intl
>
1808 __c_locale _M_c_locale_moneypunct
;
1811 typedef _CharT char_type
;
1812 typedef basic_string
<_CharT
> string_type
;
1814 static const bool intl
= _Intl
;
1817 moneypunct_byname(const char* __s
, size_t __refs
= 0)
1818 : moneypunct
<_CharT
, _Intl
>(__refs
)
1820 this->_S_create_c_locale(_M_c_locale_moneypunct
, __s
);
1821 this->_M_initialize_moneypunct(_M_c_locale_moneypunct
);
1826 ~moneypunct_byname()
1827 { this->_S_destroy_c_locale(_M_c_locale_moneypunct
); }
1830 template<typename _CharT
, bool _Intl
>
1831 const bool moneypunct_byname
<_CharT
, _Intl
>::intl
;
1833 template<typename _CharT
, typename _InIter
>
1834 class money_get
: public locale::facet
1838 typedef _CharT char_type
;
1839 typedef _InIter iter_type
;
1840 typedef basic_string
<_CharT
> string_type
;
1842 static locale::id id
;
1845 money_get(size_t __refs
= 0) : facet(__refs
) { }
1848 get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1849 ios_base::iostate
& __err
, long double& __units
) const
1850 { return this->do_get(__s
, __end
, __intl
, __io
, __err
, __units
); }
1853 get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1854 ios_base::iostate
& __err
, string_type
& __digits
) const
1855 { return this->do_get(__s
, __end
, __intl
, __io
, __err
, __digits
); }
1862 do_get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1863 ios_base::iostate
& __err
, long double& __units
) const;
1866 do_get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1867 ios_base::iostate
& __err
, string_type
& __digits
) const;
1870 template<typename _CharT
, typename _InIter
>
1871 locale::id money_get
<_CharT
, _InIter
>::id
;
1873 template<typename _CharT
, typename _OutIter
>
1874 class money_put
: public locale::facet
1877 typedef _CharT char_type
;
1878 typedef _OutIter iter_type
;
1879 typedef basic_string
<_CharT
> string_type
;
1881 static locale::id id
;
1884 money_put(size_t __refs
= 0) : facet(__refs
) { }
1887 put(iter_type __s
, bool __intl
, ios_base
& __io
,
1888 char_type __fill
, long double __units
) const
1889 { return this->do_put(__s
, __intl
, __io
, __fill
, __units
); }
1892 put(iter_type __s
, bool __intl
, ios_base
& __io
,
1893 char_type __fill
, const string_type
& __digits
) const
1894 { return this->do_put(__s
, __intl
, __io
, __fill
, __digits
); }
1901 do_put(iter_type __s
, bool __intl
, ios_base
& __io
, char_type __fill
,
1902 long double __units
) const;
1905 do_put(iter_type __s
, bool __intl
, ios_base
& __io
, char_type __fill
,
1906 const string_type
& __digits
) const;
1909 template<typename _CharT
, typename _OutIter
>
1910 locale::id money_put
<_CharT
, _OutIter
>::id
;
1913 struct messages_base
1915 typedef int catalog
;
1918 template<typename _CharT
>
1919 class messages
: public locale::facet
, public messages_base
1923 typedef _CharT char_type
;
1924 typedef basic_string
<_CharT
> string_type
;
1927 // Underlying "C" library locale information saved from
1928 // initialization, needed by messages_byname as well.
1929 __c_locale _M_c_locale_messages
;
1930 const char* _M_name_messages
;
1933 static locale::id id
;
1936 messages(size_t __refs
= 0);
1940 messages(__c_locale __cloc
, const char* __s
, size_t __refs
= 0);
1943 open(const basic_string
<char>& __s
, const locale
& __loc
) const
1944 { return this->do_open(__s
, __loc
); }
1946 // Non-standard and unorthodox, yet effective.
1948 open(const basic_string
<char>&, const locale
&, const char*) const;
1951 get(catalog __c
, int __set
, int __msgid
, const string_type
& __s
) const
1952 { return this->do_get(__c
, __set
, __msgid
, __s
); }
1955 close(catalog __c
) const
1956 { return this->do_close(__c
); }
1963 do_open(const basic_string
<char>&, const locale
&) const;
1966 do_get(catalog
, int, int, const string_type
& __dfault
) const;
1969 do_close(catalog
) const;
1971 // Returns a locale and codeset-converted string, given a char* message.
1973 _M_convert_to_char(const string_type
& __msg
) const
1976 return reinterpret_cast<char*>(const_cast<_CharT
*>(__msg
.c_str()));
1979 // Returns a locale and codeset-converted string, given a char* message.
1981 _M_convert_from_char(char* __msg
) const
1983 // Length of message string without terminating null.
1984 size_t __len
= char_traits
<char>::length(__msg
) - 1;
1986 // "everybody can easily convert the string using
1987 // mbsrtowcs/wcsrtombs or with iconv()"
1989 // Convert char* to _CharT in locale used to open catalog.
1990 // XXX need additional template parameter on messages class for this..
1991 // typedef typename codecvt<char, _CharT, _StateT> __codecvt_type;
1992 typedef typename codecvt
<char, _CharT
, mbstate_t> __codecvt_type
;
1994 __codecvt_type::state_type __state
;
1995 // XXX may need to initialize state.
1996 //initialize_state(__state._M_init());
1999 // XXX what size for this string?
2000 _CharT
* __to
= static_cast<_CharT
*>(__builtin_alloca(__len
+ 1));
2001 const __codecvt_type
& __cvt
= use_facet
<__codecvt_type
>(_M_locale_conv
);
2002 __cvt
.out(__state
, __msg
, __msg
+ __len
, __from_next
,
2003 __to
, __to
+ __len
+ 1, __to_next
);
2004 return string_type(__to
);
2007 typedef ctype
<_CharT
> __ctype_type
;
2008 // const __ctype_type& __cvt = use_facet<__ctype_type>(_M_locale_msg);
2009 const __ctype_type
& __cvt
= use_facet
<__ctype_type
>(locale());
2010 // XXX Again, proper length of converted string an issue here.
2011 // For now, assume the converted length is not larger.
2012 _CharT
* __dest
= static_cast<_CharT
*>(__builtin_alloca(__len
+ 1));
2013 __cvt
.widen(__msg
, __msg
+ __len
, __dest
);
2014 return basic_string
<_CharT
>(__dest
);
2016 return string_type();
2020 template<typename _CharT
>
2021 locale::id messages
<_CharT
>::id
;
2023 // Specializations for required instantiations.
2026 messages
<char>::do_get(catalog
, int, int, const string
&) const;
2028 #ifdef _GLIBCXX_USE_WCHAR_T
2031 messages
<wchar_t>::do_get(catalog
, int, int, const wstring
&) const;
2034 template<typename _CharT
>
2035 class messages_byname
: public messages
<_CharT
>
2038 typedef _CharT char_type
;
2039 typedef basic_string
<_CharT
> string_type
;
2042 messages_byname(const char* __s
, size_t __refs
= 0);
2050 // Include host and configuration specific messages functions.
2051 #include <bits/messages_members.h>
2054 // Subclause convenience interfaces, inlines.
2055 // NB: These are inline because, when used in a loop, some compilers
2056 // can hoist the body out of the loop; then it's just as fast as the
2057 // C is*() function.
2058 template<typename _CharT
>
2060 isspace(_CharT __c
, const locale
& __loc
)
2061 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
2063 template<typename _CharT
>
2065 isprint(_CharT __c
, const locale
& __loc
)
2066 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
2068 template<typename _CharT
>
2070 iscntrl(_CharT __c
, const locale
& __loc
)
2071 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
2073 template<typename _CharT
>
2075 isupper(_CharT __c
, const locale
& __loc
)
2076 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
2078 template<typename _CharT
>
2079 inline bool islower(_CharT __c
, const locale
& __loc
)
2080 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
2082 template<typename _CharT
>
2084 isalpha(_CharT __c
, const locale
& __loc
)
2085 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
2087 template<typename _CharT
>
2089 isdigit(_CharT __c
, const locale
& __loc
)
2090 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
2092 template<typename _CharT
>
2094 ispunct(_CharT __c
, const locale
& __loc
)
2095 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
2097 template<typename _CharT
>
2099 isxdigit(_CharT __c
, const locale
& __loc
)
2100 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
2102 template<typename _CharT
>
2104 isalnum(_CharT __c
, const locale
& __loc
)
2105 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
2107 template<typename _CharT
>
2109 isgraph(_CharT __c
, const locale
& __loc
)
2110 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
2112 template<typename _CharT
>
2114 toupper(_CharT __c
, const locale
& __loc
)
2115 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
2117 template<typename _CharT
>
2119 tolower(_CharT __c
, const locale
& __loc
)
2120 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }