?? istream
字號:
// istream standard header
#if _MSC_VER > 1000 /*IFSTRIP=IGN*/
#pragma once
#endif
#ifndef _ISTREAM_
#define _ISTREAM_
#include <ostream>
#ifdef _MSC_VER
#pragma pack(push,8)
#endif /* _MSC_VER */
_STD_BEGIN
// TEMPLATE CLASS basic_istream
template<class _E, class _Tr = char_traits<_E> >
class basic_istream : virtual public basic_ios<_E, _Tr> {
public:
typedef basic_istream<_E, _Tr> _Myt;
typedef basic_ios<_E, _Tr> _Myios;
typedef basic_streambuf<_E, _Tr> _Mysb;
typedef istreambuf_iterator<_E, _Tr> _Iter;
typedef ctype<_E> _Ctype;
typedef num_get<_E, _Iter> _Nget;
explicit basic_istream(_Mysb *_S, bool _Isstd = false)
: _Chcount(0) {init(_S, _Isstd); }
basic_istream(_Uninitialized)
{_Addstd(); }
virtual ~basic_istream()
{}
class sentry {
public:
explicit sentry(_Myt& _Is, bool _Noskip = false)
: _Ok(_Is.ipfx(_Noskip)) {}
operator bool() const
{return (_Ok); }
private:
bool _Ok;
};
bool ipfx(bool _Noskip = false)
{if (good())
{if (tie() != 0)
tie()->flush();
if (!_Noskip && flags() & skipws)
{const _Ctype& _Fac = _USE(getloc(), _Ctype);
_TRY_IO_BEGIN
int_type _C = rdbuf()->sgetc();
while (!_Tr::eq_int_type(_Tr::eof(), _C)
&& _Fac.is(_Ctype::space,
_Tr::to_char_type(_C)))
_C = rdbuf()->snextc();
_CATCH_IO_END }
if (good())
return (true); }
setstate(failbit);
return (false); }
void isfx()
{}
_Myt& operator>>(_Myt& (__cdecl *_F)(_Myt&))
{return ((*_F)(*this)); }
_Myt& operator>>(_Myios& (__cdecl *_F)(_Myios&))
{(*_F)(*(_Myios *)this);
return (*this); }
_Myt& operator>>(ios_base& (__cdecl *_F)(ios_base&))
{(*_F)(*(ios_base *)this);
return (*this); }
_Myt& operator>>(_Bool& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(short& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{long _Y;
const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _Y);
_CATCH_IO_END
if (_St & failbit || _Y < SHRT_MIN || SHRT_MAX < _Y)
_St |= failbit;
else
_X = (short)_Y; }
setstate(_St);
return (*this); }
_Myt& operator>>(unsigned short& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(int& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{long _Y;
const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _Y);
_CATCH_IO_END
if (_St & failbit || _Y < INT_MIN || INT_MAX < _Y)
_St |= failbit;
else
_X = _Y; }
setstate(_St);
return (*this); }
_Myt& operator>>(unsigned int& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(long& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(unsigned long& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(float& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(double& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(long double& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(void *& _X)
{iostate _St = goodbit;
const sentry _Ok(*this);
if (_Ok)
{const _Nget& _Fac = _USE(getloc(), _Nget);
_TRY_IO_BEGIN
_Fac.get(_Iter(rdbuf()), _Iter(0), *this, _St, _X);
_CATCH_IO_END }
setstate(_St);
return (*this); }
_Myt& operator>>(_Mysb *_Pb)
{iostate _St = goodbit;
bool _Copied = false;
const sentry _Ok(*this);
if (_Ok && _Pb != 0)
{_TRY_IO_BEGIN
int_type _C = rdbuf()->sgetc();
for (; ; _C = rdbuf()->snextc())
if (_Tr::eq_int_type(_Tr::eof(), _C))
{_St |= eofbit;
break; }
else
{_TRY_BEGIN
if (_Tr::eq_int_type(_Tr::eof(),
_Pb->sputc(_Tr::to_char_type(_C))))
break;
_CATCH_ALL
break;
_CATCH_END
_Copied = true; }
_CATCH_IO_END }
setstate(!_Copied ? _St | failbit : _St);
return (*this); }
int_type get()
{int_type _C;
iostate _St = goodbit;
_Chcount = 0;
const sentry _Ok(*this, true);
if (!_Ok)
_C = _Tr::eof();
else
{_TRY_IO_BEGIN
_C = rdbuf()->sbumpc();
if (_Tr::eq_int_type(_Tr::eof(), _C))
_St |= eofbit | failbit;
else
++_Chcount;
_CATCH_IO_END }
setstate(_St);
return (_C); }
_Myt& get(_E *_S, streamsize _N)
{return (get(_S, _N, widen('\n'))); }
_Myt& get(_E *_S, streamsize _N, _E _D)
{iostate _St = goodbit;
_Chcount = 0;
const sentry _Ok(*this, true);
if (_Ok && 0 < _N)
{_TRY_IO_BEGIN
int_type _C = rdbuf()->sgetc();
for (; 0 < --_N; _C = rdbuf()->snextc())
if (_Tr::eq_int_type(_Tr::eof(), _C))
{_St |= eofbit;
break; }
else if (_Tr::to_char_type(_C) == _D)
break;
else
*_S++ = _Tr::to_char_type(_C), ++_Chcount;
_CATCH_IO_END }
setstate(_Chcount == 0 ? _St | failbit : _St);
*_S = _E(0);
return (*this); }
_Myt& get(_E& _X)
{int_type _C = get();
if (!_Tr::eq_int_type(_Tr::eof(), _C))
_X = _Tr::to_char_type(_C);
return (*this); }
_Myt& get(_Mysb& _Sb)
{return (get(_Sb, widen('\n'))); }
_Myt& get(_Mysb& _Sb, _E _D)
{iostate _St = goodbit;
_Chcount = 0;
const sentry _Ok(*this, true);
if (_Ok)
{_TRY_IO_BEGIN
int_type _C = rdbuf()->sgetc();
for (; ; _C = rdbuf()->snextc())
if (_Tr::eq_int_type(_Tr::eof(), _C))
{_St |= eofbit;
break; }
else
{_TRY_BEGIN
_E _Ch = _Tr::to_char_type(_C);
if (_Ch == _D
|| _Tr::eq_int_type(_Tr::eof(),
_Sb.sputc(_Ch)))
break;
_CATCH_ALL
break;
_CATCH_END
++_Chcount; }
_CATCH_IO_END }
if (_Chcount == 0)
_St |= failbit;
setstate(_St);
return (*this); }
_Myt& getline(_E *_S, streamsize _N)
{return (getline(_S, _N, widen('\n'))); }
_Myt& getline(_E *_S, streamsize _N, _E _D)
{iostate _St = goodbit;
_Chcount = 0;
const sentry _Ok(*this, true);
if (_Ok && 0 < _N)
{int_type _Di = _Tr::to_int_type(_D);
_TRY_IO_BEGIN
int_type _C = rdbuf()->sgetc();
for (; ; _C = rdbuf()->snextc())
if (_Tr::eq_int_type(_Tr::eof(), _C))
{_St |= eofbit;
break; }
else if (_C == _Di)
{++_Chcount;
rdbuf()->stossc();
break; }
else if (--_N <= 0)
{_St |= failbit;
break; }
else
{++_Chcount;
*_S++ = _Tr::to_char_type(_C); }
_CATCH_IO_END }
*_S = _E(0);
setstate(_Chcount == 0 ? _St | failbit : _St);
return (*this); }
_Myt& ignore(streamsize _N = 1, int_type _Di = _Tr::eof())
{iostate _St = goodbit;
_Chcount = 0;
const sentry _Ok(*this, true);
if (_Ok && 0 < _N)
{_TRY_IO_BEGIN
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -