std::basic_filebuf<CharT,Traits>:: underflow
From cppreference.com
< cpp | io | basic filebuf
| protected: virtual int_type underflow() |
||
入力領域により多くのデータを読み込みます。
基底クラスの std::basic_streambuf::underflow と同様に動作しますが、関連付けられた文字シーケンス(ファイル)から取得領域にデータを読み込むために、まずバイトをファイルから一時バッファ(必要に応じて大きなサイズで割り当てられます)に読み込み、次に、埋め込まれたロケールの std::codecvt::in を使用して外部(通常はマルチバイト)表現を内部形式に変換し、その内部形式で取得領域を埋めます。ロケールの 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] |
関連付けられた入力シーケンスから取得領域に文字を読み込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンスで利用可能な次の文字を返す ( std::basic_stringbuf<CharT,Traits,Allocator>の仮想保護メンバー関数) |
| [virtual] |
入力シーケンスから文字を読み取りますが、次のポインタは進めません。 ( std::strstreambufの仮想保護メンバー関数) |
| [virtual] |
関連ファイルを読み込み、取得領域の次ポインタを進めます (仮想保護メンバ関数) |
| [virtual] |
ファイルバッファの格納領域から、関連付けられたファイルへ文字を書き込みます。 (virtual protected member function) |
| シーケンスを進めずに、入力シーケンスから1文字を読み取る ( std::basic_streambuf<CharT,Traits> の public メンバ関数) |