std::basic_filebuf::underflow
性病:基本[医]FILEBEF::地下水流
protected: virtual int_type underflow() | | |
---|
将更多数据读入输入区域。
行为类似于基类。std::basic_streambuf::underflow
,除了要将关联字符序列%28(文件%29)中的数据读取到get区域外,首先将文件中的字节读入临时缓冲区%28,并根据需要分配到%29,然后使用std::codecvt::in
对于要转换外部%28的输入区域设置,多字节%29表示形式转换为内部窗体,然后用于填充GET区域。如果区域设置%27 s,则可能跳过转换std::codecvt::always_noconv
回报true
...
参数
%280%29
返回值
Traits::to_int_type(*gptr())
%28挂起序列%29的第一个字符(如果成功),或Traits::eof()
万一失败。
例
二次
#include <fstream>
#include <iostream>
struct mybuf : std::filebuf
{
int underflow() {
std::cout << "Before underflow(): size of the get area is "
<< egptr()-eback() << " with "
<< egptr()-gptr() << " read positions available\n";
int rc = std::filebuf::underflow(
std::cout << "underflow() returns " << rc << ".\nAfter the call, "
<< "size of the get area is "
<< egptr()-eback() << " with "
<< egptr()-gptr() << " read positions available\n";
return rc;
}
};
int main()
{
mybuf buf;
buf.open("test.txt", std::ios_base::in
std::istream stream(&buf
while(stream.get()) ;
}
二次
可能的产出:
二次
Before underflow(): size of the get area is 0 with 0 read positions available
underflow() returns 73.
After the call, size of the get area is 110 with 110 read positions available
Before underflow(): size of the get area is 110 with 0 read positions available
underflow() returns -1.
After the call, size of the get area is 0 with 0 read positions available
二次
另见
underflow virtual | reads characters from the associated input sequence to the get area (virtual protected member function of std::basic_streambuf) |
---|---|
underflow virtual | returns the next character available in the input sequence (virtual protected member function of std::basic_stringbuf) |
underflow virtual | reads a character from the input sequence without advancing the next pointer (virtual protected member function of std::strstreambuf) |
uflow virtual | reads from the associated file and advances the next pointer in the get area (virtual protected member function) |
overflow virtual | writes characters to the associated file from the put area (virtual protected member function) |
sgetc | reads one character from the input sequence without advancing the sequence (public member function of std::basic_streambuf) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。