30 #ifndef _LOCALE_FACETS_NONIO_TCC
31 #define _LOCALE_FACETS_NONIO_TCC 1
33 #ifdef _GLIBCXX_SYSHDR
34 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
41 template<
typename _CharT,
bool _Intl>
42 struct __use_cache<__moneypunct_cache<_CharT, _Intl> >
44 const __moneypunct_cache<_CharT, _Intl>*
45 operator() (
const locale& __loc)
const
48 const locale::facet** __caches = __loc._M_impl->_M_caches;
51 __moneypunct_cache<_CharT, _Intl>* __tmp = 0;
54 __tmp =
new __moneypunct_cache<_CharT, _Intl>;
55 __tmp->_M_cache(__loc);
60 __throw_exception_again;
62 __loc._M_impl->_M_install_cache(__tmp, __i);
65 const __moneypunct_cache<_CharT, _Intl>*
>(__caches[__i]);
69 template<
typename _CharT,
bool _Intl>
71 __moneypunct_cache<_CharT, _Intl>::_M_cache(
const locale& __loc)
73 const moneypunct<_CharT, _Intl>& __mp =
74 use_facet<moneypunct<_CharT, _Intl> >(__loc);
82 _Scoped_str(
const basic_string<_CharT>& __str)
83 : _M_len(__str.
size()), _M_str(new _CharT[_M_len])
84 { __str.copy(_M_str, _M_len); }
86 ~_Scoped_str() {
delete[] _M_str; }
89 _M_release(
const _CharT*& __p,
size_t& __n)
97 _Scoped_str __curr_symbol(__mp.curr_symbol());
98 _Scoped_str __positive_sign(__mp.positive_sign());
99 _Scoped_str __negative_sign(__mp.negative_sign());
101 const string& __g = __mp.grouping();
102 const size_t __g_size = __g.size();
103 char*
const __grouping =
new char[__g_size];
104 __g.copy(__grouping, __g_size);
108 _M_grouping = __grouping;
109 _M_grouping_size = __g_size;
110 _M_use_grouping = (__g_size
111 &&
static_cast<signed char>(__grouping[0]) > 0
113 != __gnu_cxx::__numeric_traits<char>::__max));
115 _M_decimal_point = __mp.decimal_point();
116 _M_thousands_sep = __mp.thousands_sep();
118 __curr_symbol._M_release(_M_curr_symbol, _M_curr_symbol_size);
119 __positive_sign._M_release(_M_positive_sign, _M_positive_sign_size);
120 __negative_sign._M_release(_M_negative_sign, _M_negative_sign_size);
122 _M_frac_digits = __mp.frac_digits();
123 _M_pos_format = __mp.pos_format();
124 _M_neg_format = __mp.neg_format();
126 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
127 __ct.widen(money_base::_S_atoms,
128 money_base::_S_atoms + money_base::_S_end, _M_atoms);
133 _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
135 template<
typename _CharT,
typename _InIter>
138 money_get<_CharT, _InIter>::
139 _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
142 typedef char_traits<_CharT> __traits_type;
143 typedef typename string_type::size_type size_type;
144 typedef money_base::part part;
145 typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
147 const locale& __loc = __io._M_getloc();
148 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
150 __use_cache<__cache_type> __uc;
151 const __cache_type* __lc = __uc(__loc);
152 const char_type* __lit = __lc->_M_atoms;
155 bool __negative =
false;
157 size_type __sign_size = 0;
159 const bool __mandatory_sign = (__lc->_M_positive_sign_size
160 && __lc->_M_negative_sign_size);
162 string __grouping_tmp;
163 if (__lc->_M_use_grouping)
164 __grouping_tmp.reserve(32);
170 bool __testvalid =
true;
172 bool __testdecfound =
false;
178 const char_type* __lit_zero = __lit + money_base::_S_zero;
179 const money_base::pattern __p = __lc->_M_neg_format;
180 for (
int __i = 0; __i < 4 && __testvalid; ++__i)
182 const part __which =
static_cast<part
>(__p.field[__i]);
185 case money_base::symbol:
192 || (__i == 1 && (__mandatory_sign
193 || (
static_cast<part
>(__p.field[0])
195 || (
static_cast<part
>(__p.field[2])
196 == money_base::space)))
197 || (__i == 2 && ((
static_cast<part
>(__p.field[3])
198 == money_base::value)
200 && (
static_cast<part
>(__p.field[3])
201 == money_base::sign)))))
203 const size_type __len = __lc->_M_curr_symbol_size;
205 for (; __beg != __end && __j < __len
206 && *__beg == __lc->_M_curr_symbol[__j];
207 ++__beg, (void)++__j);
213 case money_base::sign:
215 if (__lc->_M_positive_sign_size && __beg != __end
216 && *__beg == __lc->_M_positive_sign[0])
218 __sign_size = __lc->_M_positive_sign_size;
221 else if (__lc->_M_negative_sign_size && __beg != __end
222 && *__beg == __lc->_M_negative_sign[0])
225 __sign_size = __lc->_M_negative_sign_size;
228 else if (__lc->_M_positive_sign_size
229 && !__lc->_M_negative_sign_size)
233 else if (__mandatory_sign)
236 case money_base::value:
239 for (; __beg != __end; ++__beg)
241 const char_type __c = *__beg;
242 const char_type* __q = __traits_type::find(__lit_zero,
246 __res += money_base::_S_atoms[__q - __lit];
249 else if (__c == __lc->_M_decimal_point
252 if (__lc->_M_frac_digits <= 0)
257 __testdecfound =
true;
259 else if (__lc->_M_use_grouping
260 && __c == __lc->_M_thousands_sep
266 __grouping_tmp +=
static_cast<char>(__n);
281 case money_base::space:
283 if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
288 case money_base::none:
291 for (; __beg != __end
292 && __ctype.is(ctype_base::space, *__beg); ++__beg);
298 if (__sign_size > 1 && __testvalid)
300 const char_type* __sign = __negative ? __lc->_M_negative_sign
301 : __lc->_M_positive_sign;
303 for (; __beg != __end && __i < __sign_size
304 && *__beg == __sign[__i]; ++__beg, (void)++__i);
306 if (__i != __sign_size)
313 if (__res.size() > 1)
315 const size_type __first = __res.find_first_not_of(
'0');
318 __res.erase(0, __only_zeros ? __res.size() - 1 : __first);
322 if (__negative && __res[0] !=
'0')
323 __res.insert(__res.begin(),
'-');
326 if (__grouping_tmp.size())
329 __grouping_tmp +=
static_cast<char>(__testdecfound ? __last_pos
331 if (!std::__verify_grouping(__lc->_M_grouping,
332 __lc->_M_grouping_size,
338 if (__testdecfound && __n != __lc->_M_frac_digits)
354 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
355 && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
356 template<
typename _CharT,
typename _InIter>
358 money_get<_CharT, _InIter>::
359 __do_get(iter_type __beg, iter_type __end,
bool __intl, ios_base& __io,
363 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
364 : _M_extract<false>(__beg, __end, __io, __err, __str);
365 std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
370 template<
typename _CharT,
typename _InIter>
374 ios_base::iostate& __err,
long double& __units)
const
377 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
378 : _M_extract<false>(__beg, __end, __io, __err, __str);
379 std::__convert_to_v(__str.
c_str(), __units, __err, _S_get_c_locale());
383 template<
typename _CharT,
typename _InIter>
387 ios_base::iostate& __err,
string_type& __digits)
const
389 typedef typename string::size_type size_type;
392 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
395 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
396 : _M_extract<false>(__beg, __end, __io, __err, __str);
397 const size_type __len = __str.size();
401 __ctype.
widen(__str.data(), __str.data() + __len, &__digits[0]);
406 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
407 && defined __LONG_DOUBLE_IEEE128__
408 template<
typename _CharT,
typename _InIter>
412 ios_base::iostate& __err, __ibm128& __units)
const
415 __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
416 : _M_extract<false>(__beg, __end, __io, __err, __str);
417 std::__convert_to_v(__str.
c_str(), __units, __err, _S_get_c_locale());
422 template<
typename _CharT,
typename _OutIter>
425 money_put<_CharT, _OutIter>::
426 _M_insert(iter_type __s, ios_base& __io, char_type __fill,
427 const string_type& __digits)
const
429 typedef typename string_type::size_type size_type;
430 typedef money_base::part part;
431 typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
433 const locale& __loc = __io._M_getloc();
434 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
436 __use_cache<__cache_type> __uc;
437 const __cache_type* __lc = __uc(__loc);
438 const char_type* __lit = __lc->_M_atoms;
442 const char_type* __beg = __digits.data();
444 money_base::pattern __p;
445 const char_type* __sign;
446 size_type __sign_size;
447 if (!(*__beg == __lit[money_base::_S_minus]))
449 __p = __lc->_M_pos_format;
450 __sign = __lc->_M_positive_sign;
451 __sign_size = __lc->_M_positive_sign_size;
455 __p = __lc->_M_neg_format;
456 __sign = __lc->_M_negative_sign;
457 __sign_size = __lc->_M_negative_sign_size;
463 size_type __len = __ctype.scan_not(ctype_base::digit, __beg,
464 __beg + __digits.size()) - __beg;
471 __value.reserve(2 * __len);
475 long __paddec = __len - __lc->_M_frac_digits;
478 if (__lc->_M_frac_digits < 0)
480 if (__lc->_M_grouping_size)
482 __value.assign(2 * __paddec, char_type());
484 std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
486 __lc->_M_grouping_size,
487 __beg, __beg + __paddec);
488 __value.erase(__vend - &__value[0]);
491 __value.assign(__beg, __paddec);
495 if (__lc->_M_frac_digits > 0)
497 __value += __lc->_M_decimal_point;
499 __value.append(__beg + __paddec, __lc->_M_frac_digits);
503 __value.append(-__paddec, __lit[money_base::_S_zero]);
504 __value.append(__beg, __len);
511 __len = __value.size() + __sign_size;
513 ? __lc->_M_curr_symbol_size : 0);
516 __res.reserve(2 * __len);
518 const size_type __width =
static_cast<size_type
>(__io.width());
522 for (
int __i = 0; __i < 4; ++__i)
524 const part __which =
static_cast<part
>(__p.field[__i]);
527 case money_base::symbol:
529 __res.append(__lc->_M_curr_symbol,
530 __lc->_M_curr_symbol_size);
532 case money_base::sign:
539 case money_base::value:
542 case money_base::space:
547 __res.append(__width - __len, __fill);
551 case money_base::none:
553 __res.append(__width - __len, __fill);
560 __res.append(__sign + 1, __sign_size - 1);
563 __len = __res.size();
568 __res.append(__width - __len, __fill);
571 __res.insert(0, __width - __len, __fill);
576 __s = std::__write(__s, __res.data(), __len);
582 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
583 && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
584 template<
typename _CharT,
typename _OutIter>
586 money_put<_CharT, _OutIter>::
587 __do_put(iter_type __s,
bool __intl, ios_base& __io, char_type __fill,
588 double __units)
const
589 {
return this->do_put(__s, __intl, __io, __fill, (
long double) __units); }
592 template<
typename _CharT,
typename _OutIter>
596 long double __units)
const
599 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
600 #if _GLIBCXX_USE_C99_STDIO
603 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
606 int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
607 "%.*Lf", 0, __units);
609 if (__len >= __cs_size)
611 __cs_size = __len + 1;
612 __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
613 __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
614 "%.*Lf", 0, __units);
618 const int __cs_size =
619 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
620 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
621 int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0,
"%.*Lf",
625 __ctype.
widen(__cs, __cs + __len, &__digits[0]);
626 return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
627 : _M_insert<false>(__s, __io, __fill, __digits);
630 template<
typename _CharT,
typename _OutIter>
635 {
return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
636 : _M_insert<false>(__s, __io, __fill, __digits); }
638 #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
639 && defined __LONG_DOUBLE_IEEE128__
647 __glibcxx_snprintfibm128(
char*,
size_t,
const char*, ...) __asm__("snprintf");
649 template<typename _CharT, typename _OutIter>
652 __do_put(iter_type __s,
bool __intl,
ios_base& __io, char_type __fill,
653 __ibm128 __units)
const
655 const locale __loc = __io.getloc();
656 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
659 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
660 const __c_locale __old = __gnu_cxx::__uselocale(_S_get_c_locale());
664 int __len = __glibcxx_snprintfibm128(__cs, __cs_size,
"%.*Lf", 0,
667 if (__len >= __cs_size)
669 __cs_size = __len + 1;
670 __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
671 __len = __glibcxx_snprintfibm128(__cs, __cs_size,
"%.*Lf", 0,
674 __gnu_cxx::__uselocale(__old);
675 string_type __digits(__len, char_type());
676 __ctype.
widen(__cs, __cs + __len, &__digits[0]);
677 return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
678 : _M_insert<false>(__s, __io, __fill, __digits);
682 _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
687 template<
typename _CharT,
typename _InIter>
690 {
return time_base::no_order; }
694 template<
typename _CharT,
typename _InIter>
698 ios_base::iostate& __err, tm* __tm,
699 const _CharT* __format,
700 __time_get_state &__state)
const
703 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
704 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
709 for (; __beg != __end && __i < __len && !__tmperr; ++__i)
711 if (__ctype.narrow(__format[__i], 0) ==
'%')
714 char __c = __ctype.narrow(__format[++__i], 0);
716 if (__c ==
'E' || __c ==
'O')
717 __c = __ctype.narrow(__format[++__i], 0);
725 const char_type* __days[14];
726 __tp._M_days(&__days[0]);
727 __tp._M_days_abbreviated(&__days[7]);
728 __beg = _M_extract_name(__beg, __end, __mem, __days,
732 __tm->tm_wday = __mem % 7;
733 __state._M_have_wday = 1;
740 const char_type* __months[24];
741 __tp._M_months(&__months[0]);
742 __tp._M_months_abbreviated(&__months[12]);
743 __beg = _M_extract_name(__beg, __end, __mem,
744 __months, 24, __io, __tmperr);
747 __tm->tm_mon = __mem % 12;
748 __state._M_have_mon = 1;
749 __state._M_want_xday = 1;
754 const char_type* __dt[2];
755 __tp._M_date_time_formats(__dt);
756 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
757 __tm, __dt[0], __state);
759 __state._M_want_xday = 1;
763 __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
767 __state._M_century = __mem;
768 __state._M_have_century = 1;
769 __state._M_want_xday = 1;
775 if (__ctype.is(ctype_base::space, *__beg))
777 __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
781 __tm->tm_mday = __mem;
782 __state._M_have_mday = 1;
783 __state._M_want_xday = 1;
789 __ctype.widen(__cs, __cs + 9, __wcs);
790 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
791 __tm, __wcs, __state);
793 __state._M_want_xday = 1;
797 __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
801 __tm->tm_hour = __mem;
802 __state._M_have_I = 0;
807 __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
811 __tm->tm_hour = __mem % 12;
812 __state._M_have_I = 1;
817 __beg = _M_extract_num(__beg, __end, __mem, 1, 366, 3,
821 __tm->tm_yday = __mem - 1;
822 __state._M_have_yday = 1;
827 __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
831 __tm->tm_mon = __mem - 1;
832 __state._M_have_mon = 1;
837 __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
840 __tm->tm_min = __mem;
844 while (__beg != __end
845 && __ctype.is(ctype_base::space, *__beg))
850 const char_type* __ampm[2];
851 __tp._M_am_pm(&__ampm[0]);
852 if (!__ampm[0][0] || !__ampm[1][0])
854 __beg = _M_extract_name(__beg, __end, __mem, __ampm,
856 if (!__tmperr && __mem)
857 __state._M_is_pm = 1;
861 const char_type* __ampm_format;
862 __tp._M_am_pm_format(&__ampm_format);
863 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
864 __tm, __ampm_format, __state);
869 __ctype.widen(__cs, __cs + 6, __wcs);
870 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
871 __tm, __wcs, __state);
877 __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
879 __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
883 __tm->tm_sec = __mem;
888 __ctype.widen(__cs, __cs + 9, __wcs);
889 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
890 __tm, __wcs, __state);
894 __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
898 __state._M_week_no = __mem;
899 __state._M_have_uweek = 1;
904 __beg = _M_extract_num(__beg, __end, __mem, 0, 6, 1,
908 __tm->tm_wday = __mem;
909 __state._M_have_wday = 1;
914 __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
918 __state._M_week_no = __mem;
919 __state._M_have_wweek = 1;
924 const char_type* __dates[2];
925 __tp._M_date_formats(__dates);
926 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
927 __tm, __dates[0], __state);
931 const char_type* __times[2];
932 __tp._M_time_formats(__times);
933 __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
934 __tm, __times[0], __state);
938 __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
942 __state._M_want_century = 1;
943 __state._M_want_xday = 1;
948 __c = __ctype.narrow(*__beg,
'*');
949 if (__c >=
'0' && __c <=
'9')
952 __mem = __mem * 10 + (__c -
'0');
955 __c = __ctype.narrow(*__beg,
'*');
956 if (__c >=
'0' && __c <=
'9')
959 __mem = __mem * 10 + (__c -
'0');
963 __state._M_want_century = 0;
969 __tm->tm_year = __mem;
974 __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
978 __tm->tm_year = __mem - 1900;
979 __state._M_want_century = 0;
980 __state._M_want_xday = 1;
985 if (__ctype.is(ctype_base::upper, *__beg))
988 __beg = _M_extract_name(__beg, __end, __tmp,
989 __timepunct_cache<_CharT>::_S_timezones,
993 if (__beg != __end && !__tmperr && __tmp == 0
994 && (*__beg == __ctype.widen(
'-')
995 || *__beg == __ctype.widen(
'+')))
997 __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
999 __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
1007 if (*__beg == __ctype.widen(
'%'))
1017 else if (__ctype.is(ctype_base::space, __format[__i]))
1020 while (__beg != __end
1021 && __ctype.is(ctype_base::space, *__beg))
1028 if (__ctype.tolower(__format[__i]) == __ctype.tolower(*__beg)
1029 || __ctype.toupper(__format[__i]) == __ctype.toupper(*__beg))
1036 if (__tmperr || __i != __len)
1042 template<
typename _CharT,
typename _InIter>
1044 time_get<_CharT, _InIter>::
1045 _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
1047 const _CharT* __format)
const
1049 __time_get_state __state = __time_get_state();
1050 return _M_extract_via_format(__beg, __end, __io, __err, __tm,
1054 template<
typename _CharT,
typename _InIter>
1056 time_get<_CharT, _InIter>::
1057 _M_extract_num(iter_type __beg, iter_type __end,
int& __member,
1058 int __min,
int __max,
size_t __len,
1061 const locale& __loc = __io._M_getloc();
1062 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1066 for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
1068 const char __c = __ctype.narrow(*__beg,
'*');
1069 if (__c >=
'0' && __c <=
'9')
1071 __value = __value * 10 + (__c -
'0');
1072 if (__value > __max)
1078 if (__i && __value >= __min && __value <= __max)
1091 template<
typename _CharT,
typename _InIter>
1093 time_get<_CharT, _InIter>::
1094 _M_extract_name(iter_type __beg, iter_type __end,
int& __member,
1095 const _CharT** __names,
size_t __indexlen,
1098 typedef char_traits<_CharT> __traits_type;
1099 const locale& __loc = __io._M_getloc();
1100 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1103 =
static_cast<size_t*
>(__builtin_alloca(2 *
sizeof(
size_t)
1105 size_t* __lengths = __matches + __indexlen;
1106 size_t __nmatches = 0;
1108 bool __testvalid =
true;
1109 const char_type* __name;
1110 bool __begupdated =
false;
1115 const char_type __c = *__beg;
1117 const char_type __cl = __ctype.tolower(__c);
1118 const char_type __cu = __ctype.toupper(__c);
1119 for (
size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1120 if (__cl == __ctype.tolower(__names[__i1][0])
1121 || __cu == __ctype.toupper(__names[__i1][0]))
1123 __lengths[__nmatches]
1124 = __traits_type::length(__names[__i1]);
1125 __matches[__nmatches++] = __i1;
1129 while (__nmatches > 1)
1132 size_t __minlen = __lengths[0];
1133 for (
size_t __i2 = 1; __i2 < __nmatches; ++__i2)
1134 __minlen =
std::min(__minlen, __lengths[__i2]);
1137 if (__pos == __minlen)
1145 bool __match_longer =
false;
1150 const char_type __cl = __ctype.tolower(*__beg);
1151 const char_type __cu = __ctype.toupper(*__beg);
1152 for (
size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1154 __name = __names[__matches[__i3]];
1155 if (__lengths[__i3] > __pos
1156 && (__ctype.tolower(__name[__pos]) == __cl
1157 || __ctype.toupper(__name[__pos]) == __cu))
1159 __match_longer =
true;
1164 for (
size_t __i4 = 0; __i4 < __nmatches;)
1165 if (__match_longer == (__lengths[__i4] == __pos))
1167 __matches[__i4] = __matches[--__nmatches];
1168 __lengths[__i4] = __lengths[__nmatches];
1174 __minlen = __lengths[0];
1175 for (
size_t __i5 = 1; __i5 < __nmatches; ++__i5)
1176 __minlen =
std::min(__minlen, __lengths[__i5]);
1182 if (__nmatches == 2 && (__indexlen & 1) == 0)
1184 if (__matches[0] < __indexlen / 2)
1186 if (__matches[1] == __matches[0] + __indexlen / 2)
1189 else if (__matches[1] == __matches[0] - __indexlen / 2)
1191 __matches[0] = __matches[1];
1192 __lengths[0] = __lengths[1];
1196 __begupdated =
true;
1200 if (__pos < __minlen && __beg != __end)
1203 const char_type __cl = __ctype.tolower(*__beg);
1204 const char_type __cu = __ctype.toupper(*__beg);
1205 for (
size_t __i6 = 0; __i6 < __nmatches;)
1207 __name = __names[__matches[__i6]];
1208 if (__ctype.tolower(__name[__pos]) != __cl
1209 && __ctype.toupper(__name[__pos]) != __cu)
1211 __matches[__i6] = __matches[--__nmatches];
1212 __lengths[__i6] = __lengths[__nmatches];
1222 if (__nmatches == 1)
1230 __name = __names[__matches[0]];
1231 const size_t __len = __lengths[0];
1232 while (__pos < __len
1235 && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
1236 || (__ctype.toupper(__name[__pos])
1237 == __ctype.toupper(*__beg))))
1238 ++__beg, (void)++__pos;
1241 __member = __matches[0];
1243 __testvalid =
false;
1246 __testvalid =
false;
1253 template<
typename _CharT,
typename _InIter>
1255 time_get<_CharT, _InIter>::
1256 _M_extract_wday_or_month(iter_type __beg, iter_type __end,
int& __member,
1257 const _CharT** __names,
size_t __indexlen,
1260 typedef char_traits<_CharT> __traits_type;
1261 const locale& __loc = __io._M_getloc();
1262 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1264 int* __matches =
static_cast<int*
>(__builtin_alloca(2 *
sizeof(
int)
1266 size_t __nmatches = 0;
1267 size_t* __matches_lengths = 0;
1272 const char_type __c = *__beg;
1273 for (
size_t __i = 0; __i < 2 * __indexlen; ++__i)
1274 if (__c == __names[__i][0]
1275 || __c == __ctype.toupper(__names[__i][0]))
1276 __matches[__nmatches++] = __i;
1285 =
static_cast<size_t*
>(__builtin_alloca(
sizeof(
size_t)
1287 for (
size_t __i = 0; __i < __nmatches; ++__i)
1288 __matches_lengths[__i]
1289 = __traits_type::length(__names[__matches[__i]]);
1292 for (; __beg != __end; ++__beg, (void)++__pos)
1294 size_t __nskipped = 0;
1295 const char_type __c = *__beg;
1296 for (
size_t __i = 0; __i < __nmatches;)
1298 const char_type* __name = __names[__matches[__i]];
1299 if (__pos >= __matches_lengths[__i])
1300 ++__nskipped, ++__i;
1301 else if (!(__name[__pos] == __c))
1304 __matches[__i] = __matches[__nmatches];
1305 __matches_lengths[__i] = __matches_lengths[__nmatches];
1310 if (__nskipped == __nmatches)
1314 if ((__nmatches == 1 && __matches_lengths[0] == __pos)
1315 || (__nmatches == 2 && (__matches_lengths[0] == __pos
1316 || __matches_lengths[1] == __pos)))
1317 __member = (__matches[0] >= (
int)__indexlen
1318 ? __matches[0] - (int)__indexlen : __matches[0]);
1325 template<
typename _CharT,
typename _InIter>
1329 ios_base::iostate& __err, tm* __tm)
const
1332 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1334 __tp._M_time_formats(__times);
1335 __time_get_state __state = __time_get_state();
1336 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1337 __tm, __times[0], __state);
1338 __state._M_finalize_state(__tm);
1344 template<
typename _CharT,
typename _InIter>
1348 ios_base::iostate& __err, tm* __tm)
const
1351 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1353 __tp._M_date_formats(__dates);
1354 __time_get_state __state = __time_get_state();
1355 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1356 __tm, __dates[0], __state);
1357 __state._M_finalize_state(__tm);
1363 template<
typename _CharT,
typename _InIter>
1367 ios_base::iostate& __err, tm* __tm)
const
1370 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1372 __tp._M_days_abbreviated(__days);
1373 __tp._M_days(__days + 7);
1377 __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
1380 __tm->tm_wday = __tmpwday;
1389 template<
typename _CharT,
typename _InIter>
1393 ios_base& __io, ios_base::iostate& __err, tm* __tm)
const
1396 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1398 __tp._M_months_abbreviated(__months);
1399 __tp._M_months(__months + 12);
1403 __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
1406 __tm->tm_mon = __tmpmon;
1415 template<
typename _CharT,
typename _InIter>
1419 ios_base::iostate& __err, tm* __tm)
const
1424 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1426 __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2,
1432 __c = __ctype.
narrow(*__beg,
'*');
1436 if (__c >=
'0' && __c <=
'9')
1439 __tmpyear = __tmpyear * 10 + (__c -
'0');
1442 __c = __ctype.
narrow(*__beg,
'*');
1443 if (__c >=
'0' && __c <=
'9')
1446 __tmpyear = __tmpyear * 10 + (__c -
'0');
1451 else if (__tmpyear < 69)
1453 __tm->tm_year = __tmpyear;
1463 #if __cplusplus >= 201103L
1464 template<
typename _CharT,
typename _InIter>
1469 ios_base::iostate& __err, tm* __tm,
const char_type* __fmt,
1473 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1475 bool __use_state =
false;
1476 #if __GNUC__ >= 5 && !defined(_GLIBCXX_CLANG)
1477 #pragma GCC diagnostic push
1478 #pragma GCC diagnostic ignored "-Wpmf-conversions"
1487 #pragma GCC diagnostic pop
1489 __time_get_state __state = __time_get_state();
1490 while (__fmt != __fmtend &&
1498 else if (__ctype.
narrow(*__fmt, 0) ==
'%')
1503 if (++__fmt == __fmtend)
1508 const char __c = __ctype.
narrow(*__fmt, 0);
1509 if (__c !=
'E' && __c !=
'O')
1511 else if (++__fmt != __fmtend)
1514 __format = __ctype.
narrow(*__fmt, 0);
1524 __new_fmt[0] = __fmt_start[0];
1525 __new_fmt[1] = __fmt_start[1];
1528 __new_fmt[2] = __fmt_start[2];
1533 __s = _M_extract_via_format(__s, __end, __io, __err, __tm,
1534 __new_fmt, __state);
1539 __s = this->do_get(__s, __end, __io, __err, __tm, __format,
1543 else if (__ctype.
is(ctype_base::space, *__fmt))
1546 while (__fmt != __fmtend &&
1547 __ctype.
is(ctype_base::space, *__fmt))
1550 while (__s != __end &&
1551 __ctype.
is(ctype_base::space, *__s))
1568 __state._M_finalize_state(__tm);
1572 template<
typename _CharT,
typename _InIter>
1577 ios_base::iostate& __err, tm* __tm,
1578 char __format,
char __mod)
const
1581 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1585 __fmt[0] = __ctype.
widen(
'%');
1588 __fmt[1] = __format;
1594 __fmt[2] = __format;
1598 __time_get_state __state = __time_get_state();
1599 __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt,
1601 __state._M_finalize_state(__tm);
1607 #endif // __cplusplus >= 201103L
1609 template<
typename _CharT,
typename _OutIter>
1613 const _CharT* __beg,
const _CharT* __end)
const
1616 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1617 for (; __beg != __end; ++__beg)
1618 if (__ctype.
narrow(*__beg, 0) !=
'%')
1623 else if (++__beg != __end)
1627 const char __c = __ctype.
narrow(*__beg, 0);
1628 if (__c !=
'E' && __c !=
'O')
1630 else if (++__beg != __end)
1633 __format = __ctype.
narrow(*__beg, 0);
1637 __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
1644 template<
typename _CharT,
typename _OutIter>
1648 char __format,
char __mod)
const
1651 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1652 __timepunct<_CharT>
const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1656 const size_t __maxlen = 128;
1665 __fmt[0] = __ctype.
widen(
'%');
1668 __fmt[1] = __format;
1674 __fmt[2] = __format;
1678 __tp._M_put(__res, __maxlen, __fmt, __tm);
1687 #if _GLIBCXX_EXTERN_TEMPLATE
1688 #pragma GCC diagnostic push
1689 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
1690 #pragma GCC diagnostic ignored "-Wlong-long"
1695 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_get<char>;
1696 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_put<char>;
1697 extern template class __timepunct<char>;
1707 __try_use_facet<moneypunct<char, true> >(
const locale&) _GLIBCXX_NOTHROW;
1711 __try_use_facet<moneypunct<char, false> >(
const locale&) _GLIBCXX_NOTHROW;
1715 __try_use_facet<money_put<char> >(
const locale&) _GLIBCXX_NOTHROW;
1719 __try_use_facet<money_get<char> >(
const locale&) _GLIBCXX_NOTHROW;
1722 const __timepunct<char>*
1723 __try_use_facet<__timepunct<char> >(
const locale&) _GLIBCXX_NOTHROW;
1727 __try_use_facet<time_put<char> >(
const locale&) _GLIBCXX_NOTHROW;
1731 __try_use_facet<time_get<char> >(
const locale&) _GLIBCXX_NOTHROW;
1735 __try_use_facet<messages<char> >(
const locale&) _GLIBCXX_NOTHROW;
1739 use_facet<moneypunct<char, true> >(
const locale&);
1743 use_facet<moneypunct<char, false> >(
const locale&);
1747 use_facet<money_put<char> >(
const locale&);
1751 use_facet<money_get<char> >(
const locale&);
1754 const __timepunct<char>&
1755 use_facet<__timepunct<char> >(
const locale&);
1759 use_facet<time_put<char> >(
const locale&);
1763 use_facet<time_get<char> >(
const locale&);
1767 use_facet<messages<char> >(
const locale&);
1771 has_facet<moneypunct<char> >(
const locale&);
1775 has_facet<money_put<char> >(
const locale&);
1779 has_facet<money_get<char> >(
const locale&);
1783 has_facet<__timepunct<char> >(
const locale&);
1787 has_facet<time_put<char> >(
const locale&);
1791 has_facet<time_get<char> >(
const locale&);
1795 has_facet<messages<char> >(
const locale&);
1797 #ifdef _GLIBCXX_USE_WCHAR_T
1804 extern template class __timepunct<wchar_t>;
1814 __try_use_facet<moneypunct<wchar_t, true> >(
const locale&) _GLIBCXX_NOTHROW;
1818 __try_use_facet<moneypunct<wchar_t, false> >(
const locale&) _GLIBCXX_NOTHROW;
1822 __try_use_facet<money_put<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1826 __try_use_facet<money_get<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1829 const __timepunct<wchar_t>*
1830 __try_use_facet<__timepunct<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1834 __try_use_facet<time_put<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1838 __try_use_facet<time_get<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1842 __try_use_facet<messages<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1846 use_facet<moneypunct<wchar_t, true> >(
const locale&);
1850 use_facet<moneypunct<wchar_t, false> >(
const locale&);
1854 use_facet<money_put<wchar_t> >(
const locale&);
1858 use_facet<money_get<wchar_t> >(
const locale&);
1861 const __timepunct<wchar_t>&
1862 use_facet<__timepunct<wchar_t> >(
const locale&);
1866 use_facet<time_put<wchar_t> >(
const locale&);
1870 use_facet<time_get<wchar_t> >(
const locale&);
1874 use_facet<messages<wchar_t> >(
const locale&);
1878 has_facet<moneypunct<wchar_t> >(
const locale&);
1882 has_facet<money_put<wchar_t> >(
const locale&);
1886 has_facet<money_get<wchar_t> >(
const locale&);
1890 has_facet<__timepunct<wchar_t> >(
const locale&);
1894 has_facet<time_put<wchar_t> >(
const locale&);
1898 has_facet<time_get<wchar_t> >(
const locale&);
1902 has_facet<messages<wchar_t> >(
const locale&);
1904 #pragma GCC diagnostic pop
1907 _GLIBCXX_END_NAMESPACE_VERSION