名前空間
変種
操作

「cpp/io/basic ios/rdbuf」の版間の差分

提供: cppreference.com
< cpp‎ | io‎ | basic ios
(Fix some translations)
 
1行: 1行:
{{tr_note}}
 
 
{{cpp/io/basic_ios/title|rdbuf}}
 
{{cpp/io/basic_ios/title|rdbuf}}
 
{{cpp/io/basic_ios/navbar}}
 
{{cpp/io/basic_ios/navbar}}
 
{{dcl begin}}
 
{{dcl begin}}
 
{{dcl | num = 1 |
 
{{dcl | num = 1 |
std::basic_streambuf<CharT,Traits>* rdbuf() const;
+
std::basic_streambuf<CharT, Traits>* rdbuf() const;
 
}}
 
}}
 
{{dcl | num = 2 |
 
{{dcl | num = 2 |
std::basic_streambuf<CharT,Traits>* rdbuf( std::basic_streambuf<CharT,Traits>* sb );
+
std::basic_streambuf<CharT, Traits>* rdbuf( std::basic_streambuf<CharT, Traits>* sb );
 
}}
 
}}
 
{{dcl end}}
 
{{dcl end}}
  
{{tr|関連付けられたストリームバッファを管理します.|Manages the associated stream buffer.}}
+
  
1) {{tr|関連付けられているストリームバッファを返します。関連付けられたストリームバッファが存在しない場合は、返品{{lc|NULL}}.|Returns the associated stream buffer. If there is no associated stream buffer, returns {{lc|NULL}}.}}
+
1
  
2) {{tr|{{tt|sb}}に関連付けられたストリームバッファを設定します。 {{tt|sb}}のエラー状態が{{c|sb.clear()}}を呼び出すことによってクリアされます。操作する前に、関連付けられたストリームバッファを返します。関連付けられたストリームバッファが存在しない場合は、返品{{lc|NULL}}.|Sets the associated stream buffer to {{tt|sb}}. The error state of {{tt|sb}} is cleared by calling {{c|sb.clear()}}. Returns the associated stream buffer before the operation. If there is no associated stream buffer, returns {{lc|NULL}}.}}
+
2{{tt|sb}} {{lc|clear()}}
  
===パラメータ===
+
======
 
{{par begin}}
 
{{par begin}}
{{par | sb |{{tr| ストリームバッファに関連付けることができます| stream buffer to associate to}}}}
+
{{par | sb | }}
 
{{par end}}
 
{{par end}}
  
===値を返します===
+
======
{{tr|関連付けられたストリームバッファがなかった場合、関連付けられたストリームバッファ、または{{lc|NULL}}.|The associated stream buffer, or {{lc|NULL}} if there was no associated stream buffer.}}
+
  
 
===例外===
 
===例外===
31行: 30行:
 
{{example|
 
{{example|
 
|code=
 
|code=
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
|output=
 
|output=
 +
 +
 
}}
 
}}
  
===参照===
+
======
 
{{dsc begin}}
 
{{dsc begin}}
 
{{dsc inc | cpp/io/basic_ios/dsc set_rdbuf}}
 
{{dsc inc | cpp/io/basic_ios/dsc set_rdbuf}}
 
{{dsc end}}
 
{{dsc end}}
  
[[de:cpp/io/basic ios/rdbuf]]
+
deenesfritptruzh
[[en:cpp/io/basic ios/rdbuf]]
+
[[es:cpp/io/basic ios/rdbuf]]
+
[[fr:cpp/io/basic ios/rdbuf]]
+
[[it:cpp/io/basic ios/rdbuf]]
+
[[pt:cpp/io/basic ios/rdbuf]]
+
[[ru:cpp/io/basic ios/rdbuf]]
+
[[zh:cpp/io/basic ios/rdbuf]]
+

2018年6月2日 (土) 18:52時点における最新版

 
 
入出力ライブラリ
入出力マニピュレータ
Cスタイルの入出力
バッファ
(C++98で非推奨)
ストリーム
抽象
ファイル入出力
文字列入出力
配列入出力
(C++98で非推奨)
(C++98で非推奨)
(C++98で非推奨)
同期化出力
エラーカテゴリインタフェース
(C++11)
 
 
std::basic_streambuf<CharT, Traits>* rdbuf() const;
(1)
std::basic_streambuf<CharT, Traits>* rdbuf( std::basic_streambuf<CharT, Traits>* sb );
(2)

紐付けられているストリームバッファを管理します。

1) 紐付けられているストリームバッファを返します。 紐付けられているストリームバッファがない場合はヌルポインタを返します。
2) 紐付けられているストリームバッファを sb に設定します。 エラー状態は clear() を呼ぶことによってクリアされます。 この操作の前に紐付けられていたストリームバッファを返します。 紐付けられていたストリームバッファがない場合はヌルポインタを返します。

目次

[編集] 引数

sb - 紐付けるストリームバッファ

[編集] 戻り値

紐付けられていたストリームバッファ、または紐付けられていたストリームバッファがなかった場合はヌルポインタ。

[編集] 例外

(なし)

[編集]

#include <iostream>
#include <sstream>
 
int main()
{
    std::ostringstream local;
    auto cout_buff = std::cout.rdbuf(); // save pointer to std::cout buffer
 
    std::cout.rdbuf(local.rdbuf()); // substitute internal std::cout buffer with
        // buffer of 'local' object
 
    // now std::cout work with 'local' buffer
    // you don't see this message
    std::cout << "some message";
 
    // go back to old buffer
    std::cout.rdbuf(cout_buff);
 
    // you will see this message
    std::cout << "back to default buffer\n";
 
    // print 'local' content
    std::cout << "local content: " << local.str() << "\n";
}

出力:

back to default buffer
local content: some message

[編集] 関連項目

エラー状態をクリアせずに rdbuf を置き換えます
(プロテクテッドメンバ関数) [edit]