标准库头文件 <streambuf>

来自cppreference.com
< cpp‎ | header
 
 
 

此头文件是输入/输出库的一部分。

目录

抽象无修饰设备
(类模板) [编辑]

typedef

streambuf basic_streambuf<char>
wstreambuf basic_streambuf<wchar_t>

[编辑] 概要

namespace std {
 
    template <class charT, class traits = char_traits<charT> >
    class basic_streambuf;
 
    typedef basic_streambuf<char> streambuf;
    typedef basic_streambuf<wchar_t> wstreambuf;
}

[编辑] std::basic_streambuf

template <class charT, class traits = char_traits<charT> >
class basic_streambuf {
 public:
    // 类型:
    typedef charT char_type;
    typedef typename traits::int_type int_type;
    typedef typename traits::pos_type pos_type;
    typedef typename traits::off_type off_type;
    typedef traits traits_type;
 
    virtual ~basic_streambuf();
 
    // 本地环境:
    locale pubimbue(const locale& loc);
    locale getloc() const;
 
    // 缓冲区与寻位:
    basic_streambuf<char_type,traits>*
    pubsetbuf(char_type* s, streamsize n);
    pos_type pubseekoff(off_type off, ios_base::seekdir way,
                        ios_base::openmode which = ios_base::in|ios_base::out);
    pos_type pubseekpos(pos_type sp,
                        ios_base::openmode which = ios_base::in|ios_base::out);
    int pubsync();
 
    // 获取区:
    streamsize in_avail();
    int_type snextc();
    int_type sbumpc();
    int_type sgetc();
    streamsize sgetn(char_type* s, streamsize n);
 
    // 回放:
    int_type sputbackc(char_type c);
    int_type sungetc();
 
    // 放置区:
    int_type sputc(char_type c);
    streamsize sputn(const char_type* s, streamsize n);
 
 protected:
    basic_streambuf();
    basic_streambuf(const basic_streambuf& rhs);
    basic_streambuf& operator=(const basic_streambuf& rhs);
    void swap(basic_streambuf& rhs);
 
    // 获取区:
    char_type* eback() const;
    char_type* gptr() const;
    char_type* egptr() const;
    void gbump(int n);
    void setg(char_type* gbeg, char_type* gnext, char_type* gend);
 
    // 放置区:
    char_type* pbase() const;
    char_type* pptr() const;
    char_type* epptr() const;
    void pbump(int n);
    void setp(char_type* pbeg, char_type* pend);
 
    // 虚函数:
    // 本地环境:
    virtual void imbue(const locale& loc);
 
    // 缓冲区管理及寻位:
    virtual basic_streambuf<char_type,traits>* setbuf(char_type* s, streamsize n);
    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
                             ios_base::openmode which = ios_base::in|ios_base::out);
    virtual pos_type seekpos(pos_type sp,
                             ios_base::openmode which = ios_base::in|ios_base::out);
    virtual int sync();
 
    // 获取区:
    virtual streamsize showmanyc();
    virtual streamsize xsgetn(char_type* s, streamsize n);
    virtual int_type underflow();
    virtual int_type uflow();
 
    // 回放:
    virtual int_type pbackfail(int_type c = traits::eof());
 
    // 放置区:
    virtual streamsize xsputn(const char_type* s, streamsize n);
    virtual int_type overflow (int_type c = traits::eof());
};