SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Derived stream buffer that reads and writes compressed data to an associated std::streambuf. More...
#include <rw/tools/cmpstreambuf.h>
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 * | open (std::streambuf *stream_buffer, std::ios_base::openmode mode, rwuint32 block_size) |
RWCompressedStreamBuffer * | close () |
bool | is_open () const |
const Compressor & | get_compressor () const |
Derived stream buffer that reads and writes compressed data to an associated std::streambuf using the provided compressor type.
The compressor must be copy constructable, and if an instance isn't provided to the constructor, it must be default constructable. 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 successfull 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 RWCompressedStreamBuffer< Compressor >::~RWCompressedStreamBuffer | ( | ) | [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.
const Compressor& RWCompressedStreamBuffer< Compressor >::get_compressor | ( | ) | const [inline] |
Returns a reference to the underlying compressor.
bool RWCompressedStreamBuffer< Compressor >::is_open | ( | ) | const [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 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.