strstreambuf::freeze

Faz com que um buffer de fluxo não está disponível com as operações de buffer de fluxo.

void freeze(
   bool _Freezeit = true
);

Parâmetros

  • _Freezeit
    bool que indica se você desejar que o fluxo a ser congelado.

Comentários

Se _Freezeit é verdadeiro, a função altera o modo de strstreambuf armazenado para fazer a seqüência controlada congelado.Caso contrário, faz a seqüência controlada não congelado.

str implica freeze.

ObservaçãoObservação

Um buffer congelado não será liberado durante a destruição de strstreambuf .Você deve descongelar o buffer antes de ser liberado para evitar um vazamento de memória.

Exemplo

// strstreambuf_freeze.cpp
// compile with: /EHsc

#include <iostream>
#include <strstream>

using namespace std;

void report(strstream &x)
{
    if (!x.good())
        cout << "stream bad" << endl;
    else
        cout << "stream good" << endl;
}

int main()
{
    strstream x;

    x << "test1";
    cout << "before freeze: ";
    report(x);

    // Calling str freezes stream.
    cout.write(x.rdbuf()->str(), 5) << endl;
    cout << "after freeze: ";
    report(x);

    // Stream is bad now, wrote on frozen stream
    x << "test1.5";
    cout << "after write to frozen stream: ";
    report(x);

    // Unfreeze stream, but it is still bad
    x.rdbuf()->freeze(false);
    cout << "after unfreezing stream: ";
    report(x);

    // Clear stream
    x.clear();
    cout << "after clearing stream: ";
    report(x);

    x << "test3";
    cout.write(x.rdbuf()->str(), 10) << endl;

    // Clean up.  Failure to unfreeze stream will cause a
    // memory leak.
    x.rdbuf()->freeze(false);
}
  

Requisitos

Cabeçalho: <strstream>

namespace: STD

Consulte também

Referência

strstreambuf Class

iostream de programação

Convenções de iostreams