std::basic_filebuf
From cppreference.com
| ヘッダ <fstream> で定義 |
||
| template< class CharT, |
||
std::basic_filebuf は、関連付けられた文字シーケンスがファイルである std::basic_streambuf です。入力シーケンスと出力シーケンスは両方とも同じファイルに関連付けられ、両方の操作のために結合されたファイル位置が維持されます。std::basic_filebuf でシーケンスの読み書きに対する制限は、std::FILE と同じです。
関数 underflow() および overflow() / sync() は、ファイルとバッファの get および put エリア間の実際の I/O を実行します。CharT が char でない場合、ほとんどの実装ではファイルにマルチバイト文字を格納し、std::codecvt ファセットを使用してワイド文字/マルチバイト文字の変換を実行します。
一般的な文字型のためにいくつかの typedef が提供されています
| ヘッダ
<fstream> で定義 | |
| 型 | 定義 |
std::filebuf
|
std::basic_filebuf<char> |
std::wfilebuf
|
std::basic_filebuf<wchar_t> |
目次 |
[編集] メンバー型
| 型 | 定義 |
char_type
|
CharT |
traits_type
|
Traits; Traits::char_type が CharT でない場合、プログラムは不適格となる。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type。これは std::fpos<Traits::state_type> であることが要求されます。 |
off_type
|
Traits::off_type |
native_handle_type(C++26) |
TriviallyCopyable および semiregular である実装定義型 |
[編集] メンバ関数
公開メンバ関数 | |
basic_filebuf オブジェクトを構築します。(public member function) | |
| (C++11) |
basic_filebuf オブジェクトを代入します(public member function) |
| (C++11) |
2つのbasic_filebufオブジェクトを交換します(public member function) |
| (C++26) |
基となる実装定義のハンドルを返す (public member function) |
| [virtual] |
basic_filebuf オブジェクトを破棄し、ファイルが開いている場合は閉じます。(virtual public member function) |
| 関連付けられたファイルが開いているかどうかを確認します。 (public member function) | |
| ファイルをオープンし、関連付けられた文字シーケンスとして設定します。 (public member function) | |
| 書き込み領域バッファをフラッシュし、関連付けられたファイルを閉じる (public member function) | |
Protected member functions | |
| [virtual] |
ファイルからの入力に利用可能な文字数をオプションで提供します。 (virtual protected member function) |
| [virtual] |
関連付けられたファイルから読み込みます。 (virtual protected member function) |
| [virtual] |
関連付けられたファイルから読み込み、get エリアの次のポインタを進めます。 (virtual protected member function) |
| [virtual] |
入力シーケンスを戻し、文字を unget します。関連付けられたファイルには影響しません。 (virtual protected member function) |
| [virtual] |
ファイルバッファの格納領域から、関連付けられたファイルへ文字を書き込みます。 (virtual protected member function) |
| [virtual] |
ユーザー提供のバッファを提供する、またはこのファイルバッファをバッファリングなしにする (virtual protected member function) |
| [virtual] |
相対アドレスを使用してファイル位置を再配置します (virtual protected member function) |
| [virtual] |
絶対アドレスを使用してファイル位置を再配置します (virtual protected member function) |
| [virtual] |
ファイルバッファの格納領域から、関連付けられたファイルへ文字を書き込みます。 (virtual protected member function) |
| [virtual] |
関連付けられたロケールを変更します。 (virtual protected member function) |
[編集] 非メンバ関数
| std::swap アルゴリズムを特殊化する (関数テンプレート) |
std::basic_streambuf から継承
メンバ型
| メンバ型 | 定義 |
char_type
|
CharT |
traits_type
|
Traits; Traits::char_type が CharT でない場合、プログラムは不適格となる。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
メンバ関数
| [virtual] |
basic_streambuf オブジェクトを破棄する( std::basic_streambuf<CharT,Traits> の仮想 public メンバ関数) |
ロケール | |
| 関連するロケールを変更し、imbue() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| 関連するロケールのコピーを取得する ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
位置付け | |
| setbuf() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| seekoff() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| seekpos() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| sync() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
取得領域 | |
| 取得領域ですぐに利用可能な文字数を取得する ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| 入力シーケンスを進め、その後、再度進めずに1文字を読み取る ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| (C++17 で削除) |
入力シーケンスから1文字を読み込み、シーケンスを進める ( std::basic_streambuf<CharT,Traits> の public メンバ関数) |
| シーケンスを進めずに、入力シーケンスから1文字を読み取る ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| xsgetn() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
配置領域 | |
| 配置領域に1文字を書き込み、次のポインタを進める ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| xsputn() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
戻し | |
| 1文字を入力シーケンスに戻す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| 入力シーケンスの次のポインタを1つ戻す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
Protected member functions
basic_streambuf オブジェクトを構築する(protected メンバ関数) | |
| (C++11) |
basic_streambuf オブジェクトを置き換える(protected メンバ関数) |
| (C++11) |
2つの basic_streambuf オブジェクトをスワップする(protected メンバ関数) |
ロケール | |
| [virtual] |
関連するロケールの変更に対応する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
位置付け | |
| [virtual] |
許可されていれば、バッファをユーザー定義配列で置き換える ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンス、出力シーケンス、またはその両方で、相対アドレス指定を使用して次のポインタを再配置する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンス、出力シーケンス、またはその両方で、絶対アドレス指定を使用して次のポインタを再配置する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
バッファを関連付けられた文字シーケンスと同期する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
取得領域 | |
| [virtual] |
分かっていれば、関連付けられた入力シーケンスで入力に利用可能な文字数を取得する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
関連付けられた入力シーケンスから取得領域に文字を読み込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
関連付けられた入力シーケンスから取得領域に文字を読み込み、次のポインタを進める ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンスから複数の文字を読み込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| 取得領域の先頭、現在の文字、および末尾へのポインタを返す (protected メンバ関数) | |
| 入力シーケンスの次のポインタを進める (protected メンバ関数) | |
| 入力シーケンスの先頭、次、および末尾のポインタを再配置する (protected メンバ関数) | |
配置領域 | |
| [virtual] |
出力シーケンスに複数の文字を書き込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
関連付けられた出力シーケンスに、配置領域から文字を書き込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| 配置領域の先頭、現在の文字、および末尾へのポインタを返す (protected メンバ関数) | |
| 出力シーケンスの次のポインタを進める (protected メンバ関数) | |
| 出力シーケンスの先頭、次、および末尾のポインタを再配置する (protected メンバ関数) | |
戻し | |
| [virtual] |
入力シーケンスに1文字を戻す (入力シーケンスを変更する可能性あり) ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
[編集] 注記
| 機能テストマクロ | 値 | 規格 | 機能 |
|---|---|---|---|
__cpp_lib_fstream_native_handle |
202306L |
(C++26) | ネイティブハンドルサポート |
[編集] 関連項目
| Cの入出力ストリームを制御するために必要なすべての情報を保持できるオブジェクト型 (typedef) |