Namespaces
Variants

std::basic_filebuf<CharT,Traits>:: underflow

From cppreference.net
protected :
virtual int_type underflow ( )

입력 영역에 더 많은 데이터를 읽어들입니다.

기본 클래스 std :: basic_streambuf :: underflow 와 유사하게 동작하지만, get 영역으로 데이터를 읽어오기 위해 연결된 문자 시퀀스(파일)에서 데이터를 읽을 때, 먼저 파일에서 임시 버퍼(필요한 만큼 큰 크기로 할당됨)로 바이트를 읽은 다음, 임베드된 로케일의 std :: codecvt :: in 를 사용하여 외부 표현(일반적으로 멀티바이트)을 내부 형식으로 변환한 후 이를 사용하여 get 영역을 채웁니다. 로케일의 std :: codecvt :: always_noconv true 를 반환하는 경우 변환은 생략될 수 있습니다.

목차

매개변수

(없음)

반환값

Traits :: to_int_type ( * gptr ( ) ) (대기 중인 시퀀스의 첫 번째 문자)를 성공 시 반환하거나, 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

참고 항목

[virtual]
연관된 입력 시퀀스에서 get 영역으로 문자를 읽어들임
( std::basic_streambuf<CharT,Traits> 의 virtual protected 멤버 함수)
[virtual]
입력 시퀀스에서 사용 가능한 다음 문자를 반환함
( std::basic_stringbuf<CharT,Traits,Allocator> 의 virtual protected 멤버 함수)
[virtual]
다음 포인터를 이동시키지 않고 입력 시퀀스에서 문자를 읽음
( std::strstreambuf 의 virtual protected 멤버 함수)
[virtual]
연관된 파일에서 읽고 get 영역의 다음 포인터를 전진시킴
(virtual protected 멤버 함수)
[virtual]
put 영역에서 연관된 파일로 문자를 씀
(virtual protected 멤버 함수)
시퀀스를 전진시키지 않고 입력 시퀀스에서 한 문자를 읽음
( std::basic_streambuf<CharT,Traits> 의 public 멤버 함수)