locale_facets.tcc

来自「ARM Linux Tool 各种代码包括MTD」· TCC 代码 · 共 1,228 行 · 第 1/3 页

TCC
1,228
字号
      errno = 0;      long __l = strtol(__xtrc, &__sanity, __base);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __l;      else        __err |= ios_base::failbit;      return __beg;    }#ifdef _GLIBCPP_USE_LONG_LONG  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, long long& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 32 for      // integral types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      long long __ll = strtoll(__xtrc, &__sanity, __base);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __ll;      else        __err |= ios_base::failbit;      return __beg;    }#endif  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, unsigned short& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 32 for      // integral types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      unsigned long __ul = strtoul(__xtrc, &__sanity, __base);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0          && __ul <= USHRT_MAX)        __v = static_cast<unsigned short>(__ul);      else        __err |= ios_base::failbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, unsigned int& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 32 for      // integral types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      unsigned long __ul = strtoul(__xtrc, &__sanity, __base);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0          && __ul <= UINT_MAX)        __v = static_cast<unsigned int>(__ul);      else        __err |= ios_base::failbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, unsigned long& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 32 for      // integral types.      char __xtrc[32] = {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      unsigned long __ul = strtoul(__xtrc, &__sanity, __base);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __ul;      else        __err |= ios_base::failbit;      return __beg;    }#ifdef _GLIBCPP_USE_LONG_LONG  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, unsigned long long& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 32 for      // integral types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      unsigned long long __ull = strtoull(__xtrc, &__sanity, __base);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __ull;      else        __err |= ios_base::failbit;      return __beg;    }#endif  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, float& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 256 for      // floating-point types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, true);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;#ifdef _GLIBCPP_USE_C99      float __f = strtof(__xtrc, &__sanity);#else      float __f = static_cast<float>(strtod(__xtrc, &__sanity));#endif      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __f;      else        __err |= ios_base::failbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, double& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 256 for      // floating-point types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, true);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      double __d = strtod(__xtrc, &__sanity);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __d;      else        __err |= ios_base::failbit;      return __beg;    }#if defined(_GLIBCPP_USE_C99) && !defined(__hpux)  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, long double& __v) const    {      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 256 for      // floating-point types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, true);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      long double __ld = strtold(__xtrc, &__sanity);      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __ld;      else        __err |= ios_base::failbit;      return __beg;    }#else  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, long double& __v) const    {      // Stage 1: extract      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, true);      // Stage 2: determine a conversion specifier.      ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;      const char* __conv;      if (__basefield == ios_base::oct)        __conv = "%Lo";      else if (__basefield == ios_base::hex)        __conv = "%LX";      else if (__basefield == 0)        __conv = "%Li";      else        __conv = "%Lg";      // Stage 3: store results.      long double __ld;      int __p = sscanf(__xtrc, __conv, &__ld);      if (__p          && static_cast<typename __traits_type::int_type>(__p)        != __traits_type::eof())        __v = __ld;      else        __err |= ios_base::failbit;      return __beg;    }#endif  template<typename _CharT, typename _InIter>    _InIter    num_get<_CharT, _InIter>::    do_get(iter_type __beg, iter_type __end, ios_base& __io,           ios_base::iostate& __err, void*& __v) const    {      // Prepare for hex formatted input      typedef ios_base::fmtflags        fmtflags;      fmtflags __fmt = __io.flags();      fmtflags __fmtmask = ~(ios_base::showpos | ios_base::basefield                             | ios_base::uppercase | ios_base::internal);      __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));      // Stage 1: extract and determine the conversion specifier.      // Assuming leading zeros eliminated, thus the size of 32 for      // integral types.      char __xtrc[32]= {'\0'};      int __base;      _M_extract(__beg, __end, __io, __err, __xtrc, __base, false);      // Stage 2: convert and store results.      char* __sanity;      errno = 0;      void* __vp = reinterpret_cast<void*>(strtoul(__xtrc, &__sanity, __base));      if (!(__err & ios_base::failbit)          && __sanity != __xtrc && *__sanity == '\0' && errno == 0)        __v = __vp;      else        __err |= ios_base::failbit;      // Reset from hex formatted input      __io.flags(__fmt);      return __beg;    }  // __pad is specialized for ostreambuf_iterator, random access iterator.  template <typename _CharT, typename _OutIter>    inline _OutIter    __pad(_OutIter __s, _CharT __fill, int __padding);  template <typename _CharT, typename _RaIter>    _RaIter    __pad(_RaIter __s, _CharT __fill, int __padding, 	  random_access_iterator_tag)    {      fill_n(__s, __fill);      return __s + __padding;    }  template <typename _CharT, typename _OutIter, typename _Tag>    _OutIter    __pad(_OutIter __s, _CharT __fill, int __padding, _Tag)    {      while (--__padding >= 0) { *__s = __fill; ++__s; }      return __s;    }  template <typename _CharT, typename _OutIter>    inline _OutIter    __pad(_OutIter __s, _CharT __fill, int __padding)    {      return __pad(__s, __fill, __padding, 		   typename iterator_traits<_OutIter>::iterator_category());    }  template <typename _CharT, typename _OutIter>    _OutIter    __pad_numeric(_OutIter __s, ios_base::fmtflags /*__flags*/,		  _CharT /*__fill*/, int /*__width*/, 		  _CharT const* /*__first*/, _CharT const* /*__middle*/, 		  _CharT const* /*__last*/)  {      // XXX Not currently done: non streambuf_iterator      return __s;    }  // Partial specialization for ostreambuf_iterator.  template <typename _CharT>       ostreambuf_iterator<_CharT>    __pad_numeric(ostreambuf_iterator<_CharT> __s, ios_base::fmtflags __flags,		  _CharT __fill, int __width, _CharT const* __first,		  _CharT const* __middle, _CharT const* __last)    {      typedef ostreambuf_iterator<_CharT> 	__out_iter;      int __padding = __width - (__last - __first);      if (__padding < 0)        __padding = 0;      ios_base::fmtflags __aflags = __flags & ios_base::adjustfield;      bool __testfield = __padding == 0 || __aflags == ios_base::left                         || __aflags == ios_base::internal;      // This was needlessly complicated.      if (__first != __middle)        {          if (!__testfield)            {              __pad(__s, __fill, __padding);              __padding = 0;            }          copy(__first, __middle, __s);        }      __out_iter __s2 = __s;      if (__padding && __aflags != ios_base::left)        {          __pad(__s2, __fill, __padding);          __padding = 0;        }      __out_iter __s3 = copy(__middle, __last, __s2);      if (__padding)        __pad(__s3, __fill, __padding);      return __s3;    }  template <typename _CharT, typename _OutIter>    _OutIter    num_put<_CharT, _OutIter>::    do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const    {      const _Format_cache<_CharT>* __fmt = _Format_cache<_CharT>::_S_get(__io);      ios_base::fmtflags __flags = __io.flags();      if ((__flags & ios_base::boolalpha) == 0)        {          unsigned long __uv = __v;          return __output_integer(__s, __io, __fill, false, __uv);        }      else        {          const char_type* __first;          const char_type* __last;          if (__v)            {              __first = __fmt->_M_truename.data();              __last = __first + __fmt->_M_truename.size();            }          else            {              __first = __fmt->_M_falsename.data();              __last = __first + __fmt->_M_falsename.size();            }          copy(__first, __last, __s);        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?