std::basic_stringbuf::setbuf
Da cppreference.com
< cpp | io | basic stringbuf
![]() |
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 ) |
||
Se
s
é um ponteiro nulo e n
é zero, esta função não tem nenhum efeito.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.
You can help to correct and verify the translation. Click here for instructions.
Caso contrário, o efeito é definida pela implementação: algumas implementações de não fazer nada, enquanto algumas implementações limpar o membro std::string usado atualmente como o buffer e começar a usar a matriz de caracteres fornecido pelo usuário de
n
tamanho, cujo primeiro elemento é apontado por s
, como o buffer e a seqüência de caracteres de entrada / saída.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.
You can help to correct and verify the translation. Click here for instructions.
Essa função é protegida virtual, ele só pode ser chamado através
pubsetbuf()
ou de funções de membro de uma classe definida pelo usuário derivado 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.
You can help to correct and verify the translation. Click here for instructions.
Índice |
[editar] Parâmetros
s | - | ponteiro para o primeiro byte no buffer fornecido pelo usuário ou 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 | - | o número de bytes no buffer fornecido pelo usuário ou zero
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, converter para a classe 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.
[editar] Notas
O std::strstreambuf tampão preterido fluxo ou o dispositivo
boost::basic_array
boost.IOStreams pode ser usado para implementar I / O ao longo de um tampão de matriz fornecido pelo usuário char em 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.
You can help to correct and verify the translation. Click here for instructions.
[editar] Exemplo
Teste para a funcionalidade do stringstream setbuf
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.
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'; }
Saída:
3.14 (on GNU g++/libstdc++ and SunPro C++/roguewave) <nothing> (on MS Visual Studio 2010, SunPro C++/stlport4, CLang++/libc++)
[editar] Veja também
Invoca 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. (of std::basic_streambuf função pública membro)
|