⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locale_facets.tcc

📁 openRisc2000编译链接器等,用于i386 cygwin
💻 TCC
📖 第 1 页 / 共 5 页
字号:
					_S_get_c_locale(), 0);      // If the buffer was not large enough, try again with the correct size.      if (__len >= __cs_size)	{	  __cs_size = __len + 1;	  __cs = static_cast<char*>(__builtin_alloca(__cs_size));	  __len = std::__convert_from_v(__cs, __cs_size, "%.*Lf", __units,					_S_get_c_locale(), 0);	}#else      // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.      const int __cs_size = numeric_limits<long double>::max_exponent10 + 3;      char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));      int __len = std::__convert_from_v(__cs, 0, "%.*Lf", __units,					_S_get_c_locale(), 0);#endif      _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)							   * __cs_size));      __ctype.widen(__cs, __cs + __len, __ws);      const string_type __digits(__ws, __len);      return __intl ? _M_insert<true>(__s, __io, __fill, __digits)	            : _M_insert<false>(__s, __io, __fill, __digits);    }  template<typename _CharT, typename _OutIter>    _OutIter    money_put<_CharT, _OutIter>::    do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,	   const string_type& __digits) const    { return __intl ? _M_insert<true>(__s, __io, __fill, __digits)	            : _M_insert<false>(__s, __io, __fill, __digits); }  // NB: Not especially useful. Without an ios_base object or some  // kind of locale reference, we are left clawing at the air where  // the side of the mountain used to be...  template<typename _CharT, typename _InIter>    time_base::dateorder    time_get<_CharT, _InIter>::do_date_order() const    { return time_base::no_order; }  // Expand a strftime format string and parse it.  E.g., do_get_date() may  // pass %m/%d/%Y => extracted characters.  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,			  ios_base::iostate& __err, tm* __tm,			  const _CharT* __format) const    {      const locale& __loc = __io._M_getloc();      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);      const size_t __len = char_traits<_CharT>::length(__format);      for (size_t __i = 0; __beg != __end && __i < __len && !__err; ++__i)	{	  if (__ctype.narrow(__format[__i], 0) == '%')	    {	      // Verify valid formatting code, attempt to extract.	      char __c = __ctype.narrow(__format[++__i], 0);	      int __mem = 0;	      if (__c == 'E' || __c == 'O')		__c = __ctype.narrow(__format[++__i], 0);	      switch (__c)		{		  const char* __cs;		  _CharT __wcs[10];		case 'a':		  // Abbreviated weekday name [tm_wday]		  const char_type*  __days1[7];		  __tp._M_days_abbreviated(__days1);		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,					  7, __io, __err);		  break;		case 'A':		  // Weekday name [tm_wday].		  const char_type*  __days2[7];		  __tp._M_days(__days2);		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,					  7, __io, __err);		  break;		case 'h':		case 'b':		  // Abbreviated month name [tm_mon]		  const char_type*  __months1[12];		  __tp._M_months_abbreviated(__months1);		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 					  __months1, 12, __io, __err);		  break;		case 'B':		  // Month name [tm_mon].		  const char_type*  __months2[12];		  __tp._M_months(__months2);		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 					  __months2, 12, __io, __err);		  break;		case 'c':		  // Default time and date representation.		  const char_type*  __dt[2];		  __tp._M_date_time_formats(__dt);		  __beg = _M_extract_via_format(__beg, __end, __io, __err, 						__tm, __dt[0]);		  break;		case 'd':		  // Day [01, 31]. [tm_mday]		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,					 __io, __err);		  break;		case 'e':		  // Day [1, 31], with single digits preceded by		  // space. [tm_mday]		  if (__ctype.is(ctype_base::space, *__beg))		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,					   1, __io, __err);		  else		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,					   2, __io, __err);		  break;		case 'D':		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]		  __cs = "%m/%d/%y";		  __ctype.widen(__cs, __cs + 9, __wcs);		  __beg = _M_extract_via_format(__beg, __end, __io, __err, 						__tm, __wcs);		  break;		case 'H':		  // Hour [00, 23]. [tm_hour]		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,					 __io, __err);		  break;		case 'I':		  // Hour [01, 12]. [tm_hour]		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,					 __io, __err);		  break;		case 'm':		  // Month [01, 12]. [tm_mon]		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, 					 __io, __err);		  if (!__err)		    __tm->tm_mon = __mem - 1;		  break;		case 'M':		  // Minute [00, 59]. [tm_min]		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,					 __io, __err);		  break;		case 'n':		  if (__ctype.narrow(*__beg, 0) == '\n')		    ++__beg;		  else		    __err |= ios_base::failbit;		  break;		case 'R':		  // Equivalent to (%H:%M).		  __cs = "%H:%M";		  __ctype.widen(__cs, __cs + 6, __wcs);		  __beg = _M_extract_via_format(__beg, __end, __io, __err, 						__tm, __wcs);		  break;		case 'S':		  // Seconds. [tm_sec]		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.#ifdef _GLIBCXX_USE_C99		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,#else		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,#endif					 __io, __err);		  break;		case 't':		  if (__ctype.narrow(*__beg, 0) == '\t')		    ++__beg;		  else		    __err |= ios_base::failbit;		  break;		case 'T':		  // Equivalent to (%H:%M:%S).		  __cs = "%H:%M:%S";		  __ctype.widen(__cs, __cs + 9, __wcs);		  __beg = _M_extract_via_format(__beg, __end, __io, __err, 						__tm, __wcs);		  break;		case 'x':		  // Locale's date.		  const char_type*  __dates[2];		  __tp._M_date_formats(__dates);		  __beg = _M_extract_via_format(__beg, __end, __io, __err, 						__tm, __dates[0]);		  break;		case 'X':		  // Locale's time.		  const char_type*  __times[2];		  __tp._M_time_formats(__times);		  __beg = _M_extract_via_format(__beg, __end, __io, __err, 						__tm, __times[0]);		  break;		case 'y':		case 'C': // C99		  // Two digit year. [tm_year]		  __beg = _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2,					 __io, __err);		  break;		case 'Y':		  // Year [1900). [tm_year]		  __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,					 __io, __err);		  if (!__err)		    __tm->tm_year = __mem - 1900;		  break;		case 'Z':		  // Timezone info.		  if (__ctype.is(ctype_base::upper, *__beg))		    {		      int __tmp;		      __beg = _M_extract_name(__beg, __end, __tmp,				       __timepunct_cache<_CharT>::_S_timezones,					      14, __io, __err);		      // GMT requires special effort.		      if (__beg != __end && !__err && __tmp == 0			  && (*__beg == __ctype.widen('-')			      || *__beg == __ctype.widen('+')))			{			  __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,						 __io, __err);			  __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,						 __io, __err);			}		    }		  else		    __err |= ios_base::failbit;		  break;		default:		  // Not recognized.		  __err |= ios_base::failbit;		}	    }	  else	    {	      // Verify format and input match, extract and discard.	      if (__format[__i] == *__beg)		++__beg;	      else		__err |= ios_base::failbit;	    }	}      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    _M_extract_num(iter_type __beg, iter_type __end, int& __member,		   int __min, int __max, size_t __len,		   ios_base& __io, ios_base::iostate& __err) const    {      const locale& __loc = __io._M_getloc();      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);      // As-is works for __len = 1, 2, 4, the values actually used.      int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1);      ++__min;      size_t __i = 0;      int __value = 0;      for (; __beg != __end && __i < __len; ++__beg, ++__i)	{	  const char __c = __ctype.narrow(*__beg, '*');	  if (__c >= '0' && __c <= '9')	    {	      __value = __value * 10 + (__c - '0');	      const int __valuec = __value * __mult;	      if (__valuec > __max || __valuec + __mult < __min)		break;	      __mult /= 10;	    }	  else	    break;	}      if (__i == __len)	__member = __value;      else	__err |= ios_base::failbit;      return __beg;    }  // Assumptions:  // All elements in __names are unique.  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    _M_extract_name(iter_type __beg, iter_type __end, int& __member,		    const _CharT** __names, size_t __indexlen,		    ios_base& __io, ios_base::iostate& __err) const    {      typedef char_traits<_CharT>		__traits_type;      const locale& __loc = __io._M_getloc();      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);      int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)							  * __indexlen));      size_t __nmatches = 0;      size_t __pos = 0;      bool __testvalid = true;      const char_type* __name;      // Look for initial matches.      // NB: Some of the locale data is in the form of all lowercase      // names, and some is in the form of initially-capitalized      // names. Look for both.      if (__beg != __end)	{	  const char_type __c = *__beg;	  for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)	    if (__c == __names[__i1][0]		|| __c == __ctype.toupper(__names[__i1][0]))	      __matches[__nmatches++] = __i1;	}      while (__nmatches > 1)	{	  // Find smallest matching string.	  size_t __minlen = __traits_type::length(__names[__matches[0]]);	  for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)	    __minlen = std::min(__minlen,			      __traits_type::length(__names[__matches[__i2]]));	  ++__beg, ++__pos;	  if (__pos < __minlen && __beg != __end)	    for (size_t __i3 = 0; __i3 < __nmatches;)	      {		__name = __names[__matches[__i3]];		if (__name[__pos] != *__beg)		  __matches[__i3] = __matches[--__nmatches];		else		  ++__i3;	      }	  else	    break;	}      if (__nmatches == 1)	{	  // Make sure found name is completely extracted.	  ++__beg, ++__pos;	  __name = __names[__matches[0]];	  const size_t __len = __traits_type::length(__name);	  while (__pos < __len && __beg != __end && __name[__pos] == *__beg)	    ++__beg, ++__pos;	  if (__len == __pos)	    __member = __matches[0];	  else	    __testvalid = false;	}      else	__testvalid = false;      if (!__testvalid)	__err |= ios_base::failbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    do_get_time(iter_type __beg, iter_type __end, ios_base& __io,		ios_base::iostate& __err, tm* __tm) const    {      const locale& __loc = __io._M_getloc();      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);      const char_type*  __times[2];      __tp._M_time_formats(__times);      __beg = _M_extract_via_format(__beg, __end, __io, __err, 				    __tm, __times[0]);      if (__beg == __end)	__err |= ios_base::eofbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    do_get_date(iter_type __beg, iter_type __end, ios_base& __io,		ios_base::iostate& __err, tm* __tm) const    {      const locale& __loc = __io._M_getloc();      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);      const char_type*  __dates[2];      __tp._M_date_formats(__dates);      __beg = _M_extract_via_format(__beg, __end, __io, __err,				    __tm, __dates[0]);      if (__beg == __end)	__err |= ios_base::eofbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,		   ios_base::iostate& __err, tm* __tm) const    {      typedef char_traits<_CharT>		__traits_type;      const locale& __loc = __io._M_getloc();      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);      const char_type*  __days[7];      __tp._M_days_abbreviated(__days);      int __tmpwday;      __beg = _M_extract_name(__beg, __end, __tmpwday, __days, 7, __io, __err);      // Check to see if non-abbreviated name exists, and extract.      // NB: Assumes both _M_days and _M_days_abbreviated organized in      // exact same order, first to last, such that the resulting      // __days array with the same index points to a day, and that

⌨️ 快捷键说明

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