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

📄 locale_facets.tcc

📁 俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)的全部源代码。
💻 TCC
📖 第 1 页 / 共 5 页
字号:
		  const char_type*  __times[2];		  __tp._M_time_formats(__times);		  _M_extract_via_format(__beg, __end, __io, __err, __tm, 					__times[0]);		  break;		case 'y':		  // Two digit year. [tm_year]		  _M_extract_num(__beg, __end, __tm->tm_year, 0, 99, 2, 				 __ctype, __err);		  break;		case 'Y':		  // Year [1900). [tm_year]		  _M_extract_num(__beg, __end, __mem, 0, 				 numeric_limits<int>::max(), 4, 				 __ctype, __err);		  if (!__err)		    __tm->tm_year = __mem - 1900;		  break;		case 'Z':		  // Timezone info.		  if (__ctype.is(ctype_base::upper, *__beg))		    {		      int __tmp;		      _M_extract_name(__beg, __end, __tmp, 				      __timepunct<_CharT>::_S_timezones, 				      14, __err);		      		      // GMT requires special effort.		      char_type __c = *__beg;		      if (!__err && __tmp == 0 			  && (__c == __ctype.widen('-') 			      || __c == __ctype.widen('+')))			{			  _M_extract_num(__beg, __end, __tmp, 0, 23, 2,					  __ctype, __err);			  _M_extract_num(__beg, __end, __tmp, 0, 59, 2,					  __ctype, __err);			}	    			  }		      else			__err |= ios_base::failbit;		      break;		    default:		      // Not recognized.		      __err |= ios_base::failbit;		    }		}	      else		{		  // Verify format and input match, extract and discard.		  if (__c == __ctype.narrow(*__beg, 0))		    ++__beg;		  else		    __err |= ios_base::failbit;		}	}    }  template<typename _CharT, typename _InIter>    void    time_get<_CharT, _InIter>::    _M_extract_num(iter_type& __beg, iter_type& __end, int& __member,		   int __min, int __max, size_t __len, 		   const ctype<_CharT>& __ctype, 		   ios_base::iostate& __err) const    {      size_t __i = 0;      string __digits;      bool __testvalid = true;      char_type __c = *__beg;      while (__beg != __end && __i < __len 	     && __ctype.is(ctype_base::digit, __c)) 	{	  __digits += __ctype.narrow(__c, 0);	  __c = *(++__beg);	  ++__i;	}      if (__i == __len)	{	  int __value = atoi(__digits.c_str());	  if (__min <= __value && __value <= __max)	    __member = __value;	  else	    __testvalid = false;	}      else	__testvalid = false;      if (!__testvalid)	__err |= ios_base::failbit;    }  // Assumptions:  // All elements in __names are unique.  template<typename _CharT, typename _InIter>    void    time_get<_CharT, _InIter>::    _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,		    const _CharT** __names, size_t __indexlen, 		    ios_base::iostate& __err) const    {      typedef char_traits<_CharT> 		__traits_type;      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;      char_type __c = *__beg;      // Look for initial matches.      for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)	if (__c == __names[__i1][0])	  __matches[__nmatches++] = __i1;            while (__nmatches > 1)	{	  // Find smallest matching string.	  size_t __minlen = 10;	  for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)	    __minlen = min(__minlen,			   __traits_type::length(__names[__matches[__i2]]));	  	  if (__pos < __minlen && __beg != __end)	    {	      ++__pos;	      __c = *(++__beg);	      for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)		{		  __name = __names[__matches[__i3]];		  if (__name[__pos] != __c)		    __matches[__i3] = __matches[--__nmatches];		}	    }	  else	    break;	}      if (__nmatches == 1)	{	  // Make sure found name is completely extracted.	  __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;    }  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    {      _CharT __wcs[3];      const char* __cs = "%X";      locale __loc = __io.getloc();      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);      __ctype.widen(__cs, __cs + 3, __wcs);      _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);      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    {      _CharT __wcs[3];      const char* __cs = "%x";      locale __loc = __io.getloc();      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);      __ctype.widen(__cs, __cs + 3, __wcs);      _M_extract_via_format(__beg, __end, __io, __err, __tm, __wcs);      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;      locale __loc = __io.getloc();      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);      const char_type*  __days[7];      __tp._M_days_abbreviated(__days);      int __tmpwday;      _M_extract_name(__beg, __end, __tmpwday, __days, 7, __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      // day's abbreviated form.      // NB: Also assumes that an abbreviated name is a subset of the name.       if (!__err)	{	  size_t __pos = __traits_type::length(__days[__tmpwday]);	  __tp._M_days(__days);	  const char_type* __name = __days[__tmpwday];	  if (__name[__pos] == *__beg)	    {	      // Extract the rest of it.	      const size_t __len = __traits_type::length(__name);	      while (__pos < __len && __beg != __end 		     && __name[__pos] == *__beg)		++__beg, ++__pos;	      if (__len != __pos)		__err |= ios_base::failbit;	    }	  if (!__err)	    __tm->tm_wday = __tmpwday;	}      if (__beg == __end)	__err |= ios_base::eofbit;      return __beg;     }  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    do_get_monthname(iter_type __beg, iter_type __end,                     ios_base& __io, ios_base::iostate& __err, tm* __tm) const    {      typedef char_traits<_CharT> 		__traits_type;      locale __loc = __io.getloc();      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);      const char_type*  __months[12];      __tp._M_months_abbreviated(__months);      int __tmpmon;      _M_extract_name(__beg, __end, __tmpmon, __months, 12, __err);      // Check to see if non-abbreviated name exists, and extract.      // NB: Assumes both _M_months and _M_months_abbreviated organized in      // exact same order, first to last, such that the resulting      // __months array with the same index points to a month, and that      // month's abbreviated form.      // NB: Also assumes that an abbreviated name is a subset of the name.       if (!__err)	{	  size_t __pos = __traits_type::length(__months[__tmpmon]);	  __tp._M_months(__months);	  const char_type* __name = __months[__tmpmon];	  if (__name[__pos] == *__beg)	    {	      // Extract the rest of it.	      const size_t __len = __traits_type::length(__name);	      while (__pos < __len && __beg != __end 		     && __name[__pos] == *__beg)		++__beg, ++__pos;	      if (__len != __pos)		__err |= ios_base::failbit;	    }	  if (!__err)	    __tm->tm_mon = __tmpmon;	}       if (__beg == __end)	__err |= ios_base::eofbit;      return __beg;    }  template<typename _CharT, typename _InIter>    _InIter    time_get<_CharT, _InIter>::    do_get_year(iter_type __beg, iter_type __end, ios_base& __io, 		ios_base::iostate& __err, tm* __tm) const    {      locale __loc = __io.getloc();      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);       char_type __c = *__beg;      size_t __i = 0;      string __digits;      while (__i < 4 && __beg != __end && __ctype.is(ctype_base::digit, __c))	{	  __digits += __ctype.narrow(__c, 0);	  __c = *(++__beg);	  ++__i;	}      if (__i == 2 || __i == 4)	{	  long __l;	  __convert_to_v(__digits.c_str(), __l, __err, _S_c_locale);	  if (!(__err & ios_base::failbit) && __l <= INT_MAX)	    {	      __l = __i == 2 ? __l : __l - 1900; 	      __tm->tm_year = static_cast<int>(__l);	    }	}      else	__err |= ios_base::failbit;      if (__beg == __end)	__err |= ios_base::eofbit;      return __beg;    }  template<typename _CharT, typename _OutIter>    _OutIter    time_put<_CharT, _OutIter>::    put(iter_type __s, ios_base& __io, char_type, const tm* __tm, 	const _CharT* __beg, const _CharT* __end) const    {      locale __loc = __io.getloc();      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);      while (__beg != __end)	{	  char __c = __ctype.narrow(*__beg, 0);	  ++__beg;	  if (__c == '%')	    {	      char __format;	      char __mod = 0;	      size_t __len = 1; 	      __c = __ctype.narrow(*__beg, 0);	      ++__beg;	      if (__c == 'E' || __c == 'O')		{		  __mod = __c;		  __format = __ctype.narrow(*__beg, 0);		  ++__beg;		}	      else		__format = __c;	      __s = this->do_put(__s, __io, _CharT(), __tm, __format, __mod);	    }	  else	    {	      *__s = __c;	      ++__s;	    }	}      return __s;    }  template<typename _CharT, typename _OutIter>    _OutIter    time_put<_CharT, _OutIter>::    do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm, 	   char __format, char __mod) const    {       locale __loc = __io.getloc();      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);      // NB: This size is arbitrary. Should this be a data member,      // initialized at construction?      const size_t __maxlen = 64;      char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));      // NB: In IEE 1003.1-200x, and perhaps other locale models, it      // is possible that the format character will be longer than one      // character. Possibilities include 'E' or 'O' followed by a      // format character: if __mod is not the default argument, assume      // it's a valid modifier.      char_type __fmt[4];      __fmt[0] = __ctype.widen('%');       if (!__mod)	{	  __fmt[1] = __format;	  __fmt[2] = char_type();	}      else	{	  __fmt[1] = __mod;	  __fmt[2] = __format;	  __fmt[3] = char_type();	}      __tp._M_put(__res, __maxlen, __fmt, __tm);      // Write resulting, fully-formatted string to output iterator.      return __write(__s, __res, char_traits<char_type>::length(__res));    }  // Generic version does nothing.  template<typename _CharT>    int    collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const    { return 0; }  // Generic version does nothing.  template<typename _CharT>    size_t    collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const    { return 0; }  template<typename _CharT>    int    collate<_CharT>::    do_compare(const _CharT* __lo1, const _CharT* __hi1, 	       const _CharT* __lo2, const _CharT* __hi2) const    {       // strcoll assumes zero-terminated strings so we make a copy      // and then put a zero at the end.      const string_type __one(__lo1, __hi1);      const string_type __two(__lo2, __hi2);      const _CharT* __p = __one.c_str();      const _CharT* __pend = __one.c_str() + __one.length(

⌨️ 快捷键说明

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