SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Derived stream buffer that reads and writes compressed data to an associated std::streambuf. More...
#include <rw/tools/cmpstreambuf.h>
Inherits streambuf.
Public Member Functions | |
RWCompressedStreamBuffer (const Compressor &compressor=Compressor()) | |
RWCompressedStreamBuffer (std::streambuf *stream_buffer, std::ios_base::openmode mode, rwuint32 block_size, const Compressor &compressor=Compressor()) | |
virtual | ~RWCompressedStreamBuffer () |
RWCompressedStreamBuffer * | close () |
const Compressor & | get_compressor () const |
bool | is_open () const |
RWCompressedStreamBuffer * | open (std::streambuf *stream_buffer, std::ios_base::openmode mode, rwuint32 block_size) |
Derived stream buffer that reads and writes compressed data to an associated std::streambuf using the provided compressor type.
The compressor must be copy constructible, and if an instance isn't provided to the constructor, it must be default constructible. It is also expected to support the following interface methods.
The parameter dst_len initially describes the length of the output buffer dst, and src_len describes the length of the input buffer src. This function compresses src_len bytes of data from src into dst and puts the number of bytes written to dst into dst_len. Must return 0 on success, or a negative value on error.
The parameter dst_len initially describes the length of the output buffer dst, and src_len describes the length of the input buffer src. This function decompresses src_len bytes of data from src into dst and puts the number of bytes written to dst into dst_len. Must return 0 on success, or a negative value on error.
The parameter src_len is the length of an uncompressed data buffer. This function writes the worst case compressed size of that data to dst_len. Must return 0 on success, or a negative value on error.
RWCompressedStreamBuffer< Compressor >::RWCompressedStreamBuffer | ( | const Compressor & | compressor = Compressor() | ) |
Constructor initializes a stream buffer that uses compressor to compress or decompress data. A successful call to open() is required before this stream buffer can be used.
RWCompressedStreamBuffer< Compressor >::RWCompressedStreamBuffer | ( | std::streambuf * | stream_buffer, |
std::ios_base::openmode | mode, | ||
rwuint32 | block_size, | ||
const Compressor & | compressor = Compressor() |
||
) |
Constructor initializes a stream buffer that reads compressed data from or writes compressed data to stream_buffer in buffers of up to block_size bytes, and uses compressor to compress or decompress data as necessary. The mode parameter controls how this stream buffer may be used.
|
virtual |
Destructor.
RWCompressedStreamBuffer* RWCompressedStreamBuffer< Compressor >::close | ( | ) |
Closes this stream buffer, flushes all pending data, and disassociates it from the underlying std::streambuf. After calling this method, this stream buffer cannot be used for input or output until it has been reopened with a successful call to open().
Returns NULL
on error, otherwise returns a pointer to self.
|
inline |
Returns a reference to the underlying compressor.
|
inline |
Returns true
if this stream buffer is open and is ready for use, otherwise returns false
.
RWCompressedStreamBuffer* RWCompressedStreamBuffer< Compressor >::open | ( | std::streambuf * | stream_buffer, |
std::ios_base::openmode | mode, | ||
rwuint32 | block_size | ||
) |
Opens this stream buffer to read or write compressed data.
If mode indicates that this stream buffer is to be used for output, block_size specifies the number of bytes of uncompressed data to be buffered. When the buffer is overfilled or flushed, it will be compressed and written to stream_buffer.
If mode indicates that this stream buffer is to be used for input, data will be read from stream_buffer and decompressed into a local buffer. The size of this local buffer is not associated with block_size in any way.
Returns NULL
when this stream buffer is already open or if there is some other error, otherwise returns a pointer to self.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |