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>
1043 [[__gnu__::__always_inline__]]
inline
1045 time_get<_CharT, _InIter>::
1046 _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
1048 const _CharT* __format)
const
1050 __time_get_state __state = __time_get_state();
1051 return _M_extract_via_format(__beg, __end, __io, __err, __tm,
1055 template<
typename _CharT,
typename _InIter>
1056 [[__gnu__::__always_inline__]]
inline
1058 time_get<_CharT, _InIter>::
1059 _M_extract_num(iter_type __beg, iter_type __end,
int& __member,
1060 int __min,
int __max,
size_t __len,
1063 const locale& __loc = __io._M_getloc();
1064 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1068 for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
1070 const char __c = __ctype.narrow(*__beg,
'*');
1071 if (__c >=
'0' && __c <=
'9')
1073 __value = __value * 10 + (__c -
'0');
1074 if (__value > __max)
1080 if (__i && __value >= __min && __value <= __max)
1093 template<
typename _CharT,
typename _InIter>
1094 [[__gnu__::__always_inline__]]
inline
1096 time_get<_CharT, _InIter>::
1097 _M_extract_name(iter_type __beg, iter_type __end,
int& __member,
1098 const _CharT** __names,
size_t __indexlen,
1101 typedef char_traits<_CharT> __traits_type;
1102 const locale& __loc = __io._M_getloc();
1103 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1106 =
static_cast<size_t*
>(__builtin_alloca(2 *
sizeof(
size_t)
1108 size_t* __lengths = __matches + __indexlen;
1109 size_t __nmatches = 0;
1111 bool __testvalid =
true;
1112 const char_type* __name;
1113 bool __begupdated =
false;
1118 const char_type __c = *__beg;
1120 const char_type __cl = __ctype.tolower(__c);
1121 const char_type __cu = __ctype.toupper(__c);
1122 for (
size_t __i1 = 0; __i1 < __indexlen; ++__i1)
1123 if (__cl == __ctype.tolower(__names[__i1][0])
1124 || __cu == __ctype.toupper(__names[__i1][0]))
1126 __lengths[__nmatches]
1127 = __traits_type::length(__names[__i1]);
1128 __matches[__nmatches++] = __i1;
1132 while (__nmatches > 1)
1135 size_t __minlen = __lengths[0];
1136 for (
size_t __i2 = 1; __i2 < __nmatches; ++__i2)
1137 __minlen =
std::min(__minlen, __lengths[__i2]);
1140 if (__pos == __minlen)
1148 bool __match_longer =
false;
1153 const char_type __cl = __ctype.tolower(*__beg);
1154 const char_type __cu = __ctype.toupper(*__beg);
1155 for (
size_t __i3 = 0; __i3 < __nmatches; ++__i3)
1157 __name = __names[__matches[__i3]];
1158 if (__lengths[__i3] > __pos
1159 && (__ctype.tolower(__name[__pos]) == __cl
1160 || __ctype.toupper(__name[__pos]) == __cu))
1162 __match_longer =
true;
1167 for (
size_t __i4 = 0; __i4 < __nmatches;)
1168 if (__match_longer == (__lengths[__i4] == __pos))
1170 __matches[__i4] = __matches[--__nmatches];
1171 __lengths[__i4] = __lengths[__nmatches];
1177 __minlen = __lengths[0];
1178 for (
size_t __i5 = 1; __i5 < __nmatches; ++__i5)
1179 __minlen =
std::min(__minlen, __lengths[__i5]);
1185 if (__nmatches == 2 && (__indexlen & 1) == 0)
1187 if (__matches[0] < __indexlen / 2)
1189 if (__matches[1] == __matches[0] + __indexlen / 2)
1192 else if (__matches[1] == __matches[0] - __indexlen / 2)
1194 __matches[0] = __matches[1];
1195 __lengths[0] = __lengths[1];
1199 __begupdated =
true;
1203 if (__pos < __minlen && __beg != __end)
1206 const char_type __cl = __ctype.tolower(*__beg);
1207 const char_type __cu = __ctype.toupper(*__beg);
1208 for (
size_t __i6 = 0; __i6 < __nmatches;)
1210 __name = __names[__matches[__i6]];
1211 if (__ctype.tolower(__name[__pos]) != __cl
1212 && __ctype.toupper(__name[__pos]) != __cu)
1214 __matches[__i6] = __matches[--__nmatches];
1215 __lengths[__i6] = __lengths[__nmatches];
1225 if (__nmatches == 1)
1233 __name = __names[__matches[0]];
1234 const size_t __len = __lengths[0];
1235 while (__pos < __len
1238 && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
1239 || (__ctype.toupper(__name[__pos])
1240 == __ctype.toupper(*__beg))))
1241 ++__beg, (void)++__pos;
1244 __member = __matches[0];
1246 __testvalid =
false;
1249 __testvalid =
false;
1256 template<
typename _CharT,
typename _InIter>
1258 time_get<_CharT, _InIter>::
1259 _M_extract_wday_or_month(iter_type __beg, iter_type __end,
int& __member,
1260 const _CharT** __names,
size_t __indexlen,
1263 typedef char_traits<_CharT> __traits_type;
1264 const locale& __loc = __io._M_getloc();
1265 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1267 int* __matches =
static_cast<int*
>(__builtin_alloca(2 *
sizeof(
int)
1269 size_t __nmatches = 0;
1270 size_t* __matches_lengths = 0;
1275 const char_type __c = *__beg;
1276 for (
size_t __i = 0; __i < 2 * __indexlen; ++__i)
1277 if (__c == __names[__i][0]
1278 || __c == __ctype.toupper(__names[__i][0]))
1279 __matches[__nmatches++] = __i;
1288 =
static_cast<size_t*
>(__builtin_alloca(
sizeof(
size_t)
1290 for (
size_t __i = 0; __i < __nmatches; ++__i)
1291 __matches_lengths[__i]
1292 = __traits_type::length(__names[__matches[__i]]);
1295 for (; __beg != __end; ++__beg, (void)++__pos)
1297 size_t __nskipped = 0;
1298 const char_type __c = *__beg;
1299 for (
size_t __i = 0; __i < __nmatches;)
1301 const char_type* __name = __names[__matches[__i]];
1302 if (__pos >= __matches_lengths[__i])
1303 ++__nskipped, ++__i;
1304 else if (!(__name[__pos] == __c))
1307 __matches[__i] = __matches[__nmatches];
1308 __matches_lengths[__i] = __matches_lengths[__nmatches];
1313 if (__nskipped == __nmatches)
1317 if ((__nmatches == 1 && __matches_lengths[0] == __pos)
1318 || (__nmatches == 2 && (__matches_lengths[0] == __pos
1319 || __matches_lengths[1] == __pos)))
1320 __member = (__matches[0] >= (
int)__indexlen
1321 ? __matches[0] - (int)__indexlen : __matches[0]);
1328 template<
typename _CharT,
typename _InIter>
1332 ios_base::iostate& __err, tm* __tm)
const
1335 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1337 __tp._M_time_formats(__times);
1338 __time_get_state __state = __time_get_state();
1339 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1340 __tm, __times[0], __state);
1341 __state._M_finalize_state(__tm);
1347 template<
typename _CharT,
typename _InIter>
1351 ios_base::iostate& __err, tm* __tm)
const
1354 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1356 __tp._M_date_formats(__dates);
1357 __time_get_state __state = __time_get_state();
1358 __beg = _M_extract_via_format(__beg, __end, __io, __err,
1359 __tm, __dates[0], __state);
1360 __state._M_finalize_state(__tm);
1366 template<
typename _CharT,
typename _InIter>
1370 ios_base::iostate& __err, tm* __tm)
const
1373 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1375 __tp._M_days_abbreviated(__days);
1376 __tp._M_days(__days + 7);
1380 __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
1383 __tm->tm_wday = __tmpwday;
1392 template<
typename _CharT,
typename _InIter>
1396 ios_base& __io, ios_base::iostate& __err, tm* __tm)
const
1399 const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
1401 __tp._M_months_abbreviated(__months);
1402 __tp._M_months(__months + 12);
1406 __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
1409 __tm->tm_mon = __tmpmon;
1418 template<
typename _CharT,
typename _InIter>
1422 ios_base::iostate& __err, tm* __tm)
const
1427 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
1429 __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2,
1435 __c = __ctype.
narrow(*__beg,
'*');
1439 if (__c >=
'0' && __c <=
'9')
1442 __tmpyear = __tmpyear * 10 + (__c -
'0');
1445 __c = __ctype.
narrow(*__beg,
'*');
1446 if (__c >=
'0' && __c <=
'9')
1449 __tmpyear = __tmpyear * 10 + (__c -
'0');
1454 else if (__tmpyear < 69)
1456 __tm->tm_year = __tmpyear;
1466 #if __cplusplus >= 201103L
1467 template<
typename _CharT,
typename _InIter>
1472 ios_base::iostate& __err, tm* __tm,
const char_type* __fmt,
1476 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1478 bool __use_state =
false;
1479 #if __GNUC__ >= 5 && !defined(_GLIBCXX_CLANG)
1480 #pragma GCC diagnostic push
1481 #pragma GCC diagnostic ignored "-Wpmf-conversions"
1490 #pragma GCC diagnostic pop
1492 __time_get_state __state = __time_get_state();
1493 while (__fmt != __fmtend &&
1501 else if (__ctype.
narrow(*__fmt, 0) ==
'%')
1506 if (++__fmt == __fmtend)
1511 const char __c = __ctype.
narrow(*__fmt, 0);
1512 if (__c !=
'E' && __c !=
'O')
1514 else if (++__fmt != __fmtend)
1517 __format = __ctype.
narrow(*__fmt, 0);
1527 __new_fmt[0] = __fmt_start[0];
1528 __new_fmt[1] = __fmt_start[1];
1531 __new_fmt[2] = __fmt_start[2];
1536 __s = _M_extract_via_format(__s, __end, __io, __err, __tm,
1537 __new_fmt, __state);
1542 __s = this->do_get(__s, __end, __io, __err, __tm, __format,
1546 else if (__ctype.
is(ctype_base::space, *__fmt))
1549 while (__fmt != __fmtend &&
1550 __ctype.
is(ctype_base::space, *__fmt))
1553 while (__s != __end &&
1554 __ctype.
is(ctype_base::space, *__s))
1571 __state._M_finalize_state(__tm);
1575 template<
typename _CharT,
typename _InIter>
1580 ios_base::iostate& __err, tm* __tm,
1581 char __format,
char __mod)
const
1584 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1588 __fmt[0] = __ctype.
widen(
'%');
1591 __fmt[1] = __format;
1597 __fmt[2] = __format;
1601 __time_get_state __state = __time_get_state();
1602 __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt,
1604 __state._M_finalize_state(__tm);
1612 template<
typename _CharT,
typename _OutIter>
1616 const _CharT* __beg,
const _CharT* __end)
const
1619 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1620 for (; __beg != __end; ++__beg)
1621 if (__ctype.
narrow(*__beg, 0) !=
'%')
1626 else if (++__beg != __end)
1630 const char __c = __ctype.
narrow(*__beg, 0);
1631 if (__c !=
'E' && __c !=
'O')
1633 else if (++__beg != __end)
1636 __format = __ctype.
narrow(*__beg, 0);
1640 __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
1647 template<
typename _CharT,
typename _OutIter>
1651 char __format,
char __mod)
const
1654 ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
1655 __timepunct<_CharT>
const& __tp = use_facet<__timepunct<_CharT> >(__loc);
1659 const size_t __maxlen = 128;
1668 __fmt[0] = __ctype.
widen(
'%');
1671 __fmt[1] = __format;
1677 __fmt[2] = __format;
1681 __tp._M_put(__res, __maxlen, __fmt, __tm);
1690 #if _GLIBCXX_EXTERN_TEMPLATE
1691 #pragma GCC diagnostic push
1692 #pragma GCC diagnostic ignored "-Wc++11-extensions"
1693 #pragma GCC diagnostic ignored "-Wlong-long"
1698 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_get<char>;
1699 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_put<char>;
1700 extern template class __timepunct<char>;
1710 __try_use_facet<moneypunct<char, true> >(
const locale&) _GLIBCXX_NOTHROW;
1714 __try_use_facet<moneypunct<char, false> >(
const locale&) _GLIBCXX_NOTHROW;
1718 __try_use_facet<money_put<char> >(
const locale&) _GLIBCXX_NOTHROW;
1722 __try_use_facet<money_get<char> >(
const locale&) _GLIBCXX_NOTHROW;
1725 const __timepunct<char>*
1726 __try_use_facet<__timepunct<char> >(
const locale&) _GLIBCXX_NOTHROW;
1730 __try_use_facet<time_put<char> >(
const locale&) _GLIBCXX_NOTHROW;
1734 __try_use_facet<time_get<char> >(
const locale&) _GLIBCXX_NOTHROW;
1738 __try_use_facet<messages<char> >(
const locale&) _GLIBCXX_NOTHROW;
1742 use_facet<moneypunct<char, true> >(
const locale&);
1746 use_facet<moneypunct<char, false> >(
const locale&);
1750 use_facet<money_put<char> >(
const locale&);
1754 use_facet<money_get<char> >(
const locale&);
1757 const __timepunct<char>&
1758 use_facet<__timepunct<char> >(
const locale&);
1762 use_facet<time_put<char> >(
const locale&);
1766 use_facet<time_get<char> >(
const locale&);
1770 use_facet<messages<char> >(
const locale&);
1774 has_facet<moneypunct<char> >(
const locale&);
1778 has_facet<money_put<char> >(
const locale&);
1782 has_facet<money_get<char> >(
const locale&);
1786 has_facet<__timepunct<char> >(
const locale&);
1790 has_facet<time_put<char> >(
const locale&);
1794 has_facet<time_get<char> >(
const locale&);
1798 has_facet<messages<char> >(
const locale&);
1800 #ifdef _GLIBCXX_USE_WCHAR_T
1807 extern template class __timepunct<wchar_t>;
1817 __try_use_facet<moneypunct<wchar_t, true> >(
const locale&) _GLIBCXX_NOTHROW;
1821 __try_use_facet<moneypunct<wchar_t, false> >(
const locale&) _GLIBCXX_NOTHROW;
1825 __try_use_facet<money_put<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1829 __try_use_facet<money_get<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1832 const __timepunct<wchar_t>*
1833 __try_use_facet<__timepunct<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1837 __try_use_facet<time_put<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1841 __try_use_facet<time_get<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1845 __try_use_facet<messages<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1849 use_facet<moneypunct<wchar_t, true> >(
const locale&);
1853 use_facet<moneypunct<wchar_t, false> >(
const locale&);
1857 use_facet<money_put<wchar_t> >(
const locale&);
1861 use_facet<money_get<wchar_t> >(
const locale&);
1864 const __timepunct<wchar_t>&
1865 use_facet<__timepunct<wchar_t> >(
const locale&);
1869 use_facet<time_put<wchar_t> >(
const locale&);
1873 use_facet<time_get<wchar_t> >(
const locale&);
1877 use_facet<messages<wchar_t> >(
const locale&);
1881 has_facet<moneypunct<wchar_t> >(
const locale&);
1885 has_facet<money_put<wchar_t> >(
const locale&);
1889 has_facet<money_get<wchar_t> >(
const locale&);
1893 has_facet<__timepunct<wchar_t> >(
const locale&);
1897 has_facet<time_put<wchar_t> >(
const locale&);
1901 has_facet<time_get<wchar_t> >(
const locale&);
1905 has_facet<messages<wchar_t> >(
const locale&);
1907 #pragma GCC diagnostic pop
1910 _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.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
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].