next up previous contents index
Next: Decoding File Stream ( Up: Lossless Compression Previous: Decoding Input Stream (   Contents   Index


Encoding File Stream ( encoding_ofstream )

Definition

The type encoding_ofstream<Coder> is the encoding counterpart of the type ofstream from the C++ iostream library. Each instance os of type encoding_ofstream<Coder> is associated with a file. Every data that is written to os is encoded on-the-fly by an instance of type Coder and then written to the associated file. All operations and all operators («) defined for C++ ostreams can be applied to encoding_ofstream as well.

#include < LEDA/coding/coder_util.h >

Creation

encoding_ofstream< Coder> os(const char* file_name = 0, ios::openmode mode = ios::openmode(ios::out | ios::trunc))
    creates an instance os. If file_name is specified, the stream is attached to the file with the given name.

Operations

bool os.is_open() returns if os is attached to an open file.

void os.open(const char* file_name = 0, ios::openmode mode = ios::openmode(ios::out | ios::trunc))
    opens a file and attaches os to it.

void os.close() closes the attached file and detaches os from it.

streampos os.tellp() queries the position of the (internal) put pointer. This pointer determines the position in the (original) stream whereto the next character is written.

ostream& os.seekp(streampos pos) sets the position of the put pointer to pos. pos must be greater than the current put pointer. The skipped characters are assumed to be zero.

ostream& os.seekp(streamoff off, ios::seekdir dir)
    moves the put pointer by off relative to the position determined by dir. dir can be ios::beg (beginning), ios::cur (current position) or ios::end (last position). The new position of the put pointer has to be greater than its current position. The skipped characters are assumed to be zero.

Coder* os.get_coder() returns the instance of Coder which is used for encoding.


next up previous contents index
Next: Decoding File Stream ( Up: Lossless Compression Previous: Decoding Input Stream (   Contents   Index
Christian Uhrig 2017-04-07