std::basic_streambuf<CharT,Traits>::pubsetbuf, std::basic_streambuf<CharT,Traits>::setbuf
De cppreference.com
< cpp | io | basic streambuf
![]() | Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate. La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
basic_streambuf<CharT,Traits>* pubsetbuf( char_type* s, std::streamsize n ) | (1) | |
protected: virtual basic_streambuf<CharT,Traits>* setbuf( char_type* s, std::streamsize n ) | (2) | |
Llamadas
2) setbuf(s, n)
de la clase más derivadaOriginal:
Calls
setbuf(s, n)
of the most derived classThe 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.
La versión de la clase base de esta función no tiene ningún efecto. Las clases derivadas pueden anular esta función para permitir la remoción o reemplazo de la secuencia de caracteres de control (el buffer) con una matriz proporcionada por el usuario, o para cualquier otro propósito específico de la implementación .
Original:
The base class version of this function has no effect. The derived classes may override this function to allow removal or replacement of the controlled character sequence (the buffer) with a user-provided array, or for any other implementation-specific purpose.
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.
Contenido |
[editar]Parámetros
s | - | puntero al primer byte en la memoria intermedia proporcionado por el usuario Original: pointer to the first byte in the user-provided buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
n | - | el número de bytes en el búfer proporcionado por el usuario Original: the number of bytes in the user-provided buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar]Valor de retorno
*this
[editar]Ejemplo
proporcionar un tampón de 10k para la lectura. En Linux, la utilidad strace puede ser utilizado para observar el número real de bytes leídos
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.
Ejecuta este código
#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';}
[editar]Ver también
[virtual] | proporciona suministrado por el usuario búfer o sin búfer convierte a esta filebuf Original: provides user-supplied buffer or turns this filebuf unbuffered The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida de std::basic_filebuf ) |