◐ Shell
clean mode source ↗

std::basic_fstream::basic_fstream - cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

basic_fstream();

(1)

basic_fstream( const char* filename, {{#pad:|13}} ios_base::openmode mode = ios_base::in|ios_base::out );

(2)

basic_fstream( const string& filename, {{#pad:|13}} ios_base::openmode mode = ios_base::in|ios_base::out );

(3) (desde C++11)

basic_fstream( basic_fstream&& other );

(4) (desde C++11)

basic_fstream( const basic_fstream& rhs) = delete;

(5)

Constrói fluxo de arquivo novo.

Original:

Constructs new file stream.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

1)

Construtor padrão: constrói um fluxo que não está associado a um arquivo: default-constrói a std::basic_filebuf e constrói a base com o ponteiro para esse membro padrão construído std::basic_filebuf.

Original:

Default constructor: constructs a stream that is not associated with a file: default-constructs the std::basic_filebuf and constructs the base with the pointer to this default-constructed std::basic_filebuf member.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Primeiro, executa os mesmos passos que o construtor padrão, então asssociate o fluxo com um arquivo chamando rdbuf()->open(filename, mode).. Se a chamada open () retorna um ponteiro nulo, define setstate(failbit).

Original:

First, performs the same steps as the default constructor, then asssociate the stream with a file by calling rdbuf()->open(filename, mode).. If the open() call returns a null pointer, sets setstate(failbit).

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3)

Mesmo que basic_fstream(filename.c_str(), mode).

Original:

Same as basic_fstream(filename.c_str(), mode).

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

4)

Mova construtor. Primeiro, mover-constrói a classe base de other (que não afeta o ponteiro rdbuf()), em seguida, passar-constrói o membro std::basic_filebuf, em seguida, chama this->set_rdbuf() para instalar o novo basic_filebuf como o ponteiro rdbuf() na classe base.

Original:

Move constructor. First, move-constructs the base class from other (which does not affect the rdbuf() pointer), then move-constructs the std::basic_filebuf member, then calls this->set_rdbuf() to install the new basic_filebuf as the rdbuf() pointer in the base class.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

5)

O construtor de cópia é apagado: esta classe não é copiável.

Original:

The copy-constructor is deleted: this class is not copyable.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parâmetros

filename -

o nome do arquivo a ser aberto

Original:

the name of the file to be opened

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

mode -

especifica o modo de fluxo aberto. Ele é o tipo de máscara de bits, as seguintes constantes são definidas:

Constante

Original:

Constant

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Explanation
app

procurar o fim do fluxo antes de cada gravação

Original:

seek to the end of stream before each write

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

binary

abrir em modo binário

Original:

open in binary mode

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

in

Abrir para leitura

Original:

open for reading

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

out

abrir para escrita

Original:

open for writing

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

trunc

descartar o conteúdo da corrente durante a abertura

Original:

discard the contents of the stream when opening

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

ate

procurar o fim do fluxo imediatamente depois de aberto

Original:

seek to the end of stream immediately after open

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Original:

specifies stream open mode. It is bitmask type, the following constants are defined:

Constante

Original:

Constant

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Explanation
app

procurar o fim do fluxo antes de cada gravação

Original:

seek to the end of stream before each write

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

binary

abrir em modo binário

Original:

open in binary mode

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

in

Abrir para leitura

Original:

open for reading

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

out

abrir para escrita

Original:

open for writing

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

trunc

descartar o conteúdo da corrente durante a abertura

Original:

discard the contents of the stream when opening

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

ate

procurar o fim do fluxo imediatamente depois de aberto

Original:

seek to the end of stream immediately after open

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

other -

outro fluxo de arquivo para usar como fonte

Original:

another file stream to use as source

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Exemplo

#include <fstream>
#include <utility>
#include <string>
int main()
{
std::fstream f0;
    std::fstream f1("test.bin", std::ios::binary);
    std::string name = "example.txt";
    std::fstream f2(name);
    std::fstream f3(std::move(f1));
}

Veja também

abre um arquivo e associa com o fluxo

Original:

opens a file and associates it with the stream

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(função pública membro) [edit]

abre um arquivo e configura como a seqüência de caracteres associado

Original:

opens a file and configures it as the associated character sequence

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_filebuf função pública membro) [edit]

substitui o rdbuf sem limpar seu estado de erro

Original:

replaces the rdbuf without clearing its error state

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(protegido função de membro) [edit]

Constrói o objeto

Original:

constructs the object

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_iostream função pública membro) [edit]