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

📄 locale_facets.tcc

📁 gcc3.2.1源代码
💻 TCC
📖 第 1 页 / 共 5 页
字号:
		  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, char_type(), __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.      size_t __len = char_traits<char_type>::length(__res);      for (size_t __i = 0; __i < __len; ++__i, ++__s)	*__s = __res[__i];      return __s;    }  // 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    {       const string_type __one(__lo1, __hi1);      const string_type __two(__lo2, __hi2);      return _M_compare(__one.c_str(), __two.c_str());    } template<typename _CharT>    typename collate<_CharT>::string_type    collate<_CharT>::    do_transform(const _CharT* __lo, const _CharT* __hi) const    {      size_t __len = (__hi - __lo) * 2;      // First try a buffer perhaps big enough.      _CharT* __c =	static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));      size_t __res = _M_transform(__c, __lo, __len);      // If the buffer was not large enough, try again with the correct size.      if (__res >= __len)	{	  __c =	    static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__res + 1)));	  _M_transform(__c, __lo, __res + 1);	}      return string_type(__c);    } template<typename _CharT>    long    collate<_CharT>::    do_hash(const _CharT* __lo, const _CharT* __hi) const    {       unsigned long __val = 0;      for (; __lo < __hi; ++__lo)	__val = *__lo + ((__val << 7) | 		       (__val >> (numeric_limits<unsigned long>::digits - 7)));      return static_cast<long>(__val);    }  // Convert string to numeric value of type _Tv and store results.    // NB: This is specialized for all required types, there is no  // generic definition.  template<typename _Tv>    void    __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err, 		   const __c_locale& __cloc, int __base = 10);  // Convert numeric value of type _Tv to string and return length of string.  // If snprintf is available use it, otherwise fall back to the unsafe sprintf  // which, in general, can be dangerous and should be avoided.  template<typename _Tv>    int    __convert_from_v(char* __out, const int __size, const char* __fmt,		     _Tv __v, const __c_locale&, int __prec = -1);  // Construct correctly padded string, as per 22.2.2.2.2  // Assumes   // __newlen > __oldlen  // __news is allocated for __newlen size  // Used by both num_put and ostream inserters: if __num,  // internal-adjusted objects are padded according to the rules below  // concerning 0[xX] and +-, otherwise, exactly as right-adjusted  // ones are.  // NB: Of the two parameters, _CharT can be deduced from the  // function arguments. The other (_Traits) has to be explicitly specified.  template<typename _CharT, typename _Traits>    struct __pad    {      static void      _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, 	     const _CharT* __olds, const streamsize __newlen, 	     const streamsize __oldlen, const bool __num);    };  template<typename _CharT, typename _Traits>    void     __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, 				   _CharT* __news, const _CharT* __olds, 				   const streamsize __newlen, 				   const streamsize __oldlen, const bool __num)    {      size_t __plen = static_cast<size_t>(__newlen - __oldlen);      _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __plen));      _Traits::assign(__pads, __plen, __fill);       _CharT* __beg;      _CharT* __end;      size_t __mod = 0;      size_t __beglen; //either __plen or __oldlen      ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;      if (__adjust == ios_base::left)	{	  // Padding last.	  __beg = const_cast<_CharT*>(__olds);	  __beglen = __oldlen;	  __end = __pads;	}      else if (__adjust == ios_base::internal && __num)	{	  // Pad after the sign, if there is one.	  // Pad after 0[xX], if there is one.	  // Who came up with these rules, anyway? Jeeze.          locale __loc = __io.getloc();	  const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 	  const _CharT __minus = __ctype.widen('-');	  const _CharT __plus = __ctype.widen('+');	  bool __testsign = _Traits::eq(__olds[0], __minus)	    		    || _Traits::eq(__olds[0], __plus);	  bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0]) 	    		   && (_Traits::eq(__ctype.widen('x'), __olds[1]) 			       || _Traits::eq(__ctype.widen('X'), __olds[1]));	  if (__testhex)	    {	      __news[0] = __olds[0]; 	      __news[1] = __olds[1];	      __mod += 2;	      __news += 2;	      __beg = __pads;	      __beglen = __plen;	      __end = const_cast<_CharT*>(__olds + __mod);	    }	  else if (__testsign)	    {	   

⌨️ 快捷键说明

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