30#ifndef _LOCALE_FACETS_NONIO_TCC
31#define _LOCALE_FACETS_NONIO_TCC 1
33#pragma GCC system_header
35namespace 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);
80 _Scoped_str(
const basic_string<_CharT>& __str)
81 : _M_len(__str.size()), _M_str(new _CharT[_M_len])
82 { __str.copy(_M_str, _M_len); }
84 ~_Scoped_str() {
delete[] _M_str; }
87 _M_release(
const _CharT*& __p,
size_t& __n)
95 _Scoped_str __curr_symbol(__mp.curr_symbol());
96 _Scoped_str __positive_sign(__mp.positive_sign());
97 _Scoped_str __negative_sign(__mp.negative_sign());
99 const string& __g = __mp.grouping();
100 const size_t __g_size = __g.size();
101 char*
const __grouping =
new char[__g_size];
102 __g.copy(__grouping, __g_size);
106 _M_grouping = __grouping;
107 _M_grouping_size = __g_size;
108 _M_use_grouping = (__g_size
109 &&
static_cast<signed char>(__grouping[0]) > 0
111 != __gnu_cxx::__numeric_traits<char>::__max));
113 _M_decimal_point = __mp.decimal_point();
114 _M_thousands_sep = __mp.thousands_sep();
116 __curr_symbol._M_release(_M_curr_symbol, _M_curr_symbol_size);
117 __positive_sign._M_release(_M_positive_sign, _M_positive_sign_size);
118 __negative_sign._M_release(_M_negative_sign, _M_negative_sign_size);
120 _M_frac_digits = __mp.frac_digits();
121 _M_pos_format = __mp.pos_format();
122 _M_neg_format = __mp.neg_format();
124 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
125 __ct.widen(money_base::_S_atoms,
126 money_base::_S_atoms + money_base::_S_end, _M_atoms);
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__
639__typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 __asm__(
"snprintf");
641 template<
typename _CharT,
typename _OutIter>
645 __ibm128 __units)
const
648 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
651 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
652 const __c_locale __old = __gnu_cxx::__uselocale(_S_get_c_locale());
656 int __len = __glibcxx_snprintfibm128(__cs, __cs_size,
"%.*Lf", 0,
659 if (__len >= __cs_size)
661 __cs_size = __len + 1;
662 __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
663 __len = __glibcxx_snprintfibm128(__cs, __cs_size,
"%.*Lf", 0,
666 __gnu_cxx::__uselocale(__old);
667 string_type __digits(__len, char_type());
668 __ctype.
widen(__cs, __cs + __len, &__digits[0]);
669 return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
670 : _M_insert<false>(__s, __io, __fill, __digits);
674_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
679 template<
typename _CharT,
typename _InIter>
682 {
return time_base::no_order; }
686 template<
typename _CharT,
typename _InIter>
690 ios_base::iostate& __err, tm* __tm,
691 const _CharT* __format,
692 __time_get_state &__state)
const
695 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
696 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
701 for (; __beg != __end && __i < __len && !__tmperr; ++__i)
703 if (__ctype.narrow(__format[__i], 0) ==
'%')
706 char __c = __ctype.narrow(__format[++__i], 0);
708 if (__c ==
'E' || __c ==
'O')
709 __c = __ctype.narrow(__format[++__i], 0);
717 const char_type* __days[14];
718 __tp._M_days(&__days[0]);
719 __tp._M_days_abbreviated(&__days[7]);
720 __beg = _M_extract_name(__beg, __end, __mem, __days,
724 __tm->tm_wday = __mem % 7;
725 __state._M_have_wday = 1;
732 const char_type* __months[24];
733 __tp._M_months(&__months[0]);
734 __tp._M_months_abbreviated(&__months[12]);
735 __beg = _M_extract_name(__beg, __end, __mem,
736 __months, 24, __io, __tmperr);
739 __tm->tm_mon = __mem % 12;
740 __state._M_have_mon = 1;
741 __state._M_want_xday = 1;
746 const char_type* __dt[2];
747 __tp._M_date_time_formats(__dt);
748 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
749 __tm, __dt[0], __state);
751 __state._M_want_xday = 1;
755 __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
759 __state._M_century = __mem;
760 __state._M_have_century = 1;
761 __state._M_want_xday = 1;
767 if (__ctype.is(ctype_base::space, *__beg))
769 __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
773 __tm->tm_mday = __mem;
774 __state._M_have_mday = 1;
775 __state._M_want_xday = 1;
781 __ctype.widen(__cs, __cs + 9, __wcs);
782 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
783 __tm, __wcs, __state);
785 __state._M_want_xday = 1;
789 __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
793 __tm->tm_hour = __mem;
794 __state._M_have_I = 0;
799 __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
803 __tm->tm_hour = __mem % 12;
804 __state._M_have_I = 1;
809 __beg = _M_extract_num(__beg, __end, __mem, 1, 366, 3,
813 __tm->tm_yday = __mem - 1;
814 __state._M_have_yday = 1;
819 __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
823 __tm->tm_mon = __mem - 1;
824 __state._M_have_mon = 1;
829 __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
832 __tm->tm_min = __mem;
836 while (__beg != __end
837 && __ctype.is(ctype_base::space, *__beg))
842 const char_type* __ampm[2];
843 __tp._M_am_pm(&__ampm[0]);
844 if (!__ampm[0][0] || !__ampm[1][0])
846 __beg = _M_extract_name(__beg, __end, __mem, __ampm,
848 if (!__tmperr && __mem)
849 __state._M_is_pm = 1;
853 const char_type* __ampm_format;
854 __tp._M_am_pm_format(&__ampm_format);
855 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
856 __tm, __ampm_format, __state);
861 __ctype.widen(__cs, __cs + 6, __wcs);
862 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
863 __tm, __wcs, __state);
869 __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
871 __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
875 __tm->tm_sec = __mem;
880 __ctype.widen(__cs, __cs + 9, __wcs);
881 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
882 __tm, __wcs, __state);
886 __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
890 __state._M_week_no = __mem;
891 __state._M_have_uweek = 1;
896 __beg = _M_extract_num(__beg, __end, __mem, 0, 6, 1,
900 __tm->tm_wday = __mem;
901 __state._M_have_wday = 1;
906 __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
910 __state._M_week_no = __mem;
911 __state._M_have_wweek = 1;
916 const char_type* __dates[2];
917 __tp._M_date_formats(__dates);
918 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
919 __tm, __dates[0], __state);
923 const char_type* __times[2];
924 __tp._M_time_formats(__times);
925 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
926 __tm, __times[0], __state);
930 __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
934 __state._M_want_century = 1;
935 __state._M_want_xday = 1;
940 __c = __ctype.narrow(*__beg,
'*');
941 if (__c >=
'0' && __c <=
'9')
944 __mem = __mem * 10 + (__c -
'0');
947 __c = __ctype.narrow(*__beg,
'*');
948 if (__c >=
'0' && __c <=
'9')
951 __mem = __mem * 10 + (__c -
'0');
955 __state._M_want_century = 0;
961 __tm->tm_year = __mem;
966 __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
970 __tm->tm_year = __mem - 1900;
971 __state._M_want_century = 0;
972 __state._M_want_xday = 1;
977 if (__ctype.is(ctype_base::upper, *__beg))
980 __beg = _M_extract_name(__beg, __end, __tmp,
981 __timepunct_cache<_CharT>::_S_timezones,
985 if (__beg != __end && !__tmperr && __tmp == 0
986 && (*__beg == __ctype.widen(
'-')
987 || *__beg == __ctype.widen(
'+')))
989 __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
991 __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
999 if (*__beg == __ctype.widen(
'%'))
1009 else if (__ctype.is(ctype_base::space, __format[__i]))
1012 while (__beg != __end
1013 && __ctype.is(ctype_base::space, *__beg))
1020 if (__ctype.tolower(__format[__i]) == __ctype.tolower(*__beg)
1021 || __ctype.toupper(__format[__i]) == __ctype.toupper(*__beg))
1028 if (__tmperr || __i != __len)
1034 template<
typename _CharT,
typename _InIter>
1036 time_get<_CharT, _InIter>::
1037 _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
1039 const _CharT* __format)
const
1041 __time_get_state __state = __time_get_state();
1042 return _M_extract_via_format(__beg, __end, __io, __err, __tm,
1046 template<
typename _CharT,
typename _InIter>
1048 time_get<_CharT, _InIter>::
1049 _M_extract_num(iter_type __beg, iter_type __end,
int& __member,
1050 int __min,
int __max,
size_t __len,
1053 const locale& __loc = __io._M_getloc();
1054 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1058 for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
1060 const char __c = __ctype.narrow(*__beg,
'*');
1061 if (__c >=
'0' && __c <=
'9')
1063 __value = __value * 10 + (__c -
'0');
1064 if (__value > __max)
1070 if (__i && __value >= __min && __value <= __max)
1083 template<
typename _CharT,
typename _InIter>
1085 time_get<_CharT, _InIter>::
1086 _M_extract_name(iter_type __beg, iter_type __end,
int& __member,
1087 const _CharT** __names,
size_t __indexlen,
1090 typedef char_traits<_CharT> __traits_type;
1091 const locale& __loc = __io._M_getloc();
1092 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1095 =
static_cast<size_t*
>(__builtin_alloca(2 *
sizeof(
size_t)
1097 size_t* __lengths = __matches + __indexlen;
1098 size_t __nmatches = 0;
1100 bool __testvalid =
true;
1101 const char_type* __name;
1102 bool __begupdated =
false;
1107 const char_type __c = *__beg;
1109 const char_type __cl = __ctype.tolower(__c);
1110 const char_type __cu = __ctype.toupper(__c);
1111 for (
size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1112 if (__cl == __ctype.tolower(__names[__i1][0])
1113 || __cu == __ctype.toupper(__names[__i1][0]))
1115 __lengths[__nmatches]
1116 = __traits_type::length(__names[__i1]);
1117 __matches[__nmatches++] = __i1;
1121 while (__nmatches > 1)
1124 size_t __minlen = __lengths[0];
1125 for (
size_t __i2 = 1; __i2 < __nmatches; ++__i2)
1126 __minlen =
std::min(__minlen, __lengths[__i2]);
1129 if (__pos == __minlen)
1137 bool __match_longer =
false;
1142 const char_type __cl = __ctype.tolower(*__beg);
1143 const char_type __cu = __ctype.toupper(*__beg);
1144 for (
size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1146 __name = __names[__matches[__i3]];
1147 if (__lengths[__i3] > __pos
1148 && (__ctype.tolower(__name[__pos]) == __cl
1149 || __ctype.toupper(__name[__pos]) == __cu))
1151 __match_longer =
true;
1156 for (
size_t __i4 = 0; __i4 < __nmatches;)
1157 if (__match_longer == (__lengths[__i4] == __pos))
1159 __matches[__i4] = __matches[--__nmatches];
1160 __lengths[__i4] = __lengths[__nmatches];
1166 __minlen = __lengths[0];
1167 for (
size_t __i5 = 1; __i5 < __nmatches; ++__i5)
1168 __minlen =
std::min(__minlen, __lengths[__i5]);
1174 if (__nmatches == 2 && (__indexlen & 1) == 0)
1176 if (__matches[0] < __indexlen / 2)
1178 if (__matches[1] == __matches[0] + __indexlen / 2)
1181 else if (__matches[1] == __matches[0] - __indexlen / 2)
1183 __matches[0] = __matches[1];
1184 __lengths[0] = __lengths[1];
1188 __begupdated =
true;
1192 if (__pos < __minlen && __beg != __end)
1195 const char_type __cl = __ctype.tolower(*__beg);
1196 const char_type __cu = __ctype.toupper(*__beg);
1197 for (
size_t __i6 = 0; __i6 < __nmatches;)
1199 __name = __names[__matches[__i6]];
1200 if (__ctype.tolower(__name[__pos]) != __cl
1201 && __ctype.toupper(__name[__pos]) != __cu)
1203 __matches[__i6] = __matches[--__nmatches];
1204 __lengths[__i6] = __lengths[__nmatches];
1214 if (__nmatches == 1)
1222 __name = __names[__matches[0]];
1223 const size_t __len = __lengths[0];
1224 while (__pos < __len
1227 && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
1228 || (__ctype.toupper(__name[__pos])
1229 == __ctype.toupper(*__beg))))
1230 ++__beg, (void)++__pos;
1233 __member = __matches[0];
1235 __testvalid =
false;
1238 __testvalid =
false;
1245 template<
typename _CharT,
typename _InIter>
1247 time_get<_CharT, _InIter>::
1248 _M_extract_wday_or_month(iter_type __beg, iter_type __end,
int& __member,
1249 const _CharT** __names,
size_t __indexlen,
1252 typedef char_traits<_CharT> __traits_type;
1253 const locale& __loc = __io._M_getloc();
1254 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1256 int* __matches =
static_cast<int*
>(__builtin_alloca(2 *
sizeof(
int)
1258 size_t __nmatches = 0;
1259 size_t* __matches_lengths = 0;
1264 const char_type __c = *__beg;
1265 for (
size_t __i = 0; __i < 2 * __indexlen; ++__i)
1266 if (__c == __names[__i][0]
1267 || __c == __ctype.toupper(__names[__i][0]))
1268 __matches[__nmatches++] = __i;
1277 =
static_cast<size_t*
>(__builtin_alloca(
sizeof(
size_t)
1279 for (
size_t __i = 0; __i < __nmatches; ++__i)
1280 __matches_lengths[__i]
1281 = __traits_type::length(__names[__matches[__i]]);
1284 for (; __beg != __end; ++__beg, (void)++__pos)
1286 size_t __nskipped = 0;
1287 const char_type __c = *__beg;
1288 for (
size_t __i = 0; __i < __nmatches;)
1290 const char_type* __name = __names[__matches[__i]];
1291 if (__pos >= __matches_lengths[__i])
1292 ++__nskipped, ++__i;
1293 else if (!(__name[__pos] == __c))
1296 __matches[__i] = __matches[__nmatches];
1297 __matches_lengths[__i] = __matches_lengths[__nmatches];
1302 if (__nskipped == __nmatches)
1306 if ((__nmatches == 1 && __matches_lengths[0] == __pos)
1307 || (__nmatches == 2 && (__matches_lengths[0] == __pos
1308 || __matches_lengths[1] == __pos)))
1309 __member = (__matches[0] >= (
int)__indexlen
1310 ? __matches[0] - (int)__indexlen : __matches[0]);
1317 template<
typename _CharT,
typename _InIter>
1321 ios_base::iostate& __err, tm* __tm)
const
1324 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1326 __tp._M_time_formats(__times);
1327 __time_get_state __state = __time_get_state();
1328 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1329 __tm, __times[0], __state);
1330 __state._M_finalize_state(__tm);
1336 template<
typename _CharT,
typename _InIter>
1340 ios_base::iostate& __err, tm* __tm)
const
1343 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1345 __tp._M_date_formats(__dates);
1346 __time_get_state __state = __time_get_state();
1347 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1348 __tm, __dates[0], __state);
1349 __state._M_finalize_state(__tm);
1355 template<
typename _CharT,
typename _InIter>
1359 ios_base::iostate& __err, tm* __tm)
const
1362 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1364 __tp._M_days_abbreviated(__days);
1365 __tp._M_days(__days + 7);
1369 __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
1372 __tm->tm_wday = __tmpwday;
1381 template<
typename _CharT,
typename _InIter>
1385 ios_base& __io, ios_base::iostate& __err, tm* __tm)
const
1388 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1390 __tp._M_months_abbreviated(__months);
1391 __tp._M_months(__months + 12);
1395 __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
1398 __tm->tm_mon = __tmpmon;
1407 template<
typename _CharT,
typename _InIter>
1411 ios_base::iostate& __err, tm* __tm)
const
1416 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1418 __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2,
1424 __c = __ctype.
narrow(*__beg,
'*');
1428 if (__c >=
'0' && __c <=
'9')
1431 __tmpyear = __tmpyear * 10 + (__c -
'0');
1434 __c = __ctype.
narrow(*__beg,
'*');
1435 if (__c >=
'0' && __c <=
'9')
1438 __tmpyear = __tmpyear * 10 + (__c -
'0');
1443 else if (__tmpyear < 69)
1445 __tm->tm_year = __tmpyear;
1455#if __cplusplus >= 201103L
1456 template<
typename _CharT,
typename _InIter>
1461 ios_base::iostate& __err, tm* __tm,
const char_type* __fmt,
1465 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1467 bool __use_state =
false;
1468#if __GNUC__ >= 5 && !defined(__clang__)
1469#pragma GCC diagnostic push
1470#pragma GCC diagnostic ignored "-Wpmf-conversions"
1479#pragma GCC diagnostic pop
1481 __time_get_state __state = __time_get_state();
1482 while (__fmt != __fmtend &&
1490 else if (__ctype.
narrow(*__fmt, 0) ==
'%')
1495 if (++__fmt == __fmtend)
1500 const char __c = __ctype.
narrow(*__fmt, 0);
1501 if (__c !=
'E' && __c !=
'O')
1503 else if (++__fmt != __fmtend)
1506 __format = __ctype.
narrow(*__fmt, 0);
1516 __new_fmt[0] = __fmt_start[0];
1517 __new_fmt[1] = __fmt_start[1];
1520 __new_fmt[2] = __fmt_start[2];
1525 __s = _M_extract_via_format(__s, __end, __io, __err, __tm,
1526 __new_fmt, __state);
1531 __s = this->do_get(__s, __end, __io, __err, __tm, __format,
1535 else if (__ctype.
is(ctype_base::space, *__fmt))
1538 while (__fmt != __fmtend &&
1539 __ctype.
is(ctype_base::space, *__fmt))
1542 while (__s != __end &&
1543 __ctype.
is(ctype_base::space, *__s))
1560 __state._M_finalize_state(__tm);
1564 template<
typename _CharT,
typename _InIter>
1569 ios_base::iostate& __err, tm* __tm,
1570 char __format,
char __mod)
const
1573 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1577 __fmt[0] = __ctype.
widen(
'%');
1580 __fmt[1] = __format;
1586 __fmt[2] = __format;
1590 __time_get_state __state = __time_get_state();
1591 __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt,
1593 __state._M_finalize_state(__tm);
1601 template<
typename _CharT,
typename _OutIter>
1605 const _CharT* __beg,
const _CharT* __end)
const
1608 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1609 for (; __beg != __end; ++__beg)
1610 if (__ctype.
narrow(*__beg, 0) !=
'%')
1615 else if (++__beg != __end)
1619 const char __c = __ctype.
narrow(*__beg, 0);
1620 if (__c !=
'E' && __c !=
'O')
1622 else if (++__beg != __end)
1625 __format = __ctype.
narrow(*__beg, 0);
1629 __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
1636 template<
typename _CharT,
typename _OutIter>
1640 char __format,
char __mod)
const
1643 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1644 __timepunct<_CharT>
const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1648 const size_t __maxlen = 128;
1657 __fmt[0] = __ctype.
widen(
'%');
1660 __fmt[1] = __format;
1666 __fmt[2] = __format;
1670 __tp._M_put(__res, __maxlen, __fmt, __tm);
1679#if _GLIBCXX_EXTERN_TEMPLATE
1684 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_get<char>;
1685 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_put<char>;
1686 extern template class __timepunct<char>;
1696 use_facet<moneypunct<char, true> >(
const locale&);
1700 use_facet<moneypunct<char, false> >(
const locale&);
1704 use_facet<money_put<char> >(
const locale&);
1708 use_facet<money_get<char> >(
const locale&);
1711 const __timepunct<char>&
1712 use_facet<__timepunct<char> >(
const locale&);
1716 use_facet<time_put<char> >(
const locale&);
1720 use_facet<time_get<char> >(
const locale&);
1724 use_facet<messages<char> >(
const locale&);
1728 has_facet<moneypunct<char> >(
const locale&);
1732 has_facet<money_put<char> >(
const locale&);
1736 has_facet<money_get<char> >(
const locale&);
1740 has_facet<__timepunct<char> >(
const locale&);
1744 has_facet<time_put<char> >(
const locale&);
1748 has_facet<time_get<char> >(
const locale&);
1752 has_facet<messages<char> >(
const locale&);
1754#ifdef _GLIBCXX_USE_WCHAR_T
1761 extern template class __timepunct<wchar_t>;
1771 use_facet<moneypunct<wchar_t, true> >(
const locale&);
1775 use_facet<moneypunct<wchar_t, false> >(
const locale&);
1779 use_facet<money_put<wchar_t> >(
const locale&);
1783 use_facet<money_get<wchar_t> >(
const locale&);
1786 const __timepunct<wchar_t>&
1787 use_facet<__timepunct<wchar_t> >(
const locale&);
1791 use_facet<time_put<wchar_t> >(
const locale&);
1795 use_facet<time_get<wchar_t> >(
const locale&);
1799 use_facet<messages<wchar_t> >(
const locale&);
1803 has_facet<moneypunct<wchar_t> >(
const locale&);
1807 has_facet<money_put<wchar_t> >(
const locale&);
1811 has_facet<money_get<wchar_t> >(
const locale&);
1815 has_facet<__timepunct<wchar_t> >(
const locale&);
1819 has_facet<time_put<wchar_t> >(
const locale&);
1823 has_facet<time_get<wchar_t> >(
const locale&);
1827 has_facet<messages<wchar_t> >(
const locale&);
1831_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.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
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.
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.
const locale & _M_getloc() const
Locale access.
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].