std::basic_filebuf::setbuf
De cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> protected: virtual std::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n ) |
||
Si
s est un pointeur nul et n est gal zro, le filebuf devient' unbuffered pour la sortie, ce qui signifie pbase() et pptr() sont nulles et toute sortie est immdiatement envoy dposer .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.
Dans le cas contraire, un appel
setbuf() remplace la mmoire tampon interne (la squence de caractres contrle) avec le tableau de caractres fournie par l'utilisateur dont le premier lment est point par s et permet cet objet std::basic_filebuf d'utiliser jusqu' octets n dans ce tableau en mmoire tampon .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.
Cette fonction est protge virtuel, il ne peut tre appel par
pubsetbuf() ou de fonctions membres d'une classe dfinie par l'utilisateur drive de 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.
Paramtres
| s | - | pointeur vers le premier octet dans le tampon fourni par l'utilisateur ou nulle
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 | - | le nombre d'octets dans le tampon fourni par l'utilisateur ou zro
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. |
Retourne la valeur
*this, jet la classe de base 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.
Notes
Les conditions dans lesquelles cette fonction peut tre utilise et la manire dont le tampon fourni est utilis est dfini par l'implmentation .
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()ne peut tre appele lorsque le std::basic_filebuf n'est pas associ un fichier (autrement n'a pas d'effet). Avec un tampon fourni par l'utilisateur, la lecture du fichier se litn-1octets la fois .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-1bytes 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 libcOriginal: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()peut tre appele aprs l'ouverture du fichier, mais avant tout d'E / S (autrement peut se bloquer). Avec un tampon fourni par l'utilisateur, la lecture du fichier se lit plus grands multiples de 4096 qui s'inscrivent dans la mmoire tampon .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 2010Original: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()peut tre appel tout moment, mme aprs un certain I / O a eu lieu. Contenu actuel de la mmoire tampon, le cas chant, sont perdus .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.
La norme ne dfinit pas le comportement de cette fonction, sauf que
setbuf(0, 0) appele avant tout d'E / S a eu lieu est ncessaire pour rgler la sortie sans tampon .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.
Exemple
fournir un tampon 10k pour la lecture. Sur Linux, l'utilitaire strace peut tre utilis pour observer le nombre rel d'octets lus
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.
#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';
}
Voir aussi
Invoque setbuf()Original: invokes setbuf()The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique de std::basic_streambuf)
| |
dfinit le tampon et la taille d'un fichier stream Original: sets the buffer and its size for a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |