「cpp/io/basic filebuf/setbuf」の版間の差分
提供: cppreference.com
< cpp | io | basic filebuf
TranslationBot (トーク | 投稿記録) (Translated from the English version using Google Translate) |
細 (1版:Translate from the English version) |
2012年10月30日 (火) 16:06時点における版
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
protected: virtual std::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n ) |
||
s
がNULLポインターであるとn
がゼロの場合は、filebufはなりバッファリングされていない出力の、意味pbase()
とpptr()
ヌルであり、任意の出力は直ちにファイルに送信されます.Original:
If
s
is a null pointer and n
is zero, the filebuf becomes unbuffered for output, meaning pbase()
and pptr()
are null and any output is immediately sent to file.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
それ以外の場合は、
setbuf()
への呼び出しは、内部を置き換え最初の要素s
が指すこのstd::basic_filebufオブジェクトがバッファリングするためにその配列にn
バイトまで使用することができますされているユーザが提供する文字配列.Original:
Otherwise, a call to
setbuf()
replaces the internal buffer (the controlled character sequence) with the user-supplied character array whose first element is pointed to by s
and allows this std::basic_filebuf object to use up to n
bytes in that array for buffering.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
この関数は、仮想保護されて、それが唯一の
pubsetbuf()
を介して、またはstd::basic_filebuf
から派生したユーザー定義クラスのメンバ関数から呼ばれるかもしれない.Original:
This function is protected virtual, it may only be called through
pubsetbuf()
or from member functions of a user-defined class derived from std::basic_filebuf
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
パラメータ
s | - | ユーザが提供するバッファまたはnullの最初のバイトへのポインタ
Original: pointer to the first byte in the user-provided buffer or null The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
n | - | ユーザが提供するバッファまたはゼロのバイト数
Original: the number of bytes in the user-provided buffer or zero The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
値を返します
基底クラスにキャスト*this
std::basic_streambuf
、.Original:
*this, cast to the base class
std::basic_streambuf
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
ノート
持つバッファ(制御文字シーケンス)。この機能を使用することができる条件そして提供されたバッファが使用される方法は、実装定義で.
Original:
The conditions when this function may be used and the way in which the provided buffer is used is implementation-defined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- GCC 4.6のlibstdc + +Original:GCC 4.6 libstdc++The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
setbuf()
がファイル(そうでなければ効果がありません)に関連付けられていない場合std::basic_filebufのみ呼び出すことができます。ユーザー提供でバッファは、ファイルからの読み取りはn-1
バイト一度.Original:setbuf()
may only be called when the std::basic_filebuf is not associated with a file (has no effect otherwise). With a user-provided buffer, reading from file readsn-1
bytes at a time.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Clangの+ 3.0のlibc + +Original:Clang++3.0 libc++The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
setbuf()
ファイルを開いた後に呼ばれるかもしれないが、任意のI / O(そうでなければ、クラッシュすることがあります)の前に読み込まれます。ユーザー提供のバッファを持つ、ファイルからの読み込みが4096の最大の倍数を読み取りバッファに収まら.Original:setbuf()
may be called after opening the file, but before any I/O (may crash otherwise). With a user-provided buffer, reading from file reads largest multiples of 4096 that fit in the buffer.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Visual Studio 2010のそのOriginal:Visual Studio 2010The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
setbuf()
いくつかのI / Oが行われた後でも、いつでも呼び出すことができます。バッファの現在の内容があれば、その失われ.Original:setbuf()
may be called at any time, even after some I/O took place. Current contents of the buffer, if any, are lost.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
標準では、すべてのI / Oが行われている前に呼び出さ
setbuf(0, 0)
は、バッファなしの出力.Original:
The standard does not define any behavior for this function except that
setbuf(0, 0)
called before any I/O has taken place is required to set unbuffered output.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
例
読書のための10Kバッファを提供します。 Linux上では、straceユーティリティーは、実際に読み込んだバイト数を観察するために使用されるかもしれません
Original:
provide a 10k buffer for reading. On linux, the strace utility may be used to observe the actual number of bytes read
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Run this code
#include <fstream> #include <iostream> #include <string> int main() { int cnt=0; std::ifstream file; char buf[10241]; file.rdbuf()->pubsetbuf(buf, sizeof buf); file.open("/usr/share/dict/words"); for(std::string line; getline(file, line); ) cnt++; std::cout << cnt << '\n'; }