名前空間
変種
操作

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

提供: cppreference.com
< cpp‎ | io‎ | basic filebuf
(r2.7.3) (ロボットによる 追加: de, en, es, fr, it, pt, ru, zh)
(Use {{lc}}. Update links. Various fixes.)
9行: 9行:
 
{{tr|{{tt|s}}がNULLポインターであると{{tt|n}}がゼロの場合は、filebufはなり''バッファリングされていない出力の''、意味{{tt|pbase()}}と{{tt|pptr()}}ヌルであり、任意の出力は直ちにファイルに送信されます.|If {{tt|s}} is a null pointer and {{tt|n}} is zero, the filebuf becomes ''unbuffered'' for output, meaning {{tt|pbase()}} and {{tt|pptr()}} are null and any output is immediately sent to file.}}
 
{{tr|{{tt|s}}がNULLポインターであると{{tt|n}}がゼロの場合は、filebufはなり''バッファリングされていない出力の''、意味{{tt|pbase()}}と{{tt|pptr()}}ヌルであり、任意の出力は直ちにファイルに送信されます.|If {{tt|s}} is a null pointer and {{tt|n}} is zero, the filebuf becomes ''unbuffered'' for output, meaning {{tt|pbase()}} and {{tt|pptr()}} are null and any output is immediately sent to file.}}
  
{{tr|それ以外の場合は、{{tt|setbuf()}}への呼び出しは、内部を置き換え最初の要素{{tt|s}}が指すこの{{c|std::basic_filebuf}}オブジェクトがバッファリングするためにその配列に{{tt|n}}バイトまで使用することができますされているユーザが提供する文字配列.|Otherwise, a call to {{tt|setbuf()}} replaces the internal buffer (the controlled character sequence) with the user-supplied character array whose first element is pointed to by {{tt|s}} and allows this {{c|std::basic_filebuf}} object to use up to {{tt|n}} bytes in that array for buffering.}}
+
{{tr|それ以外の場合は、{{tt|setbuf()}}への呼び出しは、内部を置き換え最初の要素{{tt|s}}が指すこの{{|std::basic_filebuf}}オブジェクトがバッファリングするためにその配列に{{tt|n}}バイトまで使用することができますされているユーザが提供する文字配列.|Otherwise, a call to {{tt|setbuf()}} replaces the internal buffer (the controlled character sequence) with the user-supplied character array whose first element is pointed to by {{tt|s}} and allows this {{|std::basic_filebuf}} object to use up to {{tt|n}} bytes in that array for buffering.}}
  
 
{{tr|この関数は、仮想保護されて、それが唯一の{{tt|pubsetbuf()}}を介して、または{{tt|std::basic_filebuf}}から派生したユーザー定義クラスのメンバ関数から呼ばれるかもしれない.|This function is protected virtual, it may only be called through {{tt|pubsetbuf()}} or from member functions of a user-defined class derived from {{tt|std::basic_filebuf}}.}}
 
{{tr|この関数は、仮想保護されて、それが唯一の{{tt|pubsetbuf()}}を介して、または{{tt|std::basic_filebuf}}から派生したユーザー定義クラスのメンバ関数から呼ばれるかもしれない.|This function is protected virtual, it may only be called through {{tt|pubsetbuf()}} or from member functions of a user-defined class derived from {{tt|std::basic_filebuf}}.}}
  
 
===パラメータ===
 
===パラメータ===
{{param list begin}}
+
{{begin}}
{{param list item | s |{{tr| ユーザが提供するバッファまたはnullの最初のバイトへのポインタ| pointer to the first byte in the user-provided buffer or null}}}}
+
{{| s |{{tr| ユーザが提供するバッファまたはnullの最初のバイトへのポインタ| pointer to the first byte in the user-provided buffer or null}}}}
{{param list item | n |{{tr| ユーザが提供するバッファまたはゼロのバイト数| the number of bytes in the user-provided buffer or zero}}}}
+
{{| n |{{tr| ユーザが提供するバッファまたはゼロのバイト数| the number of bytes in the user-provided buffer or zero}}}}
{{param list end}}
+
{{end}}
  
 
===値を返します===
 
===値を返します===
26行: 26行:
  
 
* {{tr|GCC 4.6のlibstdc + +|GCC 4.6 libstdc++}}
 
* {{tr|GCC 4.6のlibstdc + +|GCC 4.6 libstdc++}}
: {{tr|{{tt|setbuf()}}がファイル(そうでなければ効果がありません)に関連付けられていない場合{{c|std::basic_filebuf}}のみ呼び出すことができます。ユーザー提供でバッファは、ファイルからの読み取りは{{tt|n-1}}バイト一度.|{{tt|setbuf()}} may only be called when the {{c|std::basic_filebuf}} is not associated with a file (has no effect otherwise). With a user-provided buffer, reading from file reads {{tt|n-1}} bytes at a time.}}
+
: {{tr|{{tt|setbuf()}}がファイル(そうでなければ効果がありません)に関連付けられていない場合{{|std::basic_filebuf}}のみ呼び出すことができます。ユーザー提供でバッファは、ファイルからの読み取りは{{tt|n-1}}バイト一度.|{{tt|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 {{tt|n-1}} bytes at a time.}}
 
* {{tr|Clangの+ 3.0のlibc + +|Clang++3.0 libc++}}
 
* {{tr|Clangの+ 3.0のlibc + +|Clang++3.0 libc++}}
 
: {{tr|{{tt|setbuf()}}ファイルを開いた後に呼ばれるかもしれないが、任意のI / O(そうでなければ、クラッシュすることがあります)の前に読み込まれます。ユーザー提供のバッファを持つ、ファイルからの読み込みが4096の最大の倍数を読み取りバッファに収まら. |{{tt|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. }}
 
: {{tr|{{tt|setbuf()}}ファイルを開いた後に呼ばれるかもしれないが、任意のI / O(そうでなければ、クラッシュすることがあります)の前に読み込まれます。ユーザー提供のバッファを持つ、ファイルからの読み込みが4096の最大の倍数を読み取りバッファに収まら. |{{tt|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. }}
57行: 57行:
  
 
===も参照してください===
 
===も参照してください===
{{dcl list begin}}
+
{{begin}}
{{dcl list template | cpp/io/basic_streambuf/dcl list pubsetbuf | mem=std::basic_streambuf}}
+
{{| cpp/io/basic_streambuf/pubsetbuf | mem=std::basic_streambuf}}
{{dcl list template | cpp/io/c/dcl list setvbuf}}
+
{{| cpp/io/c/setvbuf}}
{{dcl list end}}
+
{{end}}
  
 
[[de:cpp/io/basic filebuf/setbuf]]
 
[[de:cpp/io/basic filebuf/setbuf]]

2013年7月2日 (火) 13: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';
}


も参照してください

setbuf() を呼びます
(std::basic_streambuf<CharT,Traits>のパブリックメンバ関数) [edit]
ファイルストリームのためのバッファとそのサイズを設定します
(関数) [edit]