名前空間
変種
操作

「cpp/io/basic filebuf/setbuf」の版間の差分

提供: cppreference.com
< cpp‎ | io‎ | basic filebuf
(Translated from the English version using Google Translate)
 
(1版:Translate from the English version)

2012年10月30日 (火) 16:06時点における版

 
 
入出力ライブラリ
入出力マニピュレータ
Cスタイルの入出力
バッファ
(C++98で非推奨)
ストリーム
抽象
ファイル入出力
文字列入出力
配列入出力
(C++98で非推奨)
(C++98で非推奨)
(C++98で非推奨)
同期化出力
エラーカテゴリインタフェース
(C++11)
 
 
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.
それ以外の場合は、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.
この関数は、仮想保護されて、それが唯一の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.

目次

パラメータ

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.

値を返します

基底クラスにキャスト*thisstd::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.

ノート

持つバッファ(制御文字シーケンス)。この機能を使用することができる条件そして提供されたバッファが使用される方法は、実装定義で.
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.
  • 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 reads n-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 2010
    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が行われた後でも、いつでも呼び出すことができます。バッファの現在の内容があれば、その失われ.
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.

読書のための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.

#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';
}


も参照してください

テンプレート:cpp/io/basic streambuf/dcl list pubsetbufテンプレート:cpp/io/c/dcl list setvbuf