30#ifndef _LOCALE_FACETS_TCC
31#define _LOCALE_FACETS_TCC 1
34#pragma GCC system_header
36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wc++11-extensions"
45 template<
typename _Facet>
53 template<
typename _CharT>
80 template<
typename _CharT>
87 _CharT* __truename = 0;
88 _CharT* __falsename = 0;
96 &&
static_cast<signed char>(__grouping[0]) > 0
128 delete [] __grouping;
129 delete [] __truename;
130 delete [] __falsename;
145 const string& __grouping_tmp)
throw ();
149 template<
typename _CharT,
typename _InIter>
160 const __cache_type* __lc = __uc(__loc);
161 const _CharT* __lit = __lc->_M_atoms_in;
165 bool __testeof = __beg == __end;
173 && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
174 && !(__c == __lc->_M_decimal_point))
176 __xtrc +=
__plus ?
'+' :
'-';
177 if (++__beg != __end)
185 bool __found_mantissa =
false;
189 if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
190 || __c == __lc->_M_decimal_point)
194 if (!__found_mantissa)
197 __found_mantissa =
true;
201 if (++__beg != __end)
211 bool __found_dec =
false;
212 bool __found_sci =
false;
213 string __found_grouping;
214 if (__lc->_M_use_grouping)
218 if (!__lc->_M_allocated)
222 const int __digit =
_M_find(__lit_zero, 10, __c);
225 __xtrc +=
'0' + __digit;
226 __found_mantissa =
true;
228 else if (__c == __lc->_M_decimal_point
229 && !__found_dec && !__found_sci)
236 && !__found_sci && __found_mantissa)
243 if (++__beg != __end)
248 __xtrc +=
__plus ?
'+' :
'-';
261 if (++__beg != __end)
271 if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
273 if (!__found_dec && !__found_sci)
279 __found_grouping +=
static_cast<char>(__sep_pos);
293 else if (__c == __lc->_M_decimal_point)
295 if (!__found_dec && !__found_sci)
300 if (__found_grouping.
size())
301 __found_grouping +=
static_cast<char>(__sep_pos);
311 __traits_type::find(__lit_zero, 10, __c);
314 __xtrc +=
'0' + (__q - __lit_zero);
315 __found_mantissa =
true;
320 && !__found_sci && __found_mantissa)
323 if (__found_grouping.
size() && !__found_dec)
324 __found_grouping +=
static_cast<char>(__sep_pos);
329 if (++__beg != __end)
334 && !(__lc->_M_use_grouping
335 && __c == __lc->_M_thousands_sep)
336 && !(__c == __lc->_M_decimal_point))
337 __xtrc +=
__plus ?
'+' :
'-';
351 if (++__beg != __end)
359 if (__found_grouping.
size())
362 if (!__found_dec && !__found_sci)
363 __found_grouping +=
static_cast<char>(__sep_pos);
366 __lc->_M_grouping_size,
374 template<
typename _CharT,
typename _InIter>
375 template<
typename _ValueT>
384 typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
388 const __cache_type* __lc = __uc(__loc);
389 const _CharT* __lit = __lc->_M_atoms_in;
396 int __base = __oct ? 8 : (__basefield ==
ios_base::hex ? 16 : 10);
399 bool __testeof = __beg == __end;
402 bool __negative =
false;
408 && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
409 && !(__c == __lc->_M_decimal_point))
411 if (++__beg != __end)
420 bool __found_zero =
false;
424 if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
425 || __c == __lc->_M_decimal_point)
428 && (!__found_zero || __base == 10))
432 if (__basefield == 0)
437 else if (__found_zero
441 if (__basefield == 0)
445 __found_zero =
false;
454 if (++__beg != __end)
471 string __found_grouping;
472 if (__lc->_M_use_grouping)
474 bool __testfail =
false;
475 bool __testoverflow =
false;
476 const __unsigned_type __max =
477 (__negative && __num_traits::__is_signed)
478 ? -
static_cast<__unsigned_type
>(__num_traits::__min)
479 : __num_traits::__max;
480 const __unsigned_type __smax = __max / __base;
481 __unsigned_type __result = 0;
485 if (!__lc->_M_allocated)
489 __digit =
_M_find(__lit_zero, __len, __c);
493 if (__result > __smax)
494 __testoverflow =
true;
498 __testoverflow |= __result > __max - __digit;
503 if (++__beg != __end)
513 if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep)
519 __found_grouping +=
static_cast<char>(__sep_pos);
528 else if (__c == __lc->_M_decimal_point)
533 __traits_type::find(__lit_zero, __len, __c);
537 __digit = __q - __lit_zero;
540 if (__result > __smax)
541 __testoverflow =
true;
545 __testoverflow |= __result > __max - __digit;
551 if (++__beg != __end)
559 if (__found_grouping.
size())
562 __found_grouping +=
static_cast<char>(__sep_pos);
565 __lc->_M_grouping_size,
572 if ((!__sep_pos && !__found_zero && !__found_grouping.
size())
578 else if (__testoverflow)
580 if (__negative && __num_traits::__is_signed)
581 __v = __num_traits::__min;
583 __v = __num_traits::__max;
587 __v = __negative ? -__result : __result;
596 template<
typename _CharT,
typename _InIter>
609 if (__l == 0 || __l == 1)
627 const __cache_type* __lc = __uc(__loc);
631 bool __donef = __lc->_M_falsename_size == 0;
632 bool __donet = __lc->_M_truename_size == 0;
633 bool __testeof =
false;
635 while (!__donef || !__donet)
646 __testf = __c == __lc->_M_falsename[__n];
648 if (!__testf && __donet)
652 __testt = __c == __lc->_M_truename[__n];
654 if (!__testt && __donef)
657 if (!__testt && !__testf)
663 __donef = !__testf || __n >= __lc->_M_falsename_size;
664 __donet = !__testt || __n >= __lc->_M_truename_size;
666 if (__testf && __n == __lc->_M_falsename_size && __n)
669 if (__testt && __n == __lc->_M_truename_size)
674 else if (__testt && __n == __lc->_M_truename_size && __n)
692 template<
typename _CharT,
typename _InIter>
707 template<
typename _CharT,
typename _InIter>
722#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
723 template<
typename _CharT,
typename _InIter>
731 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
739 template<
typename _CharT,
typename _InIter>
754 template<
typename _CharT,
typename _InIter>
762 const fmtflags __fmt = __io.
flags();
765#pragma GCC diagnostic push
766#pragma GCC diagnostic ignored "-Wlong-long"
768 <=
sizeof(
unsigned long)),
769 unsigned long,
unsigned long long>
::__type _UIntPtrType;
770#pragma GCC diagnostic pop
778 __v =
reinterpret_cast<void*
>(__ul);
782#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
783 && defined __LONG_DOUBLE_IEEE128__
784 template<
typename _CharT,
typename _InIter>
792 __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc);
802 template<
typename _CharT,
typename _OutIter>
806 _CharT* __new,
const _CharT* __cs,
int& __len)
const
812 __len =
static_cast<int>(__w);
817 template<
typename _CharT,
typename _ValueT>
822 _CharT* __buf = __bufend;
823 if (__builtin_expect(__dec,
true))
851 *--__buf = __lit[(__v & 0xf) + __case_offset];
856 return __bufend - __buf;
861 template<
typename _CharT,
typename _OutIter>
864 _M_group_int(
const char* __grouping,
size_t __grouping_size, _CharT __sep,
865 ios_base&, _CharT* __new, _CharT* __cs,
int& __len)
const
868 __grouping_size, __cs, __cs + __len);
872 template<
typename _CharT,
typename _OutIter>
873 template<
typename _ValueT>
880 typedef typename __add_unsigned<_ValueT>::__type __unsigned_type;
884 const __cache_type* __lc = __uc(__loc);
885 const _CharT* __lit = __lc->_M_atoms_out;
889 const int __ilen = 5 *
sizeof(_ValueT);
890 _CharT* __cs =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
898 const __unsigned_type __u = ((__v > 0 || !__dec)
899 ? __unsigned_type(__v)
900 : -__unsigned_type(__v));
901 int __len =
__int_to_char(__cs + __ilen, __u, __lit, __flags, __dec);
902 __cs += __ilen - __len;
905 if (__lc->_M_use_grouping)
909 _CharT* __cs2 =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
913 __lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len);
918 if (__builtin_expect(__dec,
true))
949 _CharT* __cs3 =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
951 _M_pad(__fill, __w, __io, __cs3, __cs, __len);
961 template<
typename _CharT,
typename _OutIter>
965 _CharT __sep,
const _CharT* __p, _CharT* __new,
966 _CharT* __cs,
int& __len)
const
971 const int __declen = __p ? __p - __cs : __len;
974 __cs, __cs + __declen);
977 int __newlen = __p2 - __new;
981 __newlen += __len - __declen;
996 template<
typename _CharT,
typename _OutIter>
997 template<
typename _ValueT>
1006 const __cache_type* __lc = __uc(__loc);
1011 const int __max_digits =
1020#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF
1022 const bool __use_prec =
1027 int __cs_size = __max_digits * 3;
1028 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
1031 __fbuf, __prec, __v);
1037 if (__len >= __cs_size)
1039 __cs_size = __len + 1;
1040 __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
1043 __fbuf, __prec, __v);
1051 const int __max_exp =
1060 const int __cs_size = __fixed ? __max_exp + __prec + 4
1061 : __max_digits * 2 + __prec;
1062 char* __cs =
static_cast<char*
>(__builtin_alloca(__cs_size));
1071 _CharT* __ws =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
1073 __ctype.
widen(__cs, __cs + __len, __ws);
1080 __wp = __ws + (__p - __cs);
1081 *__wp = __lc->_M_decimal_point;
1087 if (__lc->_M_use_grouping
1088 && (__wp || __len < 3 || (__cs[1] <=
'9' && __cs[2] <=
'9'
1089 && __cs[1] >=
'0' && __cs[2] >=
'0')))
1093 _CharT* __ws2 =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
1097 if (__cs[0] ==
'-' || __cs[0] ==
'+')
1105 __lc->_M_thousands_sep, __wp, __ws2 + __off,
1106 __ws + __off, __len);
1116 _CharT* __ws3 =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
1118 _M_pad(__fill, __w, __io, __ws3, __ws, __len);
1128 template<
typename _CharT,
typename _OutIter>
1136 const long __l = __v;
1144 const __cache_type* __lc = __uc(__loc);
1146 const _CharT* __name = __v ? __lc->_M_truename
1147 : __lc->_M_falsename;
1148 int __len = __v ? __lc->_M_truename_size
1149 : __lc->_M_falsename_size;
1156 =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
1180 template<
typename _CharT,
typename _OutIter>
1186#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
1187 template<
typename _CharT,
typename _OutIter>
1190 __do_put(iter_type __s,
ios_base& __io, char_type __fill,
double __v)
const
1191 {
return _M_insert_float(__s, __io, __fill,
char(), __v); }
1194 template<
typename _CharT,
typename _OutIter>
1198 long double __v)
const
1201 template<
typename _CharT,
typename _OutIter>
1205 const void* __v)
const
1212#pragma GCC diagnostic push
1213#pragma GCC diagnostic ignored "-Wlong-long"
1215 <=
sizeof(
unsigned long)),
1216 unsigned long,
unsigned long long>
::__type _UIntPtrType;
1217#pragma GCC diagnostic pop
1220 reinterpret_cast<_UIntPtrType
>(__v));
1221 __io.
flags(__flags);
1225#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
1226 && defined __LONG_DOUBLE_IEEE128__
1227 template<
typename _CharT,
typename _OutIter>
1232 {
return _M_insert_float(__s, __io, __fill,
'L', __v); }
1243 template<
typename _CharT,
typename _Traits>
1246 _CharT* __news,
const _CharT* __olds,
1249 const size_t __plen =
static_cast<size_t>(__newlen - __oldlen);
1255 _Traits::copy(__news, __olds, __oldlen);
1256 _Traits::assign(__news + __oldlen, __plen, __fill);
1269 if (__ctype.
widen(
'-') == __olds[0]
1270 || __ctype.
widen(
'+') == __olds[0])
1272 __news[0] = __olds[0];
1276 else if (__ctype.
widen(
'0') == __olds[0]
1278 && (__ctype.
widen(
'x') == __olds[1]
1279 || __ctype.
widen(
'X') == __olds[1]))
1281 __news[0] = __olds[0];
1282 __news[1] = __olds[1];
1288 _Traits::assign(__news, __plen, __fill);
1289 _Traits::copy(__news + __plen, __olds + __mod, __oldlen - __mod);
1292 template<
typename _CharT>
1295 const char* __gbeg,
size_t __gsize,
1296 const _CharT* __first,
const _CharT* __last)
1301 while (__last - __first > __gbeg[__idx]
1302 &&
static_cast<signed char>(__gbeg[__idx]) > 0
1305 __last -= __gbeg[__idx];
1306 __idx < __gsize - 1 ? ++__idx : ++__ctr;
1309 while (__first != __last)
1310 *__s++ = *__first++;
1315 for (
char __i = __gbeg[__idx]; __i > 0; --__i)
1316 *__s++ = *__first++;
1322 for (
char __i = __gbeg[__idx]; __i > 0; --__i)
1323 *__s++ = *__first++;
1331#if _GLIBCXX_EXTERN_TEMPLATE
1336 extern template class ctype_byname<char>;
1340 __try_use_facet<ctype<char> >(
const locale&) _GLIBCXX_NOTHROW;
1343 const numpunct<char>*
1344 __try_use_facet<numpunct<char> >(
const locale&) _GLIBCXX_NOTHROW;
1347 const num_put<char>*
1348 __try_use_facet<num_put<char> >(
const locale&) _GLIBCXX_NOTHROW;
1351 const num_get<char>*
1352 __try_use_facet<num_get<char> >(
const locale&) _GLIBCXX_NOTHROW;
1356 use_facet<ctype<char> >(
const locale&);
1359 const numpunct<char>&
1360 use_facet<numpunct<char> >(
const locale&);
1363 const num_put<char>&
1364 use_facet<num_put<char> >(
const locale&);
1367 const num_get<char>&
1368 use_facet<num_get<char> >(
const locale&);
1372 has_facet<ctype<char> >(
const locale&);
1376 has_facet<numpunct<char> >(
const locale&);
1380 has_facet<num_put<char> >(
const locale&);
1384 has_facet<num_get<char> >(
const locale&);
1386#ifdef _GLIBCXX_USE_WCHAR_T
1391 extern template class ctype_byname<wchar_t>;
1394 const ctype<wchar_t>*
1395 __try_use_facet<ctype<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1398 const numpunct<wchar_t>*
1399 __try_use_facet<numpunct<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1402 const num_put<wchar_t>*
1403 __try_use_facet<num_put<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1406 const num_get<wchar_t>*
1407 __try_use_facet<num_get<wchar_t> >(
const locale&) _GLIBCXX_NOTHROW;
1410 const ctype<wchar_t>&
1411 use_facet<ctype<wchar_t> >(
const locale&);
1414 const numpunct<wchar_t>&
1415 use_facet<numpunct<wchar_t> >(
const locale&);
1418 const num_put<wchar_t>&
1419 use_facet<num_put<wchar_t> >(
const locale&);
1422 const num_get<wchar_t>&
1423 use_facet<num_get<wchar_t> >(
const locale&);
1427 has_facet<ctype<wchar_t> >(
const locale&);
1431 has_facet<numpunct<wchar_t> >(
const locale&);
1435 has_facet<num_put<wchar_t> >(
const locale&);
1439 has_facet<num_get<wchar_t> >(
const locale&);
1446#pragma GCC diagnostic pop
#define __throw_exception_again
#define _GLIBCXX_NAMESPACE_LDBL
#define _GLIBCXX_DEFAULT_ABI_TAG
#define _GLIBCXX_VISIBILITY(V)
#define _GLIBCXX_BEGIN_NAMESPACE_LDBL
#define _GLIBCXX_END_NAMESPACE_LDBL
#define _GLIBCXX_END_NAMESPACE_VERSION
#define _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define _GLIBCXX_NAMESPACE_CXX11
class __attribute((__abi_tag__("cxx11"))) failure typedef _Ios_Fmtflags fmtflags
These are thrown to indicate problems with io.
const _Facet & use_facet(const locale &__loc)
Return a facet.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
void __convert_to_v(const char *, _Tp &, ios_base::iostate &, const __c_locale &)
ostreambuf_iterator< _CharT > __write(ostreambuf_iterator< _CharT > __s, const _CharT *__ws, int __len)
_CharT * __add_grouping(_CharT *__s, _CharT __sep, const char *__gbeg, size_t __gsize, const _CharT *__first, const _CharT *__last)
int __int_to_char(_CharT *__bufend, _ValueT __v, const _CharT *__lit, ios_base::fmtflags __flags, bool __dec)
int __convert_from_v(const __c_locale &__cloc, char *__out, const int __size, const char *__fmt,...)
bool __verify_grouping(const char *__grouping, size_t __grouping_size, const string &__grouping_tmp)
ISO C++ entities toplevel namespace is std.
constexpr const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
constexpr size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr void clear() noexcept
constexpr void reserve(size_type __res_arg)
Attempt to preallocate enough memory for specified number of characters.
constexpr size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
Managing sequences of characters and character-like objects.
static constexpr const char_type * find(const char_type *__s, std::size_t __n, const char_type &__a)
static constexpr char_type * copy(char_type *__s1, const char_type *__s2, std::size_t __n)
static constexpr void assign(char_type &__c1, const char_type &__c2)
Basis for explicit traits specializations.
_Ios_Iostate iostate
This is a bitmask type.
static const fmtflags hex
Converts integer input or generates integer output in hexadecimal base.
static const fmtflags uppercase
Replaces certain lowercase letters with their uppercase equivalents in generated output.
static const fmtflags basefield
A mask of dec|oct|hex. Useful for the 2-arg form of setf.
streamsize precision() const
Flags 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 fmtflags boolalpha
Insert/extract bool in alphabetic rather than numeric format.
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 fmtflags floatfield
A mask of scientific|fixed. Useful for the 2-arg form of setf.
static const iostate goodbit
Indicates all is well.
const locale & _M_getloc() const
Locale access.
streamsize width() const
Flags access.
static const fmtflags fixed
Generate floating-point output in fixed-point notation.
static const fmtflags oct
Converts integer input or generates integer output in octal base.
static const fmtflags left
Adds fill characters on the right (final positions) of certain generated output. (I....
static const fmtflags showpos
Generates a + sign in non-negative generated numeric output.
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.
The base of the I/O class hierarchy.
Container class for localization functionality.
static __c_locale _S_get_c_locale()
Localization functionality base class.
void _M_install_cache(const facet *, size_t)
static void _S_pad(ios_base &__io, _CharT __fill, _CharT *__news, const _CharT *__olds, streamsize __newlen, streamsize __oldlen)
char_type widen(char __c) const
Widen char to char_type.
Primary class template ctype facet.
static const char * _S_atoms_in
static void _S_format_float(const ios_base &__io, char *__fptr, char __mod)
static const char * _S_atoms_out
_CharT _M_atoms_out[__num_base::_S_oend]
const _CharT * _M_truename
const _CharT * _M_falsename
_CharT _M_atoms_in[__num_base::_S_iend]
void _M_cache(const locale &__loc)
string_type falsename() const
Return string representation of bool false.
string_type truename() const
Return string representation of bool true.
char_type decimal_point() const
Return decimal point character.
char_type thousands_sep() const
Return thousands separator character.
static locale::id id
Numpunct facet id.
string grouping() const
Return grouping specification.
Primary class template numpunct.
num_get(size_t __refs=0)
Constructor performs initialization.
__gnu_cxx::__enable_if< __is_char< _CharT2 >::__value, int >::__type _M_find(const _CharT2 *, size_t __len, _CharT2 __c) const
_InIter iter_type
Public typedefs.
iter_type _M_extract_int(iter_type, iter_type, ios_base &, ios_base::iostate &, _ValueT &) const
_CharT char_type
Public typedefs.
iter_type _M_extract_float(iter_type, iter_type, ios_base &, ios_base::iostate &, string &) const
Primary class template num_get.
iter_type _M_insert_int(iter_type, ios_base &__io, char_type __fill, _ValueT __v) const
void _M_pad(char_type __fill, streamsize __w, ios_base &__io, char_type *__new, const char_type *__cs, int &__len) const
void _M_group_int(const char *__grouping, size_t __grouping_size, char_type __sep, ios_base &__io, char_type *__new, char_type *__cs, int &__len) const
iter_type _M_insert_float(iter_type, ios_base &__io, char_type __fill, char __mod, _ValueT __v) const
num_put(size_t __refs=0)
Constructor performs initialization.
_CharT char_type
Public typedefs.
_OutIter iter_type
Public typedefs.
void _M_group_float(const char *__grouping, size_t __grouping_size, char_type __sep, const char_type *__p, char_type *__new, char_type *__cs, int &__len) const
Primary class template num_put.
const _Facet * operator()(const locale &__loc) const
static const _Value __max
static const bool __is_signed