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);
74 _M_decimal_point = __mp.decimal_point();
75 _M_thousands_sep = __mp.thousands_sep();
76 _M_frac_digits = __mp.frac_digits();
79 _CharT* __curr_symbol = 0;
80 _CharT* __positive_sign = 0;
81 _CharT* __negative_sign = 0;
84 const string& __g = __mp.grouping();
85 _M_grouping_size = __g.size();
86 __grouping =
new char[_M_grouping_size];
87 __g.copy(__grouping, _M_grouping_size);
88 _M_use_grouping = (_M_grouping_size
89 &&
static_cast<signed char>(__grouping[0]) > 0
91 != __gnu_cxx::__numeric_traits<char>::__max));
93 const basic_string<_CharT>& __cs = __mp.curr_symbol();
94 _M_curr_symbol_size = __cs.size();
95 __curr_symbol =
new _CharT[_M_curr_symbol_size];
96 __cs.copy(__curr_symbol, _M_curr_symbol_size);
98 const basic_string<_CharT>& __ps = __mp.positive_sign();
99 _M_positive_sign_size = __ps.size();
100 __positive_sign =
new _CharT[_M_positive_sign_size];
101 __ps.copy(__positive_sign, _M_positive_sign_size);
103 const basic_string<_CharT>& __ns = __mp.negative_sign();
104 _M_negative_sign_size = __ns.size();
105 __negative_sign =
new _CharT[_M_negative_sign_size];
106 __ns.copy(__negative_sign, _M_negative_sign_size);
108 _M_pos_format = __mp.pos_format();
109 _M_neg_format = __mp.neg_format();
111 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
112 __ct.widen(money_base::_S_atoms,
113 money_base::_S_atoms + money_base::_S_end, _M_atoms);
115 _M_grouping = __grouping;
116 _M_curr_symbol = __curr_symbol;
117 _M_positive_sign = __positive_sign;
118 _M_negative_sign = __negative_sign;
123 delete [] __grouping;
124 delete [] __curr_symbol;
125 delete [] __positive_sign;
126 delete [] __negative_sign;
127 __throw_exception_again;
131_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
133 template<
typename _CharT,
typename _InIter>
136 money_get<_CharT, _InIter>::
137 _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
140 typedef char_traits<_CharT> __traits_type;
141 typedef typename string_type::size_type size_type;
142 typedef money_base::part part;
143 typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
145 const locale& __loc = __io._M_getloc();
146 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
148 __use_cache<__cache_type> __uc;
149 const __cache_type* __lc = __uc(__loc);
150 const char_type* __lit = __lc->_M_atoms;
153 bool __negative =
false;
155 size_type __sign_size = 0;
157 const bool __mandatory_sign = (__lc->_M_positive_sign_size
158 && __lc->_M_negative_sign_size);
160 string __grouping_tmp;
161 if (__lc->_M_use_grouping)
162 __grouping_tmp.reserve(32);
168 bool __testvalid =
true;
170 bool __testdecfound =
false;
176 const char_type* __lit_zero = __lit + money_base::_S_zero;
177 const money_base::pattern __p = __lc->_M_neg_format;
178 for (
int __i = 0; __i < 4 && __testvalid; ++__i)
180 const part __which =
static_cast<part
>(__p.field[__i]);
183 case money_base::symbol:
190 || (__i == 1 && (__mandatory_sign
191 || (
static_cast<part
>(__p.field[0])
193 || (
static_cast<part
>(__p.field[2])
194 == money_base::space)))
195 || (__i == 2 && ((
static_cast<part
>(__p.field[3])
196 == money_base::value)
198 && (
static_cast<part
>(__p.field[3])
199 == money_base::sign)))))
201 const size_type __len = __lc->_M_curr_symbol_size;
203 for (; __beg != __end && __j < __len
204 && *__beg == __lc->_M_curr_symbol[__j];
205 ++__beg, (void)++__j);
211 case money_base::sign:
213 if (__lc->_M_positive_sign_size && __beg != __end
214 && *__beg == __lc->_M_positive_sign[0])
216 __sign_size = __lc->_M_positive_sign_size;
219 else if (__lc->_M_negative_sign_size && __beg != __end
220 && *__beg == __lc->_M_negative_sign[0])
223 __sign_size = __lc->_M_negative_sign_size;
226 else if (__lc->_M_positive_sign_size
227 && !__lc->_M_negative_sign_size)
231 else if (__mandatory_sign)
234 case money_base::value:
237 for (; __beg != __end; ++__beg)
239 const char_type __c = *__beg;
240 const char_type* __q = __traits_type::find(__lit_zero,
244 __res += money_base::_S_atoms[__q - __lit];
247 else if (__c == __lc->_M_decimal_point
250 if (__lc->_M_frac_digits <= 0)
255 __testdecfound =
true;
257 else if (__lc->_M_use_grouping
258 && __c == __lc->_M_thousands_sep
264 __grouping_tmp +=
static_cast<char>(__n);
279 case money_base::space:
281 if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
286 case money_base::none:
289 for (; __beg != __end
290 && __ctype.is(ctype_base::space, *__beg); ++__beg);
296 if (__sign_size > 1 && __testvalid)
298 const char_type* __sign = __negative ? __lc->_M_negative_sign
299 : __lc->_M_positive_sign;
301 for (; __beg != __end && __i < __sign_size
302 && *__beg == __sign[__i]; ++__beg, (void)++__i);
304 if (__i != __sign_size)
311 if (__res.size() > 1)
313 const size_type __first = __res.find_first_not_of(
'0');
314 const bool __only_zeros = __first == string::npos;
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
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>
381 template<
typename _CharT,
typename _InIter>
387 typedef typename string::size_type size_type;
404 template<
typename _CharT,
typename _OutIter>
409 const string_type& __digits)
const
411 typedef typename string_type::size_type size_type;
412 typedef money_base::part part;
420 const char_type*
__lit = __lc->_M_atoms;
424 const char_type*
__beg = __digits.data();
426 money_base::pattern __p;
431 __p = __lc->_M_pos_format;
432 __sign = __lc->_M_positive_sign;
437 __p = __lc->_M_neg_format;
438 __sign = __lc->_M_negative_sign;
439 __sign_size = __lc->_M_negative_sign_size;
445 size_type __len = __ctype.scan_not(ctype_base::digit, __beg,
446 __beg + __digits.size()) - __beg;
453 __value.reserve(2 * __len);
457 long __paddec = __len - __lc->_M_frac_digits;
460 if (__lc->_M_frac_digits < 0)
462 if (__lc->_M_grouping_size)
464 __value.assign(2 * __paddec, char_type());
466 std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
468 __lc->_M_grouping_size,
469 __beg, __beg + __paddec);
470 __value.erase(__vend - &__value[0]);
473 __value.assign(__beg, __paddec);
477 if (__lc->_M_frac_digits > 0)
479 __value += __lc->_M_decimal_point;
481 __value.append(__beg + __paddec, __lc->_M_frac_digits);
485 __value.append(-__paddec, __lit[money_base::_S_zero]);
486 __value.append(__beg, __len);
493 __len = __value.size() + __sign_size;
495 ? __lc->_M_curr_symbol_size : 0);
498 __res.reserve(2 * __len);
500 const size_type __width =
static_cast<size_type
>(__io.
width());
504 for (
int __i = 0; __i < 4; ++__i)
506 const part __which =
static_cast<part
>(__p.field[__i]);
509 case money_base::symbol:
511 __res.append(__lc->_M_curr_symbol,
512 __lc->_M_curr_symbol_size);
514 case money_base::sign:
521 case money_base::value:
524 case money_base::space:
529 __res.append(__width - __len, __fill);
533 case money_base::none:
535 __res.append(__width - __len, __fill);
542 __res.append(__sign + 1, __sign_size - 1);
545 __len = __res.size();
550 __res.append(__width - __len, __fill);
553 __res.insert(0, __width - __len, __fill);
558 __s = std::__write(__s, __res.data(), __len);
564#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
565 && _GLIBCXX_USE_CXX11_ABI == 0
566 template<
typename _CharT,
typename _OutIter>
568 money_put<_CharT, _OutIter>::
569 __do_put(iter_type __s,
bool __intl, ios_base& __io, char_type __fill,
570 double __units)
const
571 {
return this->do_put(__s, __intl, __io, __fill, (
long double) __units); }
574 template<
typename _CharT,
typename _OutIter>
582#if _GLIBCXX_USE_C99_STDIO
601 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
603 int __len = std::__convert_from_v(_S_get_c_locale(),
__cs, 0,
"%.*Lf",
612 template<
typename _CharT,
typename _OutIter>
620_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
625 template<
typename _CharT,
typename _InIter>
628 {
return time_base::no_order; }
632 template<
typename _CharT,
typename _InIter>
653 if (__c ==
'E' || __c ==
'O')
698 const char_type*
__dt[2];
828 __timepunct_cache<_CharT>::_S_timezones,
853 if (__format[__i] == *__beg)
860 if (__tmperr || __i != __len)
866 template<
typename _CharT,
typename _InIter>
868 time_get<_CharT, _InIter>::
869 _M_extract_num(iter_type __beg, iter_type __end,
int& __member,
870 int __min,
int __max,
size_t __len,
873 const locale& __loc = __io._M_getloc();
874 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
877 int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1);
882 for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
884 const char __c = __ctype.narrow(*__beg,
'*');
885 if (__c >=
'0' && __c <=
'9')
887 __value = __value * 10 + (__c -
'0');
888 const int __valuec = __value * __mult;
889 if (__valuec > __max || __valuec + __mult < __min)
899 else if (__len == 4 && __i == 2)
900 __member = __value - 100;
909 template<
typename _CharT,
typename _InIter>
911 time_get<_CharT, _InIter>::
912 _M_extract_name(iter_type __beg, iter_type __end,
int& __member,
913 const _CharT** __names,
size_t __indexlen,
916 typedef char_traits<_CharT> __traits_type;
917 const locale& __loc = __io._M_getloc();
918 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
920 int* __matches =
static_cast<int*
>(__builtin_alloca(
sizeof(
int)
922 size_t __nmatches = 0;
924 bool __testvalid =
true;
925 const char_type* __name;
933 const char_type __c = *__beg;
934 for (
size_t __i1 = 0; __i1 < __indexlen; ++__i1)
935 if (__c == __names[__i1][0]
936 || __c == __ctype.toupper(__names[__i1][0]))
937 __matches[__nmatches++] = __i1;
940 while (__nmatches > 1)
943 size_t __minlen = __traits_type::length(__names[__matches[0]]);
944 for (
size_t __i2 = 1; __i2 < __nmatches; ++__i2)
946 __traits_type::length(__names[__matches[__i2]]));
949 if (__pos < __minlen && __beg != __end)
950 for (
size_t __i3 = 0; __i3 < __nmatches;)
952 __name = __names[__matches[__i3]];
953 if (!(__name[__pos] == *__beg))
954 __matches[__i3] = __matches[--__nmatches];
967 __name = __names[__matches[0]];
968 const size_t __len = __traits_type::length(__name);
969 while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
970 ++__beg, (void)++__pos;
973 __member = __matches[0];
985 template<
typename _CharT,
typename _InIter>
987 time_get<_CharT, _InIter>::
988 _M_extract_wday_or_month(iter_type __beg, iter_type __end,
int& __member,
989 const _CharT** __names,
size_t __indexlen,
992 typedef char_traits<_CharT> __traits_type;
993 const locale& __loc = __io._M_getloc();
994 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
996 int* __matches =
static_cast<int*
>(__builtin_alloca(2 *
sizeof(
int)
998 size_t __nmatches = 0;
999 size_t* __matches_lengths = 0;
1004 const char_type __c = *__beg;
1005 for (
size_t __i = 0; __i < 2 * __indexlen; ++__i)
1006 if (__c == __names[__i][0]
1007 || __c == __ctype.toupper(__names[__i][0]))
1008 __matches[__nmatches++] = __i;
1017 =
static_cast<size_t*
>(__builtin_alloca(
sizeof(
size_t)
1019 for (
size_t __i = 0; __i < __nmatches; ++__i)
1020 __matches_lengths[__i]
1021 = __traits_type::length(__names[__matches[__i]]);
1024 for (; __beg != __end; ++__beg, (void)++__pos)
1026 size_t __nskipped = 0;
1027 const char_type __c = *__beg;
1028 for (
size_t __i = 0; __i < __nmatches;)
1030 const char_type* __name = __names[__matches[__i]];
1031 if (__pos >= __matches_lengths[__i])
1032 ++__nskipped, ++__i;
1033 else if (!(__name[__pos] == __c))
1036 __matches[__i] = __matches[__nmatches];
1037 __matches_lengths[__i] = __matches_lengths[__nmatches];
1042 if (__nskipped == __nmatches)
1046 if ((__nmatches == 1 && __matches_lengths[0] == __pos)
1047 || (__nmatches == 2 && (__matches_lengths[0] == __pos
1048 || __matches_lengths[1] == __pos)))
1049 __member = (__matches[0] >= __indexlen
1050 ? __matches[0] - __indexlen : __matches[0]);
1057 template<
typename _CharT,
typename _InIter>
1074 template<
typename _CharT,
typename _InIter>
1091 template<
typename _CharT,
typename _InIter>
1117 template<
typename _CharT,
typename _InIter>
1143 template<
typename _CharT,
typename _InIter>
1164#if __cplusplus >= 201103L
1165 template<
typename _CharT,
typename _InIter>
1194 if (__c !=
'E' && __c !=
'O')
1217 while (
__s != __end &&
1237 template<
typename _CharT,
typename _InIter>
1271 template<
typename _CharT,
typename _OutIter>
1275 const _CharT*
__beg,
const _CharT* __end)
const
1285 else if (++
__beg != __end)
1290 if (__c !=
'E' && __c !=
'O')
1292 else if (++
__beg != __end)
1306 template<
typename _CharT,
typename _OutIter>
1349#if _GLIBCXX_EXTERN_TEMPLATE
1354 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_get<char>;
1355 extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11
money_put<char>;
1424#ifdef _GLIBCXX_USE_WCHAR_T
1501_GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
Basis for explicit traits specializations.
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...
fmtflags flags() const
Access to format flags.
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
static const iostate goodbit
Indicates all is well.
streamsize width() const
Flags access.
static const fmtflags left
Adds fill characters on the right (final positions) of certain generated output. (I....
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.
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.
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.
static locale::id id
Numpunct facet id.
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.