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 _CPP_BITS_LOCFACETS_H
41 #define _CPP_BITS_LOCFACETS_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 _GLIBCPP_USE_WCHAR_T
55 # define _GLIBCPP_NUM_FACETS 28
57 # define _GLIBCPP_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 _GLIBCPP_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
)
164 // 22.2.1.1 Template class ctype
165 // Include host and configuration specific ctype enums for ctype_base.
166 #include <bits/ctype_base.h>
168 // Common base for ctype<_CharT>.
169 template<typename _CharT
>
170 class __ctype_abstract_base
: public locale::facet
, public ctype_base
174 typedef _CharT char_type
;
177 is(mask __m
, char_type __c
) const
178 { return this->do_is(__m
, __c
); }
181 is(const char_type
*__lo
, const char_type
*__hi
, mask
*__vec
) const
182 { return this->do_is(__lo
, __hi
, __vec
); }
185 scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
186 { return this->do_scan_is(__m
, __lo
, __hi
); }
189 scan_not(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const
190 { return this->do_scan_not(__m
, __lo
, __hi
); }
193 toupper(char_type __c
) const
194 { return this->do_toupper(__c
); }
197 toupper(char_type
*__lo
, const char_type
* __hi
) const
198 { return this->do_toupper(__lo
, __hi
); }
201 tolower(char_type __c
) const
202 { return this->do_tolower(__c
); }
205 tolower(char_type
* __lo
, const char_type
* __hi
) const
206 { return this->do_tolower(__lo
, __hi
); }
209 widen(char __c
) const
210 { return this->do_widen(__c
); }
213 widen(const char* __lo
, const char* __hi
, char_type
* __to
) const
214 { return this->do_widen(__lo
, __hi
, __to
); }
217 narrow(char_type __c
, char __dfault
) const
218 { return this->do_narrow(__c
, __dfault
); }
221 narrow(const char_type
* __lo
, const char_type
* __hi
,
222 char __dfault
, char *__to
) const
223 { return this->do_narrow(__lo
, __hi
, __dfault
, __to
); }
227 __ctype_abstract_base(size_t __refs
= 0): locale::facet(__refs
) { }
230 ~__ctype_abstract_base() { }
233 do_is(mask __m
, char_type __c
) const = 0;
235 virtual const char_type
*
236 do_is(const char_type
* __lo
, const char_type
* __hi
,
237 mask
* __vec
) const = 0;
239 virtual const char_type
*
240 do_scan_is(mask __m
, const char_type
* __lo
,
241 const char_type
* __hi
) const = 0;
243 virtual const char_type
*
244 do_scan_not(mask __m
, const char_type
* __lo
,
245 const char_type
* __hi
) const = 0;
248 do_toupper(char_type
) const = 0;
250 virtual const char_type
*
251 do_toupper(char_type
* __lo
, const char_type
* __hi
) const = 0;
254 do_tolower(char_type
) const = 0;
256 virtual const char_type
*
257 do_tolower(char_type
* __lo
, const char_type
* __hi
) const = 0;
260 do_widen(char) const = 0;
263 do_widen(const char* __lo
, const char* __hi
,
264 char_type
* __dest
) const = 0;
267 do_narrow(char_type
, char __dfault
) const = 0;
269 virtual const char_type
*
270 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
271 char __dfault
, char* __dest
) const = 0;
274 // NB: Generic, mostly useless implementation.
275 template<typename _CharT
>
276 class ctype
: public __ctype_abstract_base
<_CharT
>
280 typedef _CharT char_type
;
281 typedef typename
ctype::mask mask
;
283 static locale::id id
;
286 ctype(size_t __refs
= 0) : __ctype_abstract_base
<_CharT
>(__refs
) { }
293 do_is(mask __m
, char_type __c
) const;
295 virtual const char_type
*
296 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
298 virtual const char_type
*
299 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
301 virtual const char_type
*
302 do_scan_not(mask __m
, const char_type
* __lo
,
303 const char_type
* __hi
) const;
306 do_toupper(char_type __c
) const;
308 virtual const char_type
*
309 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
312 do_tolower(char_type __c
) const;
314 virtual const char_type
*
315 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
318 do_widen(char __c
) const;
321 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
324 do_narrow(char_type
, char __dfault
) const;
326 virtual const char_type
*
327 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
328 char __dfault
, char* __dest
) const;
331 template<typename _CharT
>
332 locale::id ctype
<_CharT
>::id
;
334 // 22.2.1.3 ctype<char> specialization.
336 class ctype
<char> : public __ctype_abstract_base
<char>
340 typedef char char_type
;
344 __c_locale _M_c_locale_ctype
;
346 __to_type _M_toupper
;
347 __to_type _M_tolower
;
348 const mask
* _M_table
;
351 static locale::id id
;
352 static const size_t table_size
= 1 + static_cast<unsigned char>(-1);
355 ctype(const mask
* __table
= 0, bool __del
= false, size_t __refs
= 0);
358 ctype(__c_locale __cloc
, const mask
* __table
= 0, bool __del
= false,
362 is(mask __m
, char __c
) const;
365 is(const char* __lo
, const char* __hi
, mask
* __vec
) const;
368 scan_is(mask __m
, const char* __lo
, const char* __hi
) const;
371 scan_not(mask __m
, const char* __lo
, const char* __hi
) const;
375 table() const throw()
379 classic_table() throw();
385 do_is(mask __m
, char_type __c
) const;
387 virtual const char_type
*
388 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
390 virtual const char_type
*
391 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
393 virtual const char_type
*
394 do_scan_not(mask __m
, const char_type
* __lo
,
395 const char_type
* __hi
) const;
398 do_toupper(char_type
) const;
400 virtual const char_type
*
401 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
404 do_tolower(char_type
) const;
406 virtual const char_type
*
407 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
410 do_widen(char) const;
413 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
416 do_narrow(char_type
, char __dfault
) const;
418 virtual const char_type
*
419 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
420 char __dfault
, char* __dest
) const;
425 use_facet
<ctype
<char> >(const locale
& __loc
);
427 #ifdef _GLIBCPP_USE_WCHAR_T
428 // 22.2.1.3 ctype<wchar_t> specialization
430 class ctype
<wchar_t> : public __ctype_abstract_base
<wchar_t>
434 typedef wchar_t char_type
;
435 typedef wctype_t __wmask_type
;
438 __c_locale _M_c_locale_ctype
;
442 static locale::id id
;
445 ctype(size_t __refs
= 0);
448 ctype(__c_locale __cloc
, size_t __refs
= 0);
452 _M_convert_to_wmask(const mask __m
) const;
458 do_is(mask __m
, char_type __c
) const;
460 virtual const char_type
*
461 do_is(const char_type
* __lo
, const char_type
* __hi
, mask
* __vec
) const;
463 virtual const char_type
*
464 do_scan_is(mask __m
, const char_type
* __lo
, const char_type
* __hi
) const;
466 virtual const char_type
*
467 do_scan_not(mask __m
, const char_type
* __lo
,
468 const char_type
* __hi
) const;
471 do_toupper(char_type
) const;
473 virtual const char_type
*
474 do_toupper(char_type
* __lo
, const char_type
* __hi
) const;
477 do_tolower(char_type
) const;
479 virtual const char_type
*
480 do_tolower(char_type
* __lo
, const char_type
* __hi
) const;
483 do_widen(char) const;
486 do_widen(const char* __lo
, const char* __hi
, char_type
* __dest
) const;
489 do_narrow(char_type
, char __dfault
) const;
491 virtual const char_type
*
492 do_narrow(const char_type
* __lo
, const char_type
* __hi
,
493 char __dfault
, char* __dest
) const;
498 const ctype
<wchar_t>&
499 use_facet
<ctype
<wchar_t> >(const locale
& __loc
);
500 #endif //_GLIBCPP_USE_WCHAR_T
502 // Include host and configuration specific ctype inlines.
503 #include <bits/ctype_inline.h>
505 // 22.2.1.2 Template class ctype_byname
506 template<typename _CharT
>
507 class ctype_byname
: public ctype
<_CharT
>
510 typedef _CharT char_type
;
513 ctype_byname(const char* __s
, size_t __refs
= 0);
520 // 22.2.1.4 Class ctype_byname specializations.
522 ctype_byname
<char>::ctype_byname(const char*, size_t refs
);
525 ctype_byname
<wchar_t>::ctype_byname(const char*, size_t refs
);
527 // 22.2.1.5 Template class codecvt
528 #include <bits/codecvt.h>
530 // 22.2.2 The numeric category.
534 // NB: Code depends on the order of _S_atoms_out elements.
535 // Below are the indices into _S_atoms_out.
543 _S_digits_end
= _S_digits
+ 16,
544 _S_udigits
= _S_digits_end
,
545 _S_udigits_end
= _S_udigits
+ 16,
546 _S_e
= _S_digits
+ 14, // For scientific notation, 'e'
547 _S_E
= _S_udigits
+ 14, // For scientific notation, 'E'
548 _S_end
= _S_udigits_end
551 // A list of valid numeric literals for output. This array
552 // contains chars that will be passed through the current locale's
553 // ctype<_CharT>.widen() and then used to render numbers.
554 // For the standard "C" locale, this is
555 // "-+xX0123456789abcdef0123456789ABCDEF".
556 static const char* _S_atoms_out
;
559 // String literal of acceptable (narrow) input, for num_get.
560 // "0123456789eEabcdfABCDF"
561 static const char* _S_atoms_in
;
572 // Construct and return valid scanf format for floating point types.
574 _S_format_float(const ios_base
& __io
, char* __fptr
, char __mod
,
577 // Construct and return valid scanf format for integer types.
579 _S_format_int(const ios_base
& __io
, char* __fptr
, char __mod
, char __modl
);
583 template<typename _CharT
>
584 class __locale_cache
;
586 template<typename _CharT
>
587 class numpunct
: public locale::facet
591 typedef _CharT char_type
;
592 typedef basic_string
<_CharT
> string_type
;
594 friend class __locale_cache
<numpunct
<_CharT
> >;
596 static locale::id id
;
599 char_type _M_decimal_point
;
600 char_type _M_thousands_sep
;
601 const char* _M_grouping
;
602 const char_type
* _M_truename
;
603 const char_type
* _M_falsename
;
607 numpunct(size_t __refs
= 0) : locale::facet(__refs
)
608 { _M_initialize_numpunct(); }
611 numpunct(__c_locale __cloc
, size_t __refs
= 0) : locale::facet(__refs
)
612 { _M_initialize_numpunct(__cloc
); }
615 decimal_point() const
616 { return this->do_decimal_point(); }
619 thousands_sep() const
620 { return this->do_thousands_sep(); }
624 { return this->do_grouping(); }
628 { return this->do_truename(); }
632 { return this->do_falsename(); }
639 do_decimal_point() const
640 { return _M_decimal_point
; }
643 do_thousands_sep() const
644 { return _M_thousands_sep
; }
648 { return _M_grouping
; }
652 { return _M_truename
; }
656 { return _M_falsename
; }
658 // For use at construction time only.
660 _M_initialize_numpunct(__c_locale __cloc
= NULL
);
663 template<typename _CharT
>
664 locale::id numpunct
<_CharT
>::id
;
667 numpunct
<char>::~numpunct();
671 numpunct
<char>::_M_initialize_numpunct(__c_locale __cloc
);
673 #ifdef _GLIBCPP_USE_WCHAR_T
675 numpunct
<wchar_t>::~numpunct();
679 numpunct
<wchar_t>::_M_initialize_numpunct(__c_locale __cloc
);
682 template<typename _CharT
>
683 class numpunct_byname
: public numpunct
<_CharT
>
686 __c_locale _M_c_locale_numpunct
;
689 typedef _CharT char_type
;
690 typedef basic_string
<_CharT
> string_type
;
693 numpunct_byname(const char* __s
, size_t __refs
= 0)
694 : numpunct
<_CharT
>(__refs
)
696 _S_create_c_locale(_M_c_locale_numpunct
, __s
);
697 _M_initialize_numpunct(_M_c_locale_numpunct
);
703 { _S_destroy_c_locale(_M_c_locale_numpunct
); }
706 template<typename _CharT
, typename _InIter
>
707 class num_get
: public locale::facet
, public __num_base
711 typedef _CharT char_type
;
712 typedef _InIter iter_type
;
714 static locale::id id
;
717 num_get(size_t __refs
= 0) : locale::facet(__refs
) { }
720 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
721 ios_base::iostate
& __err
, bool& __v
) const
722 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
725 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
726 ios_base::iostate
& __err
, long& __v
) const
727 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
730 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
731 ios_base::iostate
& __err
, unsigned short& __v
) const
732 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
735 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
736 ios_base::iostate
& __err
, unsigned int& __v
) const
737 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
740 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
741 ios_base::iostate
& __err
, unsigned long& __v
) const
742 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
744 #ifdef _GLIBCPP_USE_LONG_LONG
746 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
747 ios_base::iostate
& __err
, long long& __v
) const
748 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
751 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
752 ios_base::iostate
& __err
, unsigned long long& __v
) const
753 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
757 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
758 ios_base::iostate
& __err
, float& __v
) const
759 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
762 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
763 ios_base::iostate
& __err
, double& __v
) const
764 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
767 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
768 ios_base::iostate
& __err
, long double& __v
) const
769 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
772 get(iter_type __in
, iter_type __end
, ios_base
& __io
,
773 ios_base::iostate
& __err
, void*& __v
) const
774 { return this->do_get(__in
, __end
, __io
, __err
, __v
); }
777 virtual ~num_get() { }
780 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
781 string
& __xtrc
) const;
784 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
785 string
& __xtrc
, int& __base
) const;
788 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
792 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, long&) const;
795 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
796 unsigned short&) const;
799 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
800 unsigned int&) const;
803 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
804 unsigned long&) const;
806 #ifdef _GLIBCPP_USE_LONG_LONG
808 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
812 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
813 unsigned long long&) const;
817 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
821 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
825 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
829 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
& __err
,
833 template<typename _CharT
, typename _InIter
>
834 locale::id num_get
<_CharT
, _InIter
>::id
;
837 // Partial specialization for istreambuf_iterator, so can use traits_type.
838 template<typename _CharT
>
839 class num_get
<_CharT
, istreambuf_iterator
<_CharT
> >;
842 _M_extract_float(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
843 string
& __xtrc
) const;
846 _M_extract_int(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&,
847 string
& __xtrc
, int& __base
) const;
850 do_get(iter_type
, iter_type
, ios_base
&, ios_base::iostate
&, bool&) const;
853 template<typename _CharT
, typename _OutIter
>
854 class num_put
: public locale::facet
, public __num_base
858 typedef _CharT char_type
;
859 typedef _OutIter iter_type
;
860 static locale::id id
;
863 num_put(size_t __refs
= 0) : locale::facet(__refs
) { }
866 put(iter_type __s
, ios_base
& __f
, char_type __fill
, bool __v
) const
867 { return this->do_put(__s
, __f
, __fill
, __v
); }
870 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long __v
) const
871 { return this->do_put(__s
, __f
, __fill
, __v
); }
874 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
875 unsigned long __v
) const
876 { return this->do_put(__s
, __f
, __fill
, __v
); }
878 #ifdef _GLIBCPP_USE_LONG_LONG
880 put(iter_type __s
, ios_base
& __f
, char_type __fill
, long long __v
) const
881 { return this->do_put(__s
, __f
, __fill
, __v
); }
884 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
885 unsigned long long __v
) const
886 { return this->do_put(__s
, __f
, __fill
, __v
); }
890 put(iter_type __s
, ios_base
& __f
, char_type __fill
, double __v
) const
891 { return this->do_put(__s
, __f
, __fill
, __v
); }
894 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
895 long double __v
) const
896 { return this->do_put(__s
, __f
, __fill
, __v
); }
899 put(iter_type __s
, ios_base
& __f
, char_type __fill
,
900 const void* __v
) const
901 { return this->do_put(__s
, __f
, __fill
, __v
); }
904 template<typename _ValueT
>
906 _M_convert_float(iter_type
, ios_base
& __io
, char_type __fill
,
907 char __mod
, _ValueT __v
) const;
910 _M_group_float(const string
& __grouping
, char_type __sep
,
911 const char_type
* __p
, char_type
* __new
, char_type
* __cs
,
914 template<typename _ValueT
>
916 _M_convert_int(iter_type
, ios_base
& __io
, char_type __fill
,
920 _M_group_int(const string
& __grouping
, char_type __sep
,
921 ios_base
& __io
, char_type
* __new
, char_type
* __cs
,
925 _M_pad(char_type __fill
, streamsize __w
, ios_base
& __io
,
926 char_type
* __new
, const char_type
* __cs
, int& __len
) const;
929 // XXX GLIBCXX_ABI Deprecated, compatibility only.
930 template<typename _ValueT
>
932 _M_convert_int(iter_type
, ios_base
& __io
, char_type __fill
,
933 char __mod
, char __modl
, _ValueT __v
) const;
936 _M_widen_float(iter_type
, ios_base
& __io
, char_type __fill
, char* __cs
,
940 _M_widen_int(iter_type
, ios_base
& __io
, char_type __fill
, char* __cs
,
944 _M_insert(iter_type
, ios_base
& __io
, char_type __fill
,
945 const char_type
* __ws
, int __len
) const;
952 do_put(iter_type
, ios_base
&, char_type __fill
, bool __v
) const;
955 do_put(iter_type
, ios_base
&, char_type __fill
, long __v
) const;
958 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long) const;
960 #ifdef _GLIBCPP_USE_LONG_LONG
962 do_put(iter_type
, ios_base
&, char_type __fill
, long long __v
) const;
965 do_put(iter_type
, ios_base
&, char_type __fill
, unsigned long long) const;
969 do_put(iter_type
, ios_base
&, char_type __fill
, double __v
) const;
972 do_put(iter_type
, ios_base
&, char_type __fill
, long double __v
) const;
975 do_put(iter_type
, ios_base
&, char_type __fill
, const void* __v
) const;
978 template <typename _CharT
, typename _OutIter
>
979 locale::id num_put
<_CharT
, _OutIter
>::id
;
982 template<typename _CharT
>
983 class collate
: public locale::facet
987 typedef _CharT char_type
;
988 typedef basic_string
<_CharT
> string_type
;
991 // Underlying "C" library locale information saved from
992 // initialization, needed by collate_byname as well.
993 __c_locale _M_c_locale_collate
;
996 static locale::id id
;
999 collate(size_t __refs
= 0)
1000 : locale::facet(__refs
)
1001 { _M_c_locale_collate
= _S_c_locale
; }
1004 collate(__c_locale __cloc
, size_t __refs
= 0)
1005 : locale::facet(__refs
)
1006 { _M_c_locale_collate
= _S_clone_c_locale(__cloc
); }
1009 compare(const _CharT
* __lo1
, const _CharT
* __hi1
,
1010 const _CharT
* __lo2
, const _CharT
* __hi2
) const
1011 { return this->do_compare(__lo1
, __hi1
, __lo2
, __hi2
); }
1014 transform(const _CharT
* __lo
, const _CharT
* __hi
) const
1015 { return this->do_transform(__lo
, __hi
); }
1018 hash(const _CharT
* __lo
, const _CharT
* __hi
) const
1019 { return this->do_hash(__lo
, __hi
); }
1021 // Used to abstract out _CharT bits in virtual member functions, below.
1023 _M_compare(const _CharT
*, const _CharT
*) const;
1026 _M_transform(_CharT
*, const _CharT
*, size_t) const;
1031 { _S_destroy_c_locale(_M_c_locale_collate
); }
1034 do_compare(const _CharT
* __lo1
, const _CharT
* __hi1
,
1035 const _CharT
* __lo2
, const _CharT
* __hi2
) const;
1038 do_transform(const _CharT
* __lo
, const _CharT
* __hi
) const;
1041 do_hash(const _CharT
* __lo
, const _CharT
* __hi
) const;
1044 template<typename _CharT
>
1045 locale::id collate
<_CharT
>::id
;
1050 collate
<char>::_M_compare(const char*, const char*) const;
1054 collate
<char>::_M_transform(char*, const char*, size_t) const;
1056 #ifdef _GLIBCPP_USE_WCHAR_T
1059 collate
<wchar_t>::_M_compare(const wchar_t*, const wchar_t*) const;
1063 collate
<wchar_t>::_M_transform(wchar_t*, const wchar_t*, size_t) const;
1066 template<typename _CharT
>
1067 class collate_byname
: public collate
<_CharT
>
1070 typedef _CharT char_type
;
1071 typedef basic_string
<_CharT
> string_type
;
1074 collate_byname(const char* __s
, size_t __refs
= 0)
1075 : collate
<_CharT
>(__refs
)
1077 _S_destroy_c_locale(_M_c_locale_collate
);
1078 _S_create_c_locale(_M_c_locale_collate
, __s
);
1083 ~collate_byname() { }
1090 enum dateorder
{ no_order
, dmy
, mdy
, ymd
, ydm
};
1093 template<typename _CharT
>
1094 class __timepunct
: public locale::facet
1098 typedef _CharT __char_type
;
1099 typedef basic_string
<_CharT
> __string_type
;
1101 static locale::id id
;
1103 // List of all known timezones, with GMT first.
1104 static const _CharT
* _S_timezones
[14];
1107 __c_locale _M_c_locale_timepunct
;
1108 char* _M_name_timepunct
;
1109 const _CharT
* _M_date_format
;
1110 const _CharT
* _M_date_era_format
;
1111 const _CharT
* _M_time_format
;
1112 const _CharT
* _M_time_era_format
;
1113 const _CharT
* _M_date_time_format
;
1114 const _CharT
* _M_date_time_era_format
;
1115 const _CharT
* _M_am
;
1116 const _CharT
* _M_pm
;
1117 const _CharT
* _M_am_pm_format
;
1119 // Day names, starting with "C"'s Sunday.
1120 const _CharT
* _M_day1
;
1121 const _CharT
* _M_day2
;
1122 const _CharT
* _M_day3
;
1123 const _CharT
* _M_day4
;
1124 const _CharT
* _M_day5
;
1125 const _CharT
* _M_day6
;
1126 const _CharT
* _M_day7
;
1128 // Abbreviated day names, starting with "C"'s Sun.
1129 const _CharT
* _M_day_a1
;
1130 const _CharT
* _M_day_a2
;
1131 const _CharT
* _M_day_a3
;
1132 const _CharT
* _M_day_a4
;
1133 const _CharT
* _M_day_a5
;
1134 const _CharT
* _M_day_a6
;
1135 const _CharT
* _M_day_a7
;
1137 // Month names, starting with "C"'s January.
1138 const _CharT
* _M_month01
;
1139 const _CharT
* _M_month02
;
1140 const _CharT
* _M_month03
;
1141 const _CharT
* _M_month04
;
1142 const _CharT
* _M_month05
;
1143 const _CharT
* _M_month06
;
1144 const _CharT
* _M_month07
;
1145 const _CharT
* _M_month08
;
1146 const _CharT
* _M_month09
;
1147 const _CharT
* _M_month10
;
1148 const _CharT
* _M_month11
;
1149 const _CharT
* _M_month12
;
1151 // Abbreviated month names, starting with "C"'s Jan.
1152 const _CharT
* _M_month_a01
;
1153 const _CharT
* _M_month_a02
;
1154 const _CharT
* _M_month_a03
;
1155 const _CharT
* _M_month_a04
;
1156 const _CharT
* _M_month_a05
;
1157 const _CharT
* _M_month_a06
;
1158 const _CharT
* _M_month_a07
;
1159 const _CharT
* _M_month_a08
;
1160 const _CharT
* _M_month_a09
;
1161 const _CharT
* _M_month_a10
;
1162 const _CharT
* _M_month_a11
;
1163 const _CharT
* _M_month_a12
;
1167 __timepunct(size_t __refs
= 0);
1170 __timepunct(__c_locale __cloc
, const char* __s
, size_t __refs
= 0);
1173 _M_put(_CharT
* __s
, size_t __maxlen
, const _CharT
* __format
,
1174 const tm
* __tm
) const;
1177 _M_date_formats(const _CharT
** __date
) const
1179 // Always have default first.
1180 __date
[0] = _M_date_format
;
1181 __date
[1] = _M_date_era_format
;
1185 _M_time_formats(const _CharT
** __time
) const
1187 // Always have default first.
1188 __time
[0] = _M_time_format
;
1189 __time
[1] = _M_time_era_format
;
1193 _M_ampm(const _CharT
** __ampm
) const
1200 _M_date_time_formats(const _CharT
** __dt
) const
1202 // Always have default first.
1203 __dt
[0] = _M_date_time_format
;
1204 __dt
[1] = _M_date_time_era_format
;
1208 _M_days(const _CharT
** __days
) const
1210 __days
[0] = _M_day1
;
1211 __days
[1] = _M_day2
;
1212 __days
[2] = _M_day3
;
1213 __days
[3] = _M_day4
;
1214 __days
[4] = _M_day5
;
1215 __days
[5] = _M_day6
;
1216 __days
[6] = _M_day7
;
1220 _M_days_abbreviated(const _CharT
** __days
) const
1222 __days
[0] = _M_day_a1
;
1223 __days
[1] = _M_day_a2
;
1224 __days
[2] = _M_day_a3
;
1225 __days
[3] = _M_day_a4
;
1226 __days
[4] = _M_day_a5
;
1227 __days
[5] = _M_day_a6
;
1228 __days
[6] = _M_day_a7
;
1232 _M_months(const _CharT
** __months
) const
1234 __months
[0] = _M_month01
;
1235 __months
[1] = _M_month02
;
1236 __months
[2] = _M_month03
;
1237 __months
[3] = _M_month04
;
1238 __months
[4] = _M_month05
;
1239 __months
[5] = _M_month06
;
1240 __months
[6] = _M_month07
;
1241 __months
[7] = _M_month08
;
1242 __months
[8] = _M_month09
;
1243 __months
[9] = _M_month10
;
1244 __months
[10] = _M_month11
;
1245 __months
[11] = _M_month12
;
1249 _M_months_abbreviated(const _CharT
** __months
) const
1251 __months
[0] = _M_month_a01
;
1252 __months
[1] = _M_month_a02
;
1253 __months
[2] = _M_month_a03
;
1254 __months
[3] = _M_month_a04
;
1255 __months
[4] = _M_month_a05
;
1256 __months
[5] = _M_month_a06
;
1257 __months
[6] = _M_month_a07
;
1258 __months
[7] = _M_month_a08
;
1259 __months
[8] = _M_month_a09
;
1260 __months
[9] = _M_month_a10
;
1261 __months
[10] = _M_month_a11
;
1262 __months
[11] = _M_month_a12
;
1269 // For use at construction time only.
1271 _M_initialize_timepunct(__c_locale __cloc
= NULL
);
1274 template<typename _CharT
>
1275 locale::id __timepunct
<_CharT
>::id
;
1280 __timepunct
<char>::_S_timezones
[14];
1284 __timepunct
<char>::_M_initialize_timepunct(__c_locale __cloc
);
1288 __timepunct
<char>::_M_put(char*, size_t, const char*, const tm
*) const;
1290 #ifdef _GLIBCPP_USE_WCHAR_T
1293 __timepunct
<wchar_t>::_S_timezones
[14];
1297 __timepunct
<wchar_t>::_M_initialize_timepunct(__c_locale __cloc
);
1301 __timepunct
<wchar_t>::_M_put(wchar_t*, size_t, const wchar_t*,
1306 template<typename _CharT
>
1307 const _CharT
* __timepunct
<_CharT
>::_S_timezones
[14];
1309 // Include host and configuration specific timepunct functions.
1310 #include <bits/time_members.h>
1312 template<typename _CharT
, typename _InIter
>
1313 class time_get
: public locale::facet
, public time_base
1317 typedef _CharT char_type
;
1318 typedef _InIter iter_type
;
1319 typedef basic_string
<_CharT
> __string_type
;
1321 static locale::id id
;
1324 time_get(size_t __refs
= 0)
1325 : locale::facet (__refs
) { }
1329 { return this->do_date_order(); }
1332 get_time(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1333 ios_base::iostate
& __err
, tm
* __tm
) const
1334 { return this->do_get_time(__beg
, __end
, __io
, __err
, __tm
); }
1337 get_date(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1338 ios_base::iostate
& __err
, tm
* __tm
) const
1339 { return this->do_get_date(__beg
, __end
, __io
, __err
, __tm
); }
1342 get_weekday(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1343 ios_base::iostate
& __err
, tm
* __tm
) const
1344 { return this->do_get_weekday(__beg
, __end
, __io
, __err
, __tm
); }
1347 get_monthname(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1348 ios_base::iostate
& __err
, tm
* __tm
) const
1349 { return this->do_get_monthname(__beg
, __end
, __io
, __err
, __tm
); }
1352 get_year(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1353 ios_base::iostate
& __err
, tm
* __tm
) const
1354 { return this->do_get_year(__beg
, __end
, __io
, __err
, __tm
); }
1361 do_date_order() const;
1364 do_get_time(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1365 ios_base::iostate
& __err
, tm
* __tm
) const;
1368 do_get_date(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1369 ios_base::iostate
& __err
, tm
* __tm
) const;
1372 do_get_weekday(iter_type __beg
, iter_type __end
, ios_base
&,
1373 ios_base::iostate
& __err
, tm
* __tm
) const;
1376 do_get_monthname(iter_type __beg
, iter_type __end
, ios_base
&,
1377 ios_base::iostate
& __err
, tm
* __tm
) const;
1380 do_get_year(iter_type __beg
, iter_type __end
, ios_base
& __io
,
1381 ios_base::iostate
& __err
, tm
* __tm
) const;
1383 // Extract numeric component of length __len.
1385 _M_extract_num(iter_type
& __beg
, iter_type
& __end
, int& __member
,
1386 int __min
, int __max
, size_t __len
,
1387 const ctype
<_CharT
>& __ctype
,
1388 ios_base::iostate
& __err
) const;
1390 // Extract day or month name, or any unique array of string
1391 // literals in a const _CharT* array.
1393 _M_extract_name(iter_type
& __beg
, iter_type
& __end
, int& __member
,
1394 const _CharT
** __names
, size_t __indexlen
,
1395 ios_base::iostate
& __err
) const;
1397 // Extract on a component-by-component basis, via __format argument.
1399 _M_extract_via_format(iter_type
& __beg
, iter_type
& __end
, ios_base
& __io
,
1400 ios_base::iostate
& __err
, tm
* __tm
,
1401 const _CharT
* __format
) const;
1404 template<typename _CharT
, typename _InIter
>
1405 locale::id time_get
<_CharT
, _InIter
>::id
;
1407 template<typename _CharT
, typename _InIter
>
1408 class time_get_byname
: public time_get
<_CharT
, _InIter
>
1412 typedef _CharT char_type
;
1413 typedef _InIter iter_type
;
1416 time_get_byname(const char*, size_t __refs
= 0)
1417 : time_get
<_CharT
, _InIter
>(__refs
) { }
1421 ~time_get_byname() { }
1424 template<typename _CharT
, typename _OutIter
>
1425 class time_put
: public locale::facet
, public time_base
1429 typedef _CharT char_type
;
1430 typedef _OutIter iter_type
;
1432 static locale::id id
;
1435 time_put(size_t __refs
= 0)
1436 : locale::facet(__refs
) { }
1439 put(iter_type __s
, ios_base
& __io
, char_type __fill
, const tm
* __tm
,
1440 const _CharT
* __beg
, const _CharT
* __end
) const;
1443 put(iter_type __s
, ios_base
& __io
, char_type __fill
,
1444 const tm
* __tm
, char __format
, char __mod
= 0) const
1445 { return this->do_put(__s
, __io
, __fill
, __tm
, __format
, __mod
); }
1453 do_put(iter_type __s
, ios_base
& __io
, char_type __fill
, const tm
* __tm
,
1454 char __format
, char __mod
) const;
1457 template<typename _CharT
, typename _OutIter
>
1458 locale::id time_put
<_CharT
, _OutIter
>::id
;
1460 template<typename _CharT
, typename _OutIter
>
1461 class time_put_byname
: public time_put
<_CharT
, _OutIter
>
1465 typedef _CharT char_type
;
1466 typedef _OutIter iter_type
;
1469 time_put_byname(const char* /*__s*/, size_t __refs
= 0)
1470 : time_put
<_CharT
, _OutIter
>(__refs
)
1475 ~time_put_byname() { }
1482 enum part
{ none
, space
, symbol
, sign
, value
};
1483 struct pattern
{ char field
[4]; };
1485 static const pattern _S_default_pattern
;
1487 // Construct and return valid pattern consisting of some combination of:
1488 // space none symbol sign value
1490 _S_construct_pattern(char __precedes
, char __space
, char __posn
);
1493 template<typename _CharT
, bool _Intl
>
1494 class moneypunct
: public locale::facet
, public money_base
1498 typedef _CharT char_type
;
1499 typedef basic_string
<_CharT
> string_type
;
1501 static const bool intl
= _Intl
;
1502 static locale::id id
;
1505 const char* _M_grouping
;
1506 char_type _M_decimal_point
;
1507 char_type _M_thousands_sep
;
1508 const char_type
* _M_curr_symbol
;
1509 const char_type
* _M_positive_sign
;
1510 const char_type
* _M_negative_sign
;
1512 pattern _M_pos_format
;
1513 pattern _M_neg_format
;
1517 moneypunct(size_t __refs
= 0) : locale::facet(__refs
)
1518 { _M_initialize_moneypunct(); }
1521 moneypunct(__c_locale __cloc
, const char* __s
, size_t __refs
= 0)
1522 : locale::facet(__refs
)
1523 { _M_initialize_moneypunct(__cloc
, __s
); }
1526 decimal_point() const
1527 { return this->do_decimal_point(); }
1530 thousands_sep() const
1531 { return this->do_thousands_sep(); }
1535 { return this->do_grouping(); }
1539 { return this->do_curr_symbol(); }
1542 positive_sign() const
1543 { return this->do_positive_sign(); }
1546 negative_sign() const
1547 { return this->do_negative_sign(); }
1551 { return this->do_frac_digits(); }
1555 { return this->do_pos_format(); }
1559 { return this->do_neg_format(); }
1566 do_decimal_point() const
1567 { return _M_decimal_point
; }
1570 do_thousands_sep() const
1571 { return _M_thousands_sep
; }
1575 { return _M_grouping
; }
1578 do_curr_symbol() const
1579 { return _M_curr_symbol
; }
1582 do_positive_sign() const
1583 { return _M_positive_sign
; }
1586 do_negative_sign() const
1587 { return _M_negative_sign
; }
1590 do_frac_digits() const
1591 { return _M_frac_digits
; }
1594 do_pos_format() const
1595 { return _M_pos_format
; }
1598 do_neg_format() const
1599 { return _M_neg_format
; }
1601 // For use at construction time only.
1603 _M_initialize_moneypunct(__c_locale __cloc
= NULL
,
1604 const char* __name
= NULL
);
1607 template<typename _CharT
, bool _Intl
>
1608 locale::id moneypunct
<_CharT
, _Intl
>::id
;
1610 template<typename _CharT
, bool _Intl
>
1611 const bool moneypunct
<_CharT
, _Intl
>::intl
;
1614 moneypunct
<char, true>::~moneypunct();
1617 moneypunct
<char, false>::~moneypunct();
1621 moneypunct
<char, true>::_M_initialize_moneypunct(__c_locale
, const char*);
1625 moneypunct
<char, false>::_M_initialize_moneypunct(__c_locale
, const char*);
1627 #ifdef _GLIBCPP_USE_WCHAR_T
1629 moneypunct
<wchar_t, true>::~moneypunct();
1632 moneypunct
<wchar_t, false>::~moneypunct();
1636 moneypunct
<wchar_t, true>::_M_initialize_moneypunct(__c_locale
,
1641 moneypunct
<wchar_t, false>::_M_initialize_moneypunct(__c_locale
,
1645 template<typename _CharT
, bool _Intl
>
1646 class moneypunct_byname
: public moneypunct
<_CharT
, _Intl
>
1648 __c_locale _M_c_locale_moneypunct
;
1651 typedef _CharT char_type
;
1652 typedef basic_string
<_CharT
> string_type
;
1654 static const bool intl
= _Intl
;
1657 moneypunct_byname(const char* __s
, size_t __refs
= 0)
1658 : moneypunct
<_CharT
, _Intl
>(__refs
)
1660 _S_create_c_locale(_M_c_locale_moneypunct
, __s
);
1661 _M_initialize_moneypunct(_M_c_locale_moneypunct
);
1666 ~moneypunct_byname()
1667 { _S_destroy_c_locale(_M_c_locale_moneypunct
); }
1670 template<typename _CharT
, bool _Intl
>
1671 const bool moneypunct_byname
<_CharT
, _Intl
>::intl
;
1673 template<typename _CharT
, typename _InIter
>
1674 class money_get
: public locale::facet
1678 typedef _CharT char_type
;
1679 typedef _InIter iter_type
;
1680 typedef basic_string
<_CharT
> string_type
;
1682 static locale::id id
;
1685 money_get(size_t __refs
= 0) : locale::facet(__refs
) { }
1688 get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1689 ios_base::iostate
& __err
, long double& __units
) const
1690 { return this->do_get(__s
, __end
, __intl
, __io
, __err
, __units
); }
1693 get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1694 ios_base::iostate
& __err
, string_type
& __digits
) const
1695 { return this->do_get(__s
, __end
, __intl
, __io
, __err
, __digits
); }
1702 do_get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1703 ios_base::iostate
& __err
, long double& __units
) const;
1706 do_get(iter_type __s
, iter_type __end
, bool __intl
, ios_base
& __io
,
1707 ios_base::iostate
& __err
, string_type
& __digits
) const;
1710 template<typename _CharT
, typename _InIter
>
1711 locale::id money_get
<_CharT
, _InIter
>::id
;
1713 template<typename _CharT
, typename _OutIter
>
1714 class money_put
: public locale::facet
1717 typedef _CharT char_type
;
1718 typedef _OutIter iter_type
;
1719 typedef basic_string
<_CharT
> string_type
;
1721 static locale::id id
;
1724 money_put(size_t __refs
= 0) : locale::facet(__refs
) { }
1727 put(iter_type __s
, bool __intl
, ios_base
& __io
,
1728 char_type __fill
, long double __units
) const
1729 { return this->do_put(__s
, __intl
, __io
, __fill
, __units
); }
1732 put(iter_type __s
, bool __intl
, ios_base
& __io
,
1733 char_type __fill
, const string_type
& __digits
) const
1734 { return this->do_put(__s
, __intl
, __io
, __fill
, __digits
); }
1741 do_put(iter_type __s
, bool __intl
, ios_base
& __io
, char_type __fill
,
1742 long double __units
) const;
1745 do_put(iter_type __s
, bool __intl
, ios_base
& __io
, char_type __fill
,
1746 const string_type
& __digits
) const;
1749 template<typename _CharT
, typename _OutIter
>
1750 locale::id money_put
<_CharT
, _OutIter
>::id
;
1753 struct messages_base
1755 typedef int catalog
;
1758 template<typename _CharT
>
1759 class messages
: public locale::facet
, public messages_base
1763 typedef _CharT char_type
;
1764 typedef basic_string
<_CharT
> string_type
;
1767 // Underlying "C" library locale information saved from
1768 // initialization, needed by messages_byname as well.
1769 __c_locale _M_c_locale_messages
;
1770 char* _M_name_messages
;
1773 static locale::id id
;
1776 messages(size_t __refs
= 0);
1780 messages(__c_locale __cloc
, const char* __s
, size_t __refs
= 0);
1783 open(const basic_string
<char>& __s
, const locale
& __loc
) const
1784 { return this->do_open(__s
, __loc
); }
1786 // Non-standard and unorthodox, yet effective.
1788 open(const basic_string
<char>&, const locale
&, const char*) const;
1791 get(catalog __c
, int __set
, int __msgid
, const string_type
& __s
) const
1792 { return this->do_get(__c
, __set
, __msgid
, __s
); }
1795 close(catalog __c
) const
1796 { return this->do_close(__c
); }
1803 do_open(const basic_string
<char>&, const locale
&) const;
1806 do_get(catalog
, int, int, const string_type
& __dfault
) const;
1809 do_close(catalog
) const;
1811 // Returns a locale and codeset-converted string, given a char* message.
1813 _M_convert_to_char(const string_type
& __msg
) const
1816 return reinterpret_cast<char*>(const_cast<_CharT
*>(__msg
.c_str()));
1819 // Returns a locale and codeset-converted string, given a char* message.
1821 _M_convert_from_char(char* __msg
) const
1823 // Length of message string without terminating null.
1824 size_t __len
= char_traits
<char>::length(__msg
) - 1;
1826 // "everybody can easily convert the string using
1827 // mbsrtowcs/wcsrtombs or with iconv()"
1829 // Convert char* to _CharT in locale used to open catalog.
1830 // XXX need additional template parameter on messages class for this..
1831 // typedef typename codecvt<char, _CharT, _StateT> __codecvt_type;
1832 typedef typename codecvt
<char, _CharT
, mbstate_t> __codecvt_type
;
1834 __codecvt_type::state_type __state
;
1835 // XXX may need to initialize state.
1836 //initialize_state(__state._M_init());
1839 // XXX what size for this string?
1840 _CharT
* __to
= static_cast<_CharT
*>(__builtin_alloca(__len
+ 1));
1841 const __codecvt_type
& __cvt
= use_facet
<__codecvt_type
>(_M_locale_conv
);
1842 __cvt
.out(__state
, __msg
, __msg
+ __len
, __from_next
,
1843 __to
, __to
+ __len
+ 1, __to_next
);
1844 return string_type(__to
);
1847 typedef ctype
<_CharT
> __ctype_type
;
1848 // const __ctype_type& __cvt = use_facet<__ctype_type>(_M_locale_msg);
1849 const __ctype_type
& __cvt
= use_facet
<__ctype_type
>(locale());
1850 // XXX Again, proper length of converted string an issue here.
1851 // For now, assume the converted length is not larger.
1852 _CharT
* __dest
= static_cast<_CharT
*>(__builtin_alloca(__len
+ 1));
1853 __cvt
.widen(__msg
, __msg
+ __len
, __dest
);
1854 return basic_string
<_CharT
>(__dest
);
1856 return string_type();
1860 template<typename _CharT
>
1861 locale::id messages
<_CharT
>::id
;
1863 // Specializations for required instantiations.
1866 messages
<char>::do_get(catalog
, int, int, const string
&) const;
1868 #ifdef _GLIBCPP_USE_WCHAR_T
1871 messages
<wchar_t>::do_get(catalog
, int, int, const wstring
&) const;
1874 template<typename _CharT
>
1875 class messages_byname
: public messages
<_CharT
>
1878 typedef _CharT char_type
;
1879 typedef basic_string
<_CharT
> string_type
;
1882 messages_byname(const char* __s
, size_t __refs
= 0);
1890 // Include host and configuration specific messages functions.
1891 #include <bits/messages_members.h>
1894 // Subclause convenience interfaces, inlines.
1895 // NB: These are inline because, when used in a loop, some compilers
1896 // can hoist the body out of the loop; then it's just as fast as the
1897 // C is*() function.
1898 template<typename _CharT
>
1900 isspace(_CharT __c
, const locale
& __loc
)
1901 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::space
, __c
); }
1903 template<typename _CharT
>
1905 isprint(_CharT __c
, const locale
& __loc
)
1906 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::print
, __c
); }
1908 template<typename _CharT
>
1910 iscntrl(_CharT __c
, const locale
& __loc
)
1911 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::cntrl
, __c
); }
1913 template<typename _CharT
>
1915 isupper(_CharT __c
, const locale
& __loc
)
1916 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::upper
, __c
); }
1918 template<typename _CharT
>
1919 inline bool islower(_CharT __c
, const locale
& __loc
)
1920 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::lower
, __c
); }
1922 template<typename _CharT
>
1924 isalpha(_CharT __c
, const locale
& __loc
)
1925 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alpha
, __c
); }
1927 template<typename _CharT
>
1929 isdigit(_CharT __c
, const locale
& __loc
)
1930 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::digit
, __c
); }
1932 template<typename _CharT
>
1934 ispunct(_CharT __c
, const locale
& __loc
)
1935 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::punct
, __c
); }
1937 template<typename _CharT
>
1939 isxdigit(_CharT __c
, const locale
& __loc
)
1940 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::xdigit
, __c
); }
1942 template<typename _CharT
>
1944 isalnum(_CharT __c
, const locale
& __loc
)
1945 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::alnum
, __c
); }
1947 template<typename _CharT
>
1949 isgraph(_CharT __c
, const locale
& __loc
)
1950 { return use_facet
<ctype
<_CharT
> >(__loc
).is(ctype_base::graph
, __c
); }
1952 template<typename _CharT
>
1954 toupper(_CharT __c
, const locale
& __loc
)
1955 { return use_facet
<ctype
<_CharT
> >(__loc
).toupper(__c
); }
1957 template<typename _CharT
>
1959 tolower(_CharT __c
, const locale
& __loc
)
1960 { return use_facet
<ctype
<_CharT
> >(__loc
).tolower(__c
); }
1964 * __locale_cache objects hold information extracted from facets in
1965 * a form optimized for parsing and formatting. They are stored in
1966 * a locale's facet array and accessed via __use_cache<_Facet>.
1968 * The intent twofold: to avoid the costs of creating a locale
1969 * object and to avoid calling the virtual functions in a locale's
1970 * facet to look up data.
1973 class __locale_cache_base
1975 friend class std::locale::_Impl
;
1976 friend class locale
;
1980 ~__locale_cache_base() { }
1984 // This template doesn't really get used for anything except a
1985 // placeholder for specializations
1986 template<typename _Facet
>
1987 class __locale_cache
: public __locale_cache_base
1990 __locale_cache(const locale
&) {}
1993 template<typename _CharT
>
1994 class __locale_cache
<numpunct
<_CharT
> > : public __locale_cache_base
1997 typedef _CharT char_type
;
1998 typedef char_traits
<_CharT
> traits_type
;
1999 typedef basic_string
<_CharT
> string_type
;
2004 // The sign used to separate decimal values: for standard US
2005 // locales, this would usually be: "." Abstracted from
2006 // numpunct::decimal_point().
2007 _CharT _M_decimal_point
;
2009 // The sign used to separate groups of digits into smaller
2010 // strings that the eye can parse with less difficulty: for
2011 // standard US locales, this would usually be: "," Abstracted
2012 // from numpunct::thousands_sep().
2013 _CharT _M_thousands_sep
;
2015 // However the US's "false" and "true" are translated. From
2016 // numpunct::truename() and numpunct::falsename(), respectively.
2017 const _CharT
* _M_truename
;
2018 const _CharT
* _M_falsename
;
2020 // If we are checking groupings. This should be equivalent to
2021 // numpunct::groupings().size() != 0
2022 bool _M_use_grouping
;
2024 // If we are using numpunct's groupings, this is the current
2025 // grouping string in effect (from numpunct::grouping()).
2026 const char* _M_grouping
;
2028 // A list of valid numeric literals: for the standard "C"
2029 // locale, this is "-+xX0123456789abcdef0123456789ABCDEF". This
2030 // array contains the chars after having been passed through the
2031 // current locale's ctype<_CharT>.widen().
2033 // Copied here from __locale_cache<ctype> to save multiple cache
2034 // access in num_put functions.
2035 _CharT _M_atoms_out
[__num_base::_S_end
];
2038 __locale_cache(const locale
& __loc
);
2039 __locale_cache(const locale
& __loc
, bool);
2043 delete [] _M_truename
;
2044 delete [] _M_falsename
;
2045 delete [] _M_grouping
;