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

📄 istream

📁 realview22.rar
💻
📖 第 1 页 / 共 2 页
字号:
    basic_istream& read (char_type*, streamsize, int_type, int);

    // 27.6.1.3, p28: extract at most n, fail on eof
    basic_istream& read (char_type*, streamsize);

    // 27.6.1.3, p30: extract at most min (rdbuf()->in_avail(), n))
    streamsize readsome (char_type*, streamsize);

    // 27.6.1.3, p27
    int_type peek ();
      
    // 27.6.1.3, p37
    pos_type tellg ();

    // 27.6.1.3, p38
    basic_istream& seekg (pos_type);

    // 27.6.1.3, p40
    basic_istream& seekg (off_type, ios_base::seekdir);

    // 27.6.1.3, p36
    int sync ();

    // 27.6.1.3, p32
    basic_istream& putback (char_type);

    // 27.6.1.3, p34
    basic_istream& unget ();

    // 27.6.1.3, p2
    streamsize gcount () const {
        return _C_chcount;
    }

    // flags used by read() extension and _C_unsafe_get()
    enum {
        _C_nullterm = 0x01,   // null-terminate input
        _C_wsterm   = 0x02,   // terminate input on whitespace
        _C_skipws   = 0x04,   // skip leading whitespace
        _C_eatdelim = 0x08,   // extract delimiter
        _C_faileof  = 0x10,   // set ios_base::failbit on eof
        _C_failend  = 0x20,   // set ios_base::failbit on end of buffer
        _C_failnoi  = 0x40,   // set ios_base::failbit on no input
        _C_eatnull  = 0x80    // extract null char
    };

    // does not construct a sentry, does not affect gcount()
    // extracts character unless it is equal to __delim
    int_type _C_unsafe_get (streamsize* = 0,
                            int_type    = traits_type::eof (),
                            int         = 0);

protected:

    streamsize _C_chcount;   // number of chars extracted
};


// 27.6.1.4, p1
template<class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
ws (basic_istream<_CharT, _Traits> &__strm)
{
    return __strm._C_ipfx (basic_istream<_CharT, _Traits>::_C_skipws);
}


template<class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::seekg (pos_type __pos)
{
    _RWSTD_ASSERT (0 != this->rdbuf ());

    if (!this->fail ()) {
        _RWSTD_MT_GUARD (this->_C_bufmutex ());

        // 27.6.1.3, p 38 requires that pubseekpos be called with
        // a single argument; the implemented behavior follows
        // the proposed resolution of lwg issue 136
        if (-1 == this->rdbuf ()->pubseekpos (__pos, ios_base::in))
            this->setstate (ios_base::failbit);   // lwg issue 129
    }

    return *this;
}


template<class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::seekg (off_type __off, ios_base::seekdir __dir)
{
    _RWSTD_ASSERT (0 != this->rdbuf ());

    if (!this->fail ()) {
        _RWSTD_MT_GUARD (this->_C_bufmutex ());

        // 27.6.1.3, p 40 requires that pubseekoff be called with
        // two arguments; the implemented behavior follows
        // the proposed resolution of lwg issue 136
        if (-1 == this->rdbuf ()->pubseekoff (__off, __dir, ios_base::in))
            this->setstate (ios_base::failbit);   // lwg issue 129
    }

    return *this;
}


#ifndef _RWSTD_NO_SIGNED_CHAR_IN_STREAMS

// 27.6.1.2.3, p10
template <class _Traits>
inline basic_istream<char, _Traits>&
operator>> (basic_istream<char, _Traits>& __strm, 
            unsigned char&                __c)
{
    return __strm >> _RWSTD_REINTERPRET_CAST (char&, __c);
}

template <class _Traits>
inline basic_istream<char, _Traits>&
operator>> (basic_istream<char, _Traits>& __strm, 
            signed char&                  __c)
{
    return __strm >> _RWSTD_REINTERPRET_CAST (char&, __c);
}


// 27.6.1.2.3, p6
template <class _Traits>
inline basic_istream<char, _Traits>&
operator>> (basic_istream<char, _Traits>& __strm, 
            unsigned char*                __s)
{
    return __strm >> _RWSTD_REINTERPRET_CAST (char*, __s);
}


template <class _Traits>
inline basic_istream<char, _Traits>&
operator>> (basic_istream<char, _Traits>& __strm, 
            signed char* __s)
{
    return __strm >> _RWSTD_REINTERPRET_CAST (char*, __s);
}

#endif // _RWSTD_NO_SIGNED_CHAR_IN_STREAMS


template<class _CharT, class _Traits>
inline _TYPENAME basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::peek ()
{
    _RWSTD_ASSERT (0 != this->rdbuf ());

    _C_chcount = 0;

    return sentry (*this, true) ? this->rdbuf ()->sgetc ()
                                : traits_type::eof ();
}


// 27.6.1.2.3, p10
template<class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
operator>> (basic_istream<_CharT, _Traits> &__strm, _CharT &__c)
{
    // read the first non-space char, set failbit if none read
    return __strm.read (&__c, 1, _Traits::eof (),
                        __strm._C_skipws | __strm._C_failnoi | __strm._C_eatnull);
}


// 27.6.1.2.3, p6
template<class _CharT, class _Traits>
inline basic_istream<_CharT, _Traits>&
operator>> (basic_istream<_CharT, _Traits> &__strm, _CharT *__s)
{
    _RWSTD_ASSERT (0 != __s);

    // store at most this many chars including terminating null
    const streamsize __maxlen = __strm.width () ? __strm.width () :
                                numeric_limits<streamsize>::max () - 1;

    // read at most __maxlen non-space chars up to the first whitespace
    __strm.read (__s, __maxlen, _Traits::to_int_type (__strm.widen ('\n')),
                   __strm._C_nullterm | __strm._C_wsterm
                 | __strm._C_skipws   | __strm._C_failnoi);

    __strm.width (0);

    return __strm;
}


template<class _CharT, class _Traits, class _Allocator>
basic_istream<_CharT, _Traits>&
operator>> (basic_istream<_CharT, _Traits>&,
            basic_string<_CharT, _Traits, _Allocator>&);


template<class _CharT, class _Traits, class _Allocator>
basic_istream<_CharT, _Traits>&
getline (basic_istream<_CharT, _Traits>&,
         basic_string<_CharT, _Traits, _Allocator>&,
         _CharT);


template<class _CharT, class _Traits, class _Allocator>
inline basic_istream<_CharT, _Traits>& 
getline (basic_istream<_CharT, _Traits>&            __is,
         basic_string<_CharT, _Traits, _Allocator>& __str)
{
    return getline (__is, __str, __is.widen ('\n'));
}


// 27.6.1.5
template<class _CharT, class _Traits /* = char_traits<_CharT> */>
class basic_iostream
    : public basic_istream<_CharT, _Traits>,
      public basic_ostream<_CharT, _Traits> 
{
public:

    // prevent ambiguity between types defined in the bases
    typedef _CharT                          char_type;
    typedef _Traits                         traits_type;
    typedef _TYPENAME traits_type::int_type int_type;
    typedef _TYPENAME traits_type::pos_type pos_type;
    typedef _TYPENAME traits_type::off_type off_type;

    _EXPLICIT basic_iostream (basic_streambuf<_CharT, _Traits> *__sb)
        : basic_istream<_CharT, _Traits> (__sb), 
          basic_ostream<_CharT, _Traits> (__sb)
        { /* 27.6.1.5.1, p1 */ }
};


_RWSTD_INSTANTIATE_2 (class _RWSTD_EXPORT
                      basic_istream<char, char_traits<char> >);
_RWSTD_INSTANTIATE_1 (_RWSTD_EXPORT istream& operator>> (istream&, string&));
_RWSTD_INSTANTIATE_1 (_RWSTD_EXPORT istream&
                      getline (istream&, string&, char));

#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_2 (class _RWSTD_EXPORT
                      basic_istream<wchar_t, char_traits<wchar_t> >);
_RWSTD_INSTANTIATE_1 (_RWSTD_EXPORT wistream&
                      operator>> (wistream&, wstring&));
_RWSTD_INSTANTIATE_1 (_RWSTD_EXPORT wistream&
                      getline (wistream&, wstring&, wchar_t));
#endif   // _RWSTD_NO_WCHAR_T

_RWSTD_NAMESPACE_END   // std


#if _RWSTD_DEFINE_TEMPLATE (BASIC_ISTREAM)
#  include <istream.cc>
#endif


#endif   // _RWSTD_ISTREAM_INCLUDED

⌨️ 快捷键说明

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