Espacios de nombres
Variantes
Acciones

std::basic_filebuf::setbuf

De cppreference.com
< cpp‎ | io‎ | basic filebuf
 
 
Biblioteca de E/S
Manipuladores de E/S
E/S estilo C
Búferes
(en desuso en C++98)
Flujos
Abstracciones
E/S de archivos
E/S de cadenas
E/S de arrays
(en desuso en C++98)
(en desuso en C++98)
(en desuso en C++98)
Salida sincronizada
Tipos
Interfaz de categoría de error
(C++11)
 
std::basic_filebuf
Las funciones públicas miembros
Original:
Public member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Protegido funciones miembro
Original:
Protected member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_filebuf::setbuf
Terceros funciones
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
protected:
virtual std::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n )
Si s es un puntero nulo y n es cero, se convierte en el filebuf' sin memoria intermedia para la salida, es decir pbase() y pptr() son nulos y cualquier salida inmediatamente se envía al archivo .
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.
De lo contrario, una llamada a setbuf() sustituye a la interna buffer (la secuencia de caracteres de control) con la matriz de caracteres proporcionada por el usuario cuyo primer elemento es apuntado por s y permite que este objeto std::basic_filebuf utilizar hasta n bytes de la matriz de almacenamiento en búfer .
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.
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_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.

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

Las condiciones en las que esta función se puede utilizar y la forma en que se utiliza el búfer proporcionado es definido por la implantación .
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.
  • 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() sólo puede ser llamada cuando el std::basic_filebuf no está asociado con un archivo (no tiene ningún efecto contrario). Con proporcionado por el usuario buffer, al leer el archivo lee n-1 bytes a la vez .
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 reads n-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 libc + +
    Original:
    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() puede ser llamado una vez abierto el archivo, pero antes de I / O (se puede bloquear de otra manera). Con el buffer proporcionado por el usuario , la lectura de archivos lee más grandes múltiplos de 4096 que caben en el búfer .
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 2010
    Original:
    Visual Studio 2010
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
setbuf() se puede llamar en cualquier momento, incluso después de un I / O se llevó a cabo. contenido actual del buffer, en su caso, se pierden .
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.
El estándar no define el comportamiento de esta función, excepto que setbuf(0, 0) llamado antes que cualquier E / S se ha llevado a cabo se requiere para establecer la salida sin búfer .
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.

[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.

#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

Invoca a setbuf().
(función miembro pública de std::basic_streambuf<CharT,Traits>) [editar]
establece el tampón y su tamaño para una secuencia de archivo
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.

(función) [editar]