30 #ifndef _LOCALE_FACETS_NONIO_TCC
31 #define _LOCALE_FACETS_NONIO_TCC 1
33 #pragma GCC system_header
35 namespace std _GLIBCXX_VISIBILITY(default)
37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
39 template<
typename _CharT,
bool _Intl>
40 struct __use_cache<__moneypunct_cache<_CharT, _Intl> >
42 const __moneypunct_cache<_CharT, _Intl>*
43 operator() (
const locale& __loc)
const
46 const locale::facet** __caches = __loc._M_impl->_M_caches;
49 __moneypunct_cache<_CharT, _Intl>* __tmp = 0;
52 __tmp =
new __moneypunct_cache<_CharT, _Intl>;
53 __tmp->_M_cache(__loc);
58 __throw_exception_again;
60 __loc._M_impl->_M_install_cache(__tmp, __i);
63 const __moneypunct_cache<_CharT, _Intl>*
>(__caches[__i]);
67 template<
typename _CharT,
bool _Intl>
69 __moneypunct_cache<_CharT, _Intl>::_M_cache(
const locale& __loc)
71 const moneypunct<_CharT, _Intl>& __mp =
72 use_facet<moneypunct<_CharT, _Intl> >(__loc);
74 _M_decimal_point = __mp.decimal_point();
75 _M_thousands_sep = __mp.thousands_sep();
76 _M_frac_digits = __mp.frac_digits();
79 _CharT* __curr_symbol = 0;
80 _CharT* __positive_sign = 0;
81 _CharT* __negative_sign = 0;
84 const string& __g = __mp.grouping();
85 _M_grouping_size = __g.size();
86 __grouping =
new char[_M_grouping_size];
87 __g.copy(__grouping, _M_grouping_size);
88 _M_use_grouping = (_M_grouping_size
89 &&
static_cast<signed char>(__grouping[0]) > 0
91 != __gnu_cxx::__numeric_traits<char>::__max));
93 const basic_string<_CharT>& __cs = __mp.curr_symbol();
94 _M_curr_symbol_size = __cs.size();
95 __curr_symbol =
new _CharT[_M_curr_symbol_size];
96 __cs.copy(__curr_symbol, _M_curr_symbol_size);
98 const basic_string<_CharT>& __ps = __mp.positive_sign();
99 _M_positive_sign_size = __ps.size();
100 __positive_sign =
new _CharT[_M_positive_sign_size];
101 __ps.copy(__positive_sign, _M_positive_sign_size);
103 const basic_string<_CharT>& __ns = __mp.negative_sign();
104 _M_negative_sign_size = __ns.size();
105 __negative_sign =
new _CharT[_M_negative_sign_size];
106 __ns.copy(__negative_sign, _M_negative_sign_size);
108 _M_pos_format = __mp.pos_format();
109 _M_neg_format = __mp.neg_format();
111 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
112 __ct.widen(money_base::_S_atoms,
113 money_base::_S_atoms + money_base::_S_end, _M_atoms);
115 _M_grouping = __grouping;
116 _M_curr_symbol = __curr_symbol;
117 _M_positive_sign = __positive_sign;
118 _M_negative_sign = __negative_sign;
123 delete [] __grouping;
124 delete [] __curr_symbol;
125 delete [] __positive_sign;
126 delete [] __negative_sign;
127 __throw_exception_again;
131 _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
133 template<
typename _CharT,
typename _InIter>
136 money_get<_CharT, _InIter>::
137 _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
140 typedef char_traits<_CharT> __traits_type;
141 typedef typename string_type::size_type size_type;
142 typedef money_base::part part;
143 typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
145 const locale& __loc = __io._M_getloc();
146 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
148 __use_cache<__cache_type> __uc;
149 const __cache_type* __lc = __uc(__loc);
150 const char_type* __lit = __lc->_M_atoms;
153 bool __negative =
false;
155 size_type __sign_size = 0;
157 const bool __mandatory_sign = (__lc->_M_positive_sign_size
158 && __lc->_M_negative_sign_size);
160 string __grouping_tmp;
161 if (__lc->_M_use_grouping)
162 __grouping_tmp.reserve(32);
168 bool __testvalid =
true;
170 bool __testdecfound =
false;
176 const char_type* __lit_zero = __lit + money_base::_S_zero;
177 const money_base::pattern __p = __lc->_M_neg_format;
178 for (
int __i = 0; __i < 4 && __testvalid; ++__i)
180 const part __which =
static_cast<part
>(__p.field[__i]);
183 case money_base::symbol:
190 || (__i == 1 && (__mandatory_sign
191 || (
static_cast<part
>(__p.field[0])
193 || (
static_cast<part
>(__p.field[2])
194 == money_base::space)))
195 || (__i == 2 && ((
static_cast<part
>(__p.field[3])
196 == money_base::value)
198 && (
static_cast<part
>(__p.field[3])
199 == money_base::sign)))))
201 const size_type __len = __lc->_M_curr_symbol_size;
203 for (; __beg != __end && __j < __len
204 && *__beg == __lc->_M_curr_symbol[__j];
205 ++__beg, (void)++__j);
211 case money_base::sign:
213 if (__lc->_M_positive_sign_size && __beg != __end
214 && *__beg == __lc->_M_positive_sign[0])
216 __sign_size = __lc->_M_positive_sign_size;
219 else if (__lc->_M_negative_sign_size && __beg != __end
220 && *__beg == __lc->_M_negative_sign[0])
223 __sign_size = __lc->_M_negative_sign_size;
226 else if (__lc->_M_positive_sign_size
227 && !__lc->_M_negative_sign_size)
231 else if (__mandatory_sign)
234 case money_base::value:
237 for (; __beg != __end; ++__beg)
239 const char_type __c = *__beg;
240 const char_type* __q = __traits_type::find(__lit_zero,
244 __res += money_base::_S_atoms[__q - __lit];
247 else if (__c == __lc->_M_decimal_point
250 if (__lc->_M_frac_digits <= 0)
255 __testdecfound =
true;
257 else if (__lc->_M_use_grouping
258 && __c == __lc->_M_thousands_sep
264 __grouping_tmp +=
static_cast<char>(__n);
279 case money_base::space:
281 if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
286 case money_base::none:
289 for (; __beg != __end
290 && __ctype.is(ctype_base::space, *__beg); ++__beg);
296 if (__sign_size > 1 && __testvalid)
298 const char_type* __sign = __negative ? __lc->_M_negative_sign
299 : __lc->_M_positive_sign;
301 for (; __beg != __end && __i < __sign_size
302 && *__beg == __sign[__i]; ++__beg, (void)++__i);
304 if (__i != __sign_size)
311 if (__res.size() > 1)
313 const size_type __first = __res.find_first_not_of(
'0');
316 __res.erase(0, __only_zeros ? __res.size() - 1 : __first);
320 if (__negative && __res[0] !=
'0')
321 __res.insert(__res.begin(),
'-');
324 if (__grouping_tmp.size())
327 __grouping_tmp +=
static_cast<char>(__testdecfound ? __last_pos
329 if (!std::__verify_grouping(__lc->_M_grouping,
330 __lc->_M_grouping_size,
336 if (__testdecfound && __n != __lc->_M_frac_digits)
352 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
353 && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
354 template<
typename _CharT,
typename _InIter>
356 money_get<_CharT, _InIter>::
357 __do_get(iter_type __beg, iter_type __end,
bool __intl, ios_base& __io,
361 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
362 : _M_extract<false>(__beg, __end, __io, __err, __str);
363 std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
368 template<
typename _CharT,
typename _InIter>
372 ios_base::iostate& __err,
long double& __units)
const
375 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
376 : _M_extract<false>(__beg, __end, __io, __err, __str);
377 std::__convert_to_v(__str.
c_str(), __units, __err, _S_get_c_locale());
381 template<
typename _CharT,
typename _InIter>
385 ios_base::iostate& __err,
string_type& __digits)
const
387 typedef typename string::size_type size_type;
390 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
393 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
394 : _M_extract<false>(__beg, __end, __io, __err, __str);
395 const size_type __len = __str.size();
399 __ctype.
widen(__str.data(), __str.data() + __len, &__digits[0]);
404 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
405 && defined __LONG_DOUBLE_IEEE128__
406 template<
typename _CharT,
typename _InIter>
410 ios_base::iostate& __err, __ibm128& __units)
const
413 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
414 : _M_extract<false>(__beg, __end, __io, __err, __str);
415 std::__convert_to_v(__str.
c_str(), __units, __err, _S_get_c_locale());
420 template<
typename _CharT,
typename _OutIter>
423 money_put<_CharT, _OutIter>::
424 _M_insert(iter_type __s, ios_base& __io, char_type __fill,
425 const string_type& __digits)
const
427 typedef typename string_type::size_type size_type;
428 typedef money_base::part part;
429 typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
431 const locale& __loc = __io._M_getloc();
432 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
434 __use_cache<__cache_type> __uc;
435 const __cache_type* __lc = __uc(__loc);
436 const char_type* __lit = __lc->_M_atoms;
440 const char_type* __beg = __digits.data();
442 money_base::pattern __p;
443 const char_type* __sign;
444 size_type __sign_size;
445 if (!(*__beg == __lit[money_base::_S_minus]))
447 __p = __lc->_M_pos_format;
448 __sign = __lc->_M_positive_sign;
449 __sign_size = __lc->_M_positive_sign_size;
453 __p = __lc->_M_neg_format;
454 __sign = __lc->_M_negative_sign;
455 __sign_size = __lc->_M_negative_sign_size;
461 size_type __len = __ctype.scan_not(ctype_base::digit, __beg,
462 __beg + __digits.size()) - __beg;
469 __value.reserve(2 * __len);
473 long __paddec = __len - __lc->_M_frac_digits;
476 if (__lc->_M_frac_digits < 0)
478 if (__lc->_M_grouping_size)
480 __value.assign(2 * __paddec, char_type());
482 std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
484 __lc->_M_grouping_size,
485 __beg, __beg + __paddec);
486 __value.erase(__vend - &__value[0]);
489 __value.assign(__beg, __paddec);
493 if (__lc->_M_frac_digits > 0)
495 __value += __lc->_M_decimal_point;
497 __value.append(__beg + __paddec, __lc->_M_frac_digits);
501 __value.append(-__paddec, __lit[money_base::_S_zero]);
502 __value.append(__beg, __len);
509 __len = __value.size() + __sign_size;
511 ? __lc->_M_curr_symbol_size : 0);
514 __res.reserve(2 * __len);
516 const size_type __width =
static_cast<size_type
>(__io.width());
520 for (
int __i = 0; __i < 4; ++__i)
522 const part __which =
static_cast<part
>(__p.field[__i]);
525 case money_base::symbol:
527 __res.append(__lc->_M_curr_symbol,
528 __lc->_M_curr_symbol_size);
530 case money_base::sign:
537 case money_base::value:
540 case money_base::space:
545 __res.append(__width - __len, __fill);
549 case money_base::none:
551 __res.append(__width - __len, __fill);
558 __res.append(__sign + 1, __sign_size - 1);
561 __len = __res.size();
566 __res.append(__width - __len, __fill);
569 __res.insert(0, __width - __len, __fill);
574 __s = std::__write(__s, __res.data(), __len);
580 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
581 && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
582 template<
typename _CharT,
typename _OutIter>
584 money_put<_CharT, _OutIter>::
585 __do_put(iter_type __s,
bool __intl, ios_base& __io, char_type __fill,
586 double __units)
const
587 {
return this->do_put(__s, __intl, __io, __fill, (
long double) __units); }
590 template<
typename _CharT,
typename _OutIter>
594 long double __units)
const
597 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
598 #if _GLIBCXX_USE_C99_STDIO
601 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
604 int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
605 "%.*Lf", 0, __units);
607 if (__len >= __cs_size)
609 __cs_size = __len + 1;
610 __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
611 __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
612 "%.*Lf", 0, __units);
616 const int __cs_size =
617 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
618 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
619 int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0,
"%.*Lf",
623 __ctype.
widen(__cs, __cs + __len, &__digits[0]);
624 return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
625 : _M_insert<false>(__s, __io, __fill, __digits);
628 template<
typename _CharT,
typename _OutIter>
633 {
return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
634 : _M_insert<false>(__s, __io, __fill, __digits); }
636 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
637 && defined __LONG_DOUBLE_IEEE128__
638 template<
typename _CharT,
typename _OutIter>
642 __ibm128 __units)
const
645 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
646 #if _GLIBCXX_USE_C99_STDIO
649 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
652 int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
653 "%.*Lf", 0, __units);
655 if (__len >= __cs_size)
657 __cs_size = __len + 1;
658 __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
659 __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
660 "%.*Lf", 0, __units);
664 const int __cs_size =
665 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
666 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
667 int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0,
"%.*Lf",
670 string_type __digits(__len, char_type());
671 __ctype.
widen(__cs, __cs + __len, &__digits[0]);
672 return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
673 : _M_insert<false>(__s, __io, __fill, __digits);
677 _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
682 template<
typename _CharT,
typename _InIter>
685 {
return time_base::no_order; }
689 template<
typename _CharT,
typename _InIter>
693 ios_base::iostate& __err, tm* __tm,
694 const _CharT* __format,
695 __time_get_state &__state)
const
698 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
699 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
704 for (; __beg != __end && __i < __len && !__tmperr; ++__i)
706 if (__ctype.narrow(__format[__i], 0) ==
'%')
709 char __c = __ctype.narrow(__format[++__i], 0);
711 if (__c ==
'E' || __c ==
'O')
712 __c = __ctype.narrow(__format[++__i], 0);
720 const char_type* __days[14];
721 __tp._M_days(&__days[0]);
722 __tp._M_days_abbreviated(&__days[7]);
723 __beg = _M_extract_name(__beg, __end, __mem, __days,
727 __tm->tm_wday = __mem % 7;
728 __state._M_have_wday = 1;
735 const char_type* __months[24];
736 __tp._M_months(&__months[0]);
737 __tp._M_months_abbreviated(&__months[12]);
738 __beg = _M_extract_name(__beg, __end, __mem,
739 __months, 24, __io, __tmperr);
742 __tm->tm_mon = __mem % 12;
743 __state._M_have_mon = 1;
744 __state._M_want_xday = 1;
749 const char_type* __dt[2];
750 __tp._M_date_time_formats(__dt);
751 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
752 __tm, __dt[0], __state);
754 __state._M_want_xday = 1;
758 __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
762 __state._M_century = __mem;
763 __state._M_have_century = 1;
764 __state._M_want_xday = 1;
770 if (__ctype.is(ctype_base::space, *__beg))
772 __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
776 __tm->tm_mday = __mem;
777 __state._M_have_mday = 1;
778 __state._M_want_xday = 1;
784 __ctype.widen(__cs, __cs + 9, __wcs);
785 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
786 __tm, __wcs, __state);
788 __state._M_want_xday = 1;
792 __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
796 __tm->tm_hour = __mem;
797 __state._M_have_I = 0;
802 __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
806 __tm->tm_hour = __mem % 12;
807 __state._M_have_I = 1;
812 __beg = _M_extract_num(__beg, __end, __mem, 1, 366, 3,
816 __tm->tm_yday = __mem - 1;
817 __state._M_have_yday = 1;
822 __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
826 __tm->tm_mon = __mem - 1;
827 __state._M_have_mon = 1;
832 __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
835 __tm->tm_min = __mem;
839 while (__beg != __end
840 && __ctype.is(ctype_base::space, *__beg))
845 const char_type* __ampm[2];
846 __tp._M_am_pm(&__ampm[0]);
847 if (!__ampm[0][0] || !__ampm[1][0])
849 __beg = _M_extract_name(__beg, __end, __mem, __ampm,
851 if (!__tmperr && __mem)
852 __state._M_is_pm = 1;
856 const char_type* __ampm_format;
857 __tp._M_am_pm_format(&__ampm_format);
858 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
859 __tm, __ampm_format, __state);
864 __ctype.widen(__cs, __cs + 6, __wcs);
865 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
866 __tm, __wcs, __state);
872 __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
874 __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
878 __tm->tm_sec = __mem;
883 __ctype.widen(__cs, __cs + 9, __wcs);
884 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
885 __tm, __wcs, __state);
889 __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
893 __state._M_week_no = __mem;
894 __state._M_have_uweek = 1;
899 __beg = _M_extract_num(__beg, __end, __mem, 0, 6, 1,
903 __tm->tm_wday = __mem;
904 __state._M_have_wday = 1;
909 __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
913 __state._M_week_no = __mem;
914 __state._M_have_wweek = 1;
919 const char_type* __dates[2];
920 __tp._M_date_formats(__dates);
921 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
922 __tm, __dates[0], __state);
926 const char_type* __times[2];
927 __tp._M_time_formats(__times);
928 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
929 __tm, __times[0], __state);
933 __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
937 __state._M_want_century = 1;
938 __state._M_want_xday = 1;
943 __c = __ctype.narrow(*__beg,
'*');
944 if (__c >=
'0' && __c <=
'9')
947 __mem = __mem * 10 + (__c -
'0');
950 __c = __ctype.narrow(*__beg,
'*');
951 if (__c >=
'0' && __c <=
'9')
954 __mem = __mem * 10 + (__c -
'0');
958 __state._M_want_century = 0;
964 __tm->tm_year = __mem;
969 __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
973 __tm->tm_year = __mem - 1900;
974 __state._M_want_century = 0;
975 __state._M_want_xday = 1;
980 if (__ctype.is(ctype_base::upper, *__beg))
983 __beg = _M_extract_name(__beg, __end, __tmp,
984 __timepunct_cache<_CharT>::_S_timezones,
988 if (__beg != __end && !__tmperr && __tmp == 0
989 && (*__beg == __ctype.widen(
'-')
990 || *__beg == __ctype.widen(
'+')))
992 __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
994 __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1002 if (*__beg == __ctype.widen(
'%'))
1012 else if (__ctype.is(ctype_base::space, __format[__i]))
1015 while (__beg != __end
1016 && __ctype.is(ctype_base::space, *__beg))
1023 if (__ctype.tolower(__format[__i]) == __ctype.tolower(*__beg)
1024 || __ctype.toupper(__format[__i]) == __ctype.toupper(*__beg))
1031 if (__tmperr || __i != __len)
1037 template<
typename _CharT,
typename _InIter>
1039 time_get<_CharT, _InIter>::
1040 _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
1042 const _CharT* __format)
const
1044 __time_get_state __state = __time_get_state();
1045 return _M_extract_via_format(__beg, __end, __io, __err, __tm,
1049 template<
typename _CharT,
typename _InIter>
1051 time_get<_CharT, _InIter>::
1052 _M_extract_num(iter_type __beg, iter_type __end,
int& __member,
1053 int __min,
int __max,
size_t __len,
1056 const locale& __loc = __io._M_getloc();
1057 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1061 for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
1063 const char __c = __ctype.narrow(*__beg,
'*');
1064 if (__c >=
'0' && __c <=
'9')
1066 __value = __value * 10 + (__c -
'0');
1067 if (__value > __max)
1073 if (__i && __value >= __min && __value <= __max)
1086 template<
typename _CharT,
typename _InIter>
1088 time_get<_CharT, _InIter>::
1089 _M_extract_name(iter_type __beg, iter_type __end,
int& __member,
1090 const _CharT** __names,
size_t __indexlen,
1093 typedef char_traits<_CharT> __traits_type;
1094 const locale& __loc = __io._M_getloc();
1095 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1098 =
static_cast<size_t*
>(__builtin_alloca(2 *
sizeof(
size_t)
1100 size_t* __lengths = __matches + __indexlen;
1101 size_t __nmatches = 0;
1103 bool __testvalid =
true;
1104 const char_type* __name;
1105 bool __begupdated =
false;
1110 const char_type __c = *__beg;
1112 const char_type __cl = __ctype.tolower(__c);
1113 const char_type __cu = __ctype.toupper(__c);
1114 for (
size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1115 if (__cl == __ctype.tolower(__names[__i1][0])
1116 || __cu == __ctype.toupper(__names[__i1][0]))
1118 __lengths[__nmatches]
1119 = __traits_type::length(__names[__i1]);
1120 __matches[__nmatches++] = __i1;
1124 while (__nmatches > 1)
1127 size_t __minlen = __lengths[0];
1128 for (
size_t __i2 = 1; __i2 < __nmatches; ++__i2)
1129 __minlen =
std::min(__minlen, __lengths[__i2]);
1132 if (__pos == __minlen)
1140 bool __match_longer =
false;
1145 const char_type __cl = __ctype.tolower(*__beg);
1146 const char_type __cu = __ctype.toupper(*__beg);
1147 for (
size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1149 __name = __names[__matches[__i3]];
1150 if (__lengths[__i3] > __pos
1151 && (__ctype.tolower(__name[__pos]) == __cl
1152 || __ctype.toupper(__name[__pos]) == __cu))
1154 __match_longer =
true;
1159 for (
size_t __i4 = 0; __i4 < __nmatches;)
1160 if (__match_longer == (__lengths[__i4] == __pos))
1162 __matches[__i4] = __matches[--__nmatches];
1163 __lengths[__i4] = __lengths[__nmatches];
1169 __minlen = __lengths[0];
1170 for (
size_t __i5 = 1; __i5 < __nmatches; ++__i5)
1171 __minlen =
std::min(__minlen, __lengths[__i5]);
1177 if (__nmatches == 2 && (__indexlen & 1) == 0)
1179 if (__matches[0] < __indexlen / 2)
1181 if (__matches[1] == __matches[0] + __indexlen / 2)
1184 else if (__matches[1] == __matches[0] - __indexlen / 2)
1186 __matches[0] = __matches[1];
1187 __lengths[0] = __lengths[1];
1191 __begupdated =
true;
1195 if (__pos < __minlen && __beg != __end)
1198 const char_type __cl = __ctype.tolower(*__beg);
1199 const char_type __cu = __ctype.toupper(*__beg);
1200 for (
size_t __i6 = 0; __i6 < __nmatches;)
1202 __name = __names[__matches[__i6]];
1203 if (__ctype.tolower(__name[__pos]) != __cl
1204 && __ctype.toupper(__name[__pos]) != __cu)
1206 __matches[__i6] = __matches[--__nmatches];
1207 __lengths[__i6] = __lengths[__nmatches];
1217 if (__nmatches == 1)
1225 __name = __names[__matches[0]];
1226 const size_t __len = __lengths[0];
1227 while (__pos < __len
1230 && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
1231 || (__ctype.toupper(__name[__pos])
1232 == __ctype.toupper(*__beg))))
1233 ++__beg, (void)++__pos;
1236 __member = __matches[0];
1238 __testvalid =
false;
1241 __testvalid =
false;
1248 template<
typename _CharT,
typename _InIter>
1250 time_get<_CharT, _InIter>::
1251 _M_extract_wday_or_month(iter_type __beg, iter_type __end,
int& __member,
1252 const _CharT** __names,
size_t __indexlen,
1255 typedef char_traits<_CharT> __traits_type;
1256 const locale& __loc = __io._M_getloc();
1257 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1259 int* __matches =
static_cast<int*
>(__builtin_alloca(2 *
sizeof(
int)
1261 size_t __nmatches = 0;
1262 size_t* __matches_lengths = 0;
1267 const char_type __c = *__beg;
1268 for (
size_t __i = 0; __i < 2 * __indexlen; ++__i)
1269 if (__c == __names[__i][0]
1270 || __c == __ctype.toupper(__names[__i][0]))
1271 __matches[__nmatches++] = __i;
1280 =
static_cast<size_t*
>(__builtin_alloca(
sizeof(
size_t)
1282 for (
size_t __i = 0; __i < __nmatches; ++__i)
1283 __matches_lengths[__i]
1284 = __traits_type::length(__names[__matches[__i]]);
1287 for (; __beg != __end; ++__beg, (void)++__pos)
1289 size_t __nskipped = 0;
1290 const char_type __c = *__beg;
1291 for (
size_t __i = 0; __i < __nmatches;)
1293 const char_type* __name = __names[__matches[__i]];
1294 if (__pos >= __matches_lengths[__i])
1295 ++__nskipped, ++__i;
1296 else if (!(__name[__pos] == __c))
1299 __matches[__i] = __matches[__nmatches];
1300 __matches_lengths[__i] = __matches_lengths[__nmatches];
1305 if (__nskipped == __nmatches)
1309 if ((__nmatches == 1 && __matches_lengths[0] == __pos)
1310 || (__nmatches == 2 && (__matches_lengths[0] == __pos
1311 || __matches_lengths[1] == __pos)))
1312 __member = (__matches[0] >= (
int)__indexlen
1313 ? __matches[0] - (int)__indexlen : __matches[0]);
1320 template<
typename _CharT,
typename _InIter>
1324 ios_base::iostate& __err, tm* __tm)
const
1327 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1329 __tp._M_time_formats(__times);
1330 __time_get_state __state = __time_get_state();
1331 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1332 __tm, __times[0], __state);
1333 __state._M_finalize_state(__tm);
1339 template<
typename _CharT,
typename _InIter>
1343 ios_base::iostate& __err, tm* __tm)
const
1346 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1348 __tp._M_date_formats(__dates);
1349 __time_get_state __state = __time_get_state();
1350 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1351 __tm, __dates[0], __state);
1352 __state._M_finalize_state(__tm);
1358 template<
typename _CharT,
typename _InIter>
1362 ios_base::iostate& __err, tm* __tm)
const
1365 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1367 __tp._M_days_abbreviated(__days);
1368 __tp._M_days(__days + 7);
1372 __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
1375 __tm->tm_wday = __tmpwday;
1384 template<
typename _CharT,
typename _InIter>
1388 ios_base& __io, ios_base::iostate& __err, tm* __tm)
const
1391 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1393 __tp._M_months_abbreviated(__months);
1394 __tp._M_months(__months + 12);
1398 __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
1401 __tm->tm_mon = __tmpmon;
1410 template<
typename _CharT,
typename _InIter>
1414 ios_base::iostate& __err, tm* __tm)
const
1419 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1421 __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2,
1427 __c = __ctype.
narrow(*__beg,
'*');
1431 if (__c >=
'0' && __c <=
'9')
1434 __tmpyear = __tmpyear * 10 + (__c -
'0');
1437 __c = __ctype.
narrow(*__beg,
'*');
1438 if (__c >=
'0' && __c <=
'9')
1441 __tmpyear = __tmpyear * 10 + (__c -
'0');
1446 else if (__tmpyear < 69)
1448 __tm->tm_year = __tmpyear;
1458 #if __cplusplus >= 201103L
1459 template<
typename _CharT,
typename _InIter>
1464 ios_base::iostate& __err, tm* __tm,
const char_type* __fmt,
1468 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1470 bool __use_state =
false;
1472 #pragma GCC diagnostic push
1473 #pragma GCC diagnostic ignored "-Wpmf-conversions"
1482 #pragma GCC diagnostic pop
1484 __time_get_state __state = __time_get_state();
1485 while (__fmt != __fmtend &&
1493 else if (__ctype.
narrow(*__fmt, 0) ==
'%')
1498 if (++__fmt == __fmtend)
1503 const char __c = __ctype.
narrow(*__fmt, 0);
1504 if (__c !=
'E' && __c !=
'O')
1506 else if (++__fmt != __fmtend)
1509 __format = __ctype.
narrow(*__fmt, 0);
1519 __new_fmt[0] = __fmt_start[0];
1520 __new_fmt[1] = __fmt_start[1];
1523 __new_fmt[2] = __fmt_start[2];
1528 __s = _M_extract_via_format(__s, __end, __io, __err, __tm,
1529 __new_fmt, __state);
1534 __s = this->do_get(__s, __end, __io, __err, __tm, __format,
1538 else if (__ctype.
is(ctype_base::space, *__fmt))
1541 while (__fmt != __fmtend &&
1542 __ctype.
is(ctype_base::space, *__fmt))
1545 while (__s != __end &&
1546 __ctype.
is(ctype_base::space, *__s))
1563 __state._M_finalize_state(__tm);
1567 template<
typename _CharT,
typename _InIter>
1572 ios_base::iostate& __err, tm* __tm,
1573 char __format,
char __mod)
const
1576 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1580 __fmt[0] = __ctype.
widen(
'%');
1583 __fmt[1] = __format;
1589 __fmt[2] = __format;
1593 __time_get_state __state = __time_get_state();
1594 __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt,
1596 __state._M_finalize_state(__tm);
1604 template<
typename _CharT,
typename _OutIter>
1608 const _CharT* __beg,
const _CharT* __end)
const
1611 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1612 for (; __beg != __end; ++__beg)
1613 if (__ctype.
narrow(*__beg, 0) !=
'%')
1618 else if (++__beg != __end)
1622 const char __c = __ctype.
narrow(*__beg, 0);
1623 if (__c !=
'E' && __c !=
'O')
1625 else if (++__beg != __end)
1628 __format = __ctype.
narrow(*__beg, 0);
1632 __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
1639 template<
typename _CharT,
typename _OutIter>
1643 char __format,
char __mod)
const
1646 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1647 __timepunct<_CharT>
const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1651 const size_t __maxlen = 128;
1660 __fmt[0] = __ctype.
widen(
'%');
1663 __fmt[1] = __format;
1669 __fmt[2] = __format;
1673 __tp._M_put(__res, __maxlen, __fmt, __tm);
1682 #if _GLIBCXX_EXTERN_TEMPLATE
1687 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_get<char>;
1688 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_put<char>;
1689 extern template class __timepunct<char>;
1699 use_facet<moneypunct<char, true> >(
const locale&);
1703 use_facet<moneypunct<char, false> >(
const locale&);
1707 use_facet<money_put<char> >(
const locale&);
1711 use_facet<money_get<char> >(
const locale&);
1714 const __timepunct<char>&
1715 use_facet<__timepunct<char> >(
const locale&);
1719 use_facet<time_put<char> >(
const locale&);
1723 use_facet<time_get<char> >(
const locale&);
1727 use_facet<messages<char> >(
const locale&);
1731 has_facet<moneypunct<char> >(
const locale&);
1735 has_facet<money_put<char> >(
const locale&);
1739 has_facet<money_get<char> >(
const locale&);
1743 has_facet<__timepunct<char> >(
const locale&);
1747 has_facet<time_put<char> >(
const locale&);
1751 has_facet<time_get<char> >(
const locale&);
1755 has_facet<messages<char> >(
const locale&);
1757 #ifdef _GLIBCXX_USE_WCHAR_T
1764 extern template class __timepunct<wchar_t>;
1774 use_facet<moneypunct<wchar_t, true> >(
const locale&);
1778 use_facet<moneypunct<wchar_t, false> >(
const locale&);
1782 use_facet<money_put<wchar_t> >(
const locale&);
1786 use_facet<money_get<wchar_t> >(
const locale&);
1789 const __timepunct<wchar_t>&
1790 use_facet<__timepunct<wchar_t> >(
const locale&);
1794 use_facet<time_put<wchar_t> >(
const locale&);
1798 use_facet<time_get<wchar_t> >(
const locale&);
1802 use_facet<messages<wchar_t> >(
const locale&);
1806 has_facet<moneypunct<wchar_t> >(
const locale&);
1810 has_facet<money_put<wchar_t> >(
const locale&);
1814 has_facet<money_get<wchar_t> >(
const locale&);
1818 has_facet<__timepunct<wchar_t> >(
const locale&);
1822 has_facet<time_put<wchar_t> >(
const locale&);
1826 has_facet<time_get<wchar_t> >(
const locale&);
1830 has_facet<messages<wchar_t> >(
const locale&);
1834 _GLIBCXX_END_NAMESPACE_VERSION
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
Basis for explicit traits specializations.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
static const size_type npos
Value returned by various member functions when they fail.
The base of the I/O class hierarchy.
_Ios_Fmtflags fmtflags
This is a bitmask type.
_Ios_Iostate iostate
This is a bitmask type.
const locale & _M_getloc() const
Locale access.
static const fmtflags showbase
Generates a prefix indicating the numeric base of generated integer output.
static const fmtflags internal
Adds fill characters at a designated internal point in certain generated output, or identical to righ...
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
static const iostate goodbit
Indicates all is well.
static const fmtflags left
Adds fill characters on the right (final positions) of certain generated output. (I....
locale getloc() const
Locale access.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
static const fmtflags adjustfield
A mask of left|right|internal. Useful for the 2-arg form of setf.
Container class for localization functionality.
char_type tolower(char_type __c) const
Convert to lowercase.
char_type toupper(char_type __c) const
Convert to uppercase.
char_type widen(char __c) const
Widen char to char_type.
char narrow(char_type __c, char __dfault) const
Narrow char_type to char.
bool is(mask __m, char_type __c) const
Test char_type classification.
Primary class template ctype facet.
Primary class template time_get.
virtual iter_type do_get_year(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) const
Parse input year string.
_InIter iter_type
Public typedefs.
virtual iter_type do_get_weekday(iter_type __beg, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__tm) const
Parse input weekday string.
virtual iter_type do_get_monthname(iter_type __beg, iter_type __end, ios_base &, ios_base::iostate &__err, tm *__tm) const
Parse input month string.
_CharT char_type
Public typedefs.
iter_type do_get(iter_type __s, iter_type __end, ios_base &__f, ios_base::iostate &__err, tm *__tm, char __format, char __modifier) const
Parse input string according to format.
iter_type get(iter_type __s, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm, char __format, char __modifier=0) const
Parse input string according to format.
virtual dateorder do_date_order() const
Return preferred order of month, day, and year.
virtual iter_type do_get_date(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) const
Parse input date string.
virtual iter_type do_get_time(iter_type __beg, iter_type __end, ios_base &__io, ios_base::iostate &__err, tm *__tm) const
Parse input time string.
class time_get_byname [22.2.5.2].
Primary class template time_put.
virtual iter_type do_put(iter_type __s, ios_base &__io, char_type __fill, const tm *__tm, char __format, char __mod) const
Format and output a time or date.
_CharT char_type
Public typedefs.
iter_type put(iter_type __s, ios_base &__io, char_type __fill, const tm *__tm, const _CharT *__beg, const _CharT *__end) const
Format and output a time or date.
_OutIter iter_type
Public typedefs.
class time_put_byname [22.2.5.4].
Primary class template moneypunct.
static locale::id id
Numpunct facet id.
class moneypunct_byname [22.2.6.4].
Primary class template money_get.
virtual iter_type do_get(iter_type __s, iter_type __end, bool __intl, ios_base &__io, ios_base::iostate &__err, long double &__units) const
Read and parse a monetary value.
_InIter iter_type
Public typedefs.
Primary class template money_put.
virtual iter_type do_put(iter_type __s, bool __intl, ios_base &__io, char_type __fill, long double __units) const
Format and output a monetary value.
_OutIter iter_type
Public typedefs.
_CharT char_type
Public typedefs.
Primary class template messages.
class messages_byname [22.2.7.2].