std::basic_filebuf::setbuf
De cppreference.com
< cpp | io | basic filebuf
![]() |
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. |
protected: virtual std::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n ) |
||
Si
s
est un pointeur nul et n
est égal à zéro, le filebuf devient' unbuffered pour la sortie, ce qui signifie pbase()
et pptr()
sont nulles et toute sortie est immédiatement envoyé à déposer .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 mémoire tampon interne (la séquence de caractères contrôlée) avec le tableau de caractères fournie par l'utilisateur dont le premier élément est pointé par s
et permet cet objet std::basic_filebuf d'utiliser jusqu'à octets n
dans ce tableau en mémoire 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 protégée virtuel, il ne peut être appelé par
pubsetbuf()
ou de fonctions membres d'une classe définie par l'utilisateur dérivée 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.
Sommaire |
[modifier] Paramètres
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 zéro
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. |
[modifier] 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.
[modifier] Notes
Les conditions dans lesquelles cette fonction peut être utilisée et la manière dont le tampon fourni est utilisé est défini par l'implémentation .
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 appelée 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-1
octets à 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-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 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 appelée après 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 mémoire 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, même après un certain I / O a eu lieu. Contenu actuel de la mémoire tampon, le cas échéant, 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 définit pas le comportement de cette fonction, sauf que
setbuf(0, 0)
appelée avant tout d'E / S a eu lieu est nécessaire pour régler 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.
[modifier] Exemple
fournir un tampon 10k pour la lecture. Sur Linux, l'utilitaire strace peut être utilisé pour observer le nombre réel 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'; }
[modifier] 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 )
| |
définit 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) |