std::basic_filebuf<CharT,Traits>::underflow
提供: cppreference.com
< cpp | io | basic filebuf
protected: virtual int_type underflow() | ||
入力領域にさらにデータを読み込みます。
基底クラスの std::basic_streambuf::underflow のように動作します。 ただし、紐付けられている文字シーケンス (ファイル) から get 領域にデータを読み込むために、まずファイルから (必要なだけ確保された) 一時バッファにデータを読み込み、その後、外部 (一般的にはマルチバイト) 表現を get 領域に投入するために使用される内部形式に変換するために、設定されているロケールの std::codecvt::in を使用します。 ロケールの std::codecvt::always_noconv が true を返した場合、変換はスキップされるかもしれません。
目次 |
[編集]引数
(なし)
[編集]戻り値
成功した場合は Traits::to_int_type(*gptr()) (保留中のシーケンスの最初の文字)、失敗した場合は Traits::eof()。
[編集]例
Run this code
#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
[編集]関連項目
[仮想] | 紐付けられている入力シーケンスから get 領域に文字を読み込みます ( std::basic_streambuf<CharT,Traits> の仮想プロテクテッドメンバ関数) |
[仮想] | 入力シーケンスの次の利用可能な文字を返します ( std::basic_stringbuf<CharT,Traits,Allocator> の仮想プロテクテッドメンバ関数) |
[仮想] | 次ポインタを進めずに入力シーケンスから文字を読み込みます ( std::strstreambuf の仮想プロテクテッドメンバ関数) |
[仮想] | 紐付けられているファイルから読み込み、 get 領域の次ポインタを進めます (仮想プロテクテッドメンバ関数) |
[仮想] | put 領域から紐付けられているファイルに文字を書き込みます (仮想プロテクテッドメンバ関数) |
シーケンスを進めずに入力シーケンスから文字をひとつ読み込みます ( std::basic_streambuf<CharT,Traits> のパブリックメンバ関数) |