Espacios de nombres
Variantes
Acciones

std::basic_stringbuf::setbuf

De cppreference.com
< cpp‎ | io‎ | basic stringbuf
 
 
 
 
protected:
virtualstd::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n )
Si s es un puntero nulo y n es cero, esta función no tiene efecto .
Original:
If s is a null pointer and n is zero, this function has no effect.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
De lo contrario, el efecto es definido por la implementación: algunas implementaciones no hacer nada, mientras que algunas implementaciones borre el miembro std::string utiliza actualmente como el tampón y comenzar a utilizar la matriz de caracteres suministrada por el usuario de n tamaño, cuyo primer elemento es apuntado por s, como la tampón y la secuencia de caracteres de entrada / salida .
Original:
Otherwise, the effect is implementation-defined: some implementations do nothing, while some implementations clear the std::string member currently used as the buffer and begin using the user-supplied character array of size n, whose first element is pointed to by s, as the buffer and the input/output character sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esta función está protegida virtual, que sólo puede ser llamado a través de pubsetbuf() o de funciones miembro de una clase definida por el usuario derivados de std::basic_stringbuf .
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_stringbuf.
The text has been machine-translated via Google Translate.
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 o nulo
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 -
el número de bytes en el búfer proporcionado por el usuario o cero
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.

[editar]Valor de retorno

*this, arrojado a la clase 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.

[editar]Notas

La corriente std::strstreambuf tampón obsoleta o la boost::basic_array boost.IOStreams dispositivo puede ser usado para implementar E / S a través de un tampón proporcionado por el usuario matriz de caracteres en forma portátil .
Original:
The deprecated stream buffer std::strstreambuf or the boost.IOStreams device boost::basic_array may be used to implement I/O buffering over a user-provided char array in portable manner.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Ejemplo

Prueba para la funcionalidad de la setbuf stringstream de
Original:
Test for the stringstream's setbuf functionality
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>#include <sstream>int main(){std::ostringstream ss;char c[1024]={}; ss.rdbuf()->pubsetbuf(c, 1024); ss <<3.14<<'\n';std::cout<< c <<'\n';}

Salida:

3.14 (on GNU g++/libstdc++ and SunPro C++/roguewave) <nothing> (on MS Visual Studio 2010, SunPro C++/stlport4, CLang++/libc++)

[editar]Ver también

Invoca a setbuf().
(función miembro pública de std::basic_streambuf<CharT,Traits>)[editar]
close