istream.tcc

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

TCC
1,240
字号
	      // 27.6.1.2.1 Common requirements.	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      return *this;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&     basic_istream<_CharT, _Traits>::    operator>>(void*& __n)    {      sentry __cerb(*this, false);      if (__cerb) 	{	  try 	    {	      ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);	      if (_M_check_facet(_M_fnumget))		_M_fnumget->get(*this, 0, *this, __err, __n);	      this->setstate(__err);	    }	  catch(exception& __fail)	    {	      // 27.6.1.2.1 Common requirements.	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      return *this;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&     basic_istream<_CharT, _Traits>::    operator>>(__streambuf_type* __sbout)    {      streamsize __xtrct = 0;      __streambuf_type* __sbin = this->rdbuf();      sentry __cerb(*this, false);      if (__sbout && __cerb)	__xtrct = __copy_streambufs(*this, __sbin, __sbout);      if (!__sbout || !__xtrct)	this->setstate(ios_base::failbit);      return *this;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>::int_type    basic_istream<_CharT, _Traits>::    get(void)    {      const int_type __eof = traits_type::eof();      int_type __c = __eof;      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb) 	{	  try 	    {	      __c = this->rdbuf()->sbumpc();	      // 27.6.1.1 paragraph 3	      if (__c != __eof)		_M_gcount = 1;	      else		this->setstate(ios_base::eofbit | ios_base::failbit);	    }	  catch(exception& __fail)	    {	      // 27.6.1.3 paragraph 1	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      return __c;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&    basic_istream<_CharT, _Traits>::    get(char_type& __c)    {      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb) 	{ 	  try 	    {	      const int_type __eof = traits_type::eof();	      int_type __bufval = this->rdbuf()->sbumpc();	      // 27.6.1.1 paragraph 3	      if (__bufval != __eof)		{		  _M_gcount = 1;		  __c = traits_type::to_char_type(__bufval);		}	      else		this->setstate(ios_base::eofbit | ios_base::failbit);	    }	  catch(exception& __fail)	    {	      // 27.6.1.3 paragraph 1	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      return *this;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&    basic_istream<_CharT, _Traits>::    get(char_type* __s, streamsize __n, char_type __delim)    {      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb && __n > 1) 	{	  try 	    {	      const int_type __idelim = traits_type::to_int_type(__delim);	      const int_type __eof = traits_type::eof();	      __streambuf_type* __sb = this->rdbuf();	      int_type __c = __sb->sbumpc();		      bool __testdelim = __c == __idelim;	      bool __testeof =  __c == __eof;	      	      while (_M_gcount < __n - 1 && !__testeof && !__testdelim)		{		  *__s++ = traits_type::to_char_type(__c);		  ++_M_gcount;		  __c = __sb->sbumpc();		  __testeof = __c == __eof;		  __testdelim = __c == __idelim;		}	      if (__testdelim || _M_gcount == __n - 1)		__sb->sputbackc(__c);	      if (__testeof)		this->setstate(ios_base::eofbit);	    }	  catch(exception& __fail)	    {	      // 27.6.1.3 paragraph 1	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      *__s = char_type();      if (!_M_gcount)	this->setstate(ios_base::failbit);      return *this;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&    basic_istream<_CharT, _Traits>::    get(__streambuf_type& __sb, char_type __delim)    {      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb) 	{	  int_type __c;	  __streambuf_type* __this_sb = this->rdbuf();	  try 	    {	      const int_type __idelim = traits_type::to_int_type(__delim);	      const int_type __eof = traits_type::eof();	      	      __c = __this_sb->sbumpc();	      bool __testdelim = __c == __idelim;	      bool __testeof =  __c == __eof;	      bool __testput = true;	      	      while (!__testeof && !__testdelim 		    && (__testput = __sb.sputc(traits_type::to_char_type(__c)) 			 != __eof))		{		  ++_M_gcount;		  __c = __this_sb->sbumpc();		  __testeof = __c == __eof;		  __testdelim = __c == __idelim;		}	      if (__testdelim || !__testput)		__this_sb->sputbackc(traits_type::to_char_type(__c));	      if (__testeof)		this->setstate(ios_base::eofbit);	    }	  catch(exception& __fail)	    {	      // Exception may result from sputc->overflow.	      __this_sb->sputbackc(traits_type::to_char_type(__c));	    }	}      if (!_M_gcount)	this->setstate(ios_base::failbit);      return *this;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&    basic_istream<_CharT, _Traits>::    getline(char_type* __s, streamsize __n, char_type __delim)    {      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb) 	{          try 	    {	      __streambuf_type* __sb = this->rdbuf();	      int_type __c = __sb->sbumpc();	      ++_M_gcount;	      const int_type __idelim = traits_type::to_int_type(__delim);	      const int_type __eof = traits_type::eof();	      bool __testdelim = __c == __idelim;	      bool __testeof =  __c == __eof;	    	      while (_M_gcount < __n && !__testeof && !__testdelim)		{		  *__s++ = traits_type::to_char_type(__c);		  __c = __sb->sbumpc();		  ++_M_gcount;		  __testeof = __c == __eof;		  __testdelim = __c == __idelim;		}	      	      if (__testeof)		{		  --_M_gcount;		  this->setstate(ios_base::eofbit);		}	      else if (!__testdelim)		{		  --_M_gcount;		  __sb->sputbackc(traits_type::to_char_type(__c));		  this->setstate(ios_base::failbit);		}	    }	  catch(exception& __fail)	    {	      // 27.6.1.3 paragraph 1	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      *__s = char_type();      if (!_M_gcount)	this->setstate(ios_base::failbit);      return *this;    }    template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&    basic_istream<_CharT, _Traits>::    ignore(streamsize __n, int_type __delim)    {      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb && __n > 0) 	{	  try 	    {	      const int_type __idelim = traits_type::to_int_type(__delim);	      const int_type __eof = traits_type::eof();	      __streambuf_type* __sb = this->rdbuf();	      int_type __c = __sb->sbumpc();		      bool __testdelim = __c == __idelim;	      bool __testeof =  __c == __eof;	      	      __n = min(__n, numeric_limits<streamsize>::max());	      while (_M_gcount < __n - 1 && !__testeof && !__testdelim)		{		  ++_M_gcount;		  __c = __sb->sbumpc();		  __testeof = __c == __eof;		  __testdelim = __c == __idelim;		}	      if ((_M_gcount == __n - 1 && !__testeof) || __testdelim)		++_M_gcount;	      if (__testeof)		this->setstate(ios_base::eofbit);	    }	  catch(exception& __fail)	    {	      // 27.6.1.3 paragraph 1	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}      return *this;    }    template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>::int_type    basic_istream<_CharT, _Traits>::    peek(void)    {      int_type __c = traits_type::eof();      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb)	{	  try 	    { __c = this->rdbuf()->sgetc(); }	  catch(exception& __fail)	    {	      // 27.6.1.3 paragraph 1	      // Turn this on without causing an ios::failure to be thrown.	      this->setstate(ios_base::badbit);	      if ((this->exceptions() & ios_base::badbit) != 0)		__throw_exception_again;	    }	}       return __c;    }  template<typename _CharT, typename _Traits>    basic_istream<_CharT, _Traits>&    basic_istream<_CharT, _Traits>::    read(char_type* __s, streamsize __n)    {      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb) 	{	  if (__n > 0)	    {	      try 		{		  const int_type __eof = traits_type::eof();		  __streambuf_type* __sb = this->rdbuf();		  int_type __c = __sb->sbumpc();			  bool __testeof =  __c == __eof;		  		  while (_M_gcount < __n - 1 && !__testeof)		    {		      *__s++ = traits_type::to_char_type(__c);		      ++_M_gcount;		      __c = __sb->sbumpc();		      __testeof = __c == __eof;		    }		  if (__testeof)		    this->setstate(ios_base::eofbit | ios_base::failbit);		  else		    {		      // _M_gcount == __n - 1		      *__s++ = traits_type::to_char_type(__c);		      ++_M_gcount;		    }	    		}	      catch(exception& __fail)		{		  // 27.6.1.3 paragraph 1		  // Turn this on without causing an ios::failure to be thrown.		  this->setstate(ios_base::badbit);		  if ((this->exceptions() & ios_base::badbit) != 0)		    __throw_exception_again;		}	    }	}      else	this->setstate(ios_base::failbit);      return *this;    }    template<typename _CharT, typename _Traits>    streamsize     basic_istream<_CharT, _Traits>::    readsome(char_type* __s, streamsize __n)    {      const int_type __eof = traits_type::eof();      _M_gcount = 0;      sentry __cerb(*this, true);      if (__cerb) 	{	  if (__n > 0)	    {	      try 		{		  streamsize __num = this->rdbuf()->in_avail();		  if (__num != static_cast<streamsize>(__eof))		    {		      __num = min(__num, __n);		      _M_gcount = this->rdbuf()->sgetn(__s, __num);		    }		  else		    this->setstate(ios_base::eofbit);		    		}	      catch(exception& __fail)		{		  // 27.6.1.3 paragraph 1		  // Turn this on without causing an ios::failure to be thrown.		  this->setstate(ios_base::badbit);		  if ((this->exceptions() & ios_base::badbit) != 0)		    __throw_exception_again;		}	    }	}      else

⌨️ 快捷键说明

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