SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Deserializes and decompresses data from an associated std::streambuf. More...
#include <rw/tools/cmpstream.h>
Inherits std::istream.
Public Member Functions | |
RWCompressedIStream (std::streambuf *stream_buffer, std::ios_base::openmode mode=std::ios_base::in, rwuint32 block_size=2048U, const Compressor &compressor=Compressor()) | |
RWCompressedIStream (std::istream &stream, std::ios_base::openmode mode=std::ios_base::in, rwuint32 block_size=2048U, const Compressor &compressor=Compressor()) | |
void | open (std::streambuf *stream_buffer, std::ios_base::openmode mode=std::ios_base::in, rwuint32 block_size=2048U) |
void | close () |
bool | is_open () const |
const Compressor & | get_compressor () const |
RWCompressedStreamBuffer < Compressor > * | rdbuf () const |
Class RWCompressedIStream deserializes and decompresses data from an associated std::streambuf. The data on that streambuf must have been serialized with its counterpart RWCompressedOStream.
#include <rw/tools/cmpstream.h> RWCompressedIStream<Compressor> cstr(std::cin); // Construct an RWCompressedIStream using cin's streambuf
None
// for SourcePro Core Tools Module compressed streams #include <rw/tools/cmpstream.h> // for SourcePro Core Tools Module endian streams #include <rw/estream.h> // for SourcePro Core Tools Module strings #include <rw/cstring.h> // for SourcePro Core Snappy compressor #include <rw/tools/snappy/RWSnappyCompressor.h> // for C++ Standard Library file streams #include <fstream> int main () { // open the file to read from std::ifstream input_file ("output.snap", std::ios_base::binary); // layer a compressed stream on top of the file RWCompressedIStream<RWSnappyCompressor> compressed_stream (input_file); // layer an endian stream on top of the compressed stream RWeistream endian_stream (compressed_stream); // // Any data read from the endian stream is read from the file // stream, decompressed by the compressed stream, and converted from // an endian safe format into binary data by the endian stream. // RWCString data; endian_stream >> data; std::cout << data; return 0; }
Program output:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
RWCompressedIStream< Compressor >::RWCompressedIStream | ( | std::streambuf * | stream_buffer, | |
std::ios_base::openmode | mode = std::ios_base::in , |
|||
rwuint32 | block_size = 2048U , |
|||
const Compressor & | compressor = Compressor() | |||
) | [inline] |
Constructor initializes and opens the underlying stream buffer with the provided stream_buffer, mode, block_size, and compressor. If the open fails, failbit is set on this stream.
RWCompressedIStream< Compressor >::RWCompressedIStream | ( | std::istream & | stream, | |
std::ios_base::openmode | mode = std::ios_base::in , |
|||
rwuint32 | block_size = 2048U , |
|||
const Compressor & | compressor = Compressor() | |||
) | [inline] |
Constructor initializes and opens the underlying stream buffer with the provided mode, block_size, compressor, and the stream buffer associated with stream. If the open fails, failbit is set on this stream.
void RWCompressedIStream< Compressor >::close | ( | ) | [inline] |
Closes the underlying stream buffer. If the close fails, failbit is set on this stream. After this method has been called, this stream cannot be used for input until a successfull call to open() has been made.
const Compressor& RWCompressedIStream< Compressor >::get_compressor | ( | ) | const [inline] |
Returns a reference to the underlying stream buffer's compressor.
bool RWCompressedIStream< Compressor >::is_open | ( | ) | const [inline] |
Returns true
if the underlying stream buffer is open and is ready for use, otherwise returns false
.
void RWCompressedIStream< Compressor >::open | ( | std::streambuf * | stream_buffer, | |
std::ios_base::openmode | mode = std::ios_base::in , |
|||
rwuint32 | block_size = 2048U | |||
) | [inline] |
Opens the underlying stream buffer with the provided stream_buffer, mode, and block_size. If the open fails, failbit is set on this stream.
RWCompressedStreamBuffer<Compressor>* RWCompressedIStream< Compressor >::rdbuf | ( | ) | const [inline] |
Returns a pointer to the underlying stream buffer.
© 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.