Compress and write bytes to a Zlib-compressed buffer.
More...
#include <ZlibBufferWriter.hpp>
|
| ZlibBufferWriter (int mode=2, int compression_level=6, size_t buffer_size=65536) |
|
void | write (const unsigned char *buffer, size_t n) |
|
void | finish () |
|
std::vector< unsigned char > & | get_output () |
|
void | write (const std::string &x) |
|
void | write (const char *x) |
|
void | write (char x) |
|
void | write (const std::string &x) |
|
void | write (const char *x) |
|
void | write (char x) |
|
Compress and write bytes to a Zlib-compressed buffer.
This is basically a wrapper around Zlib's deflate method, with correct closing and error checking.
◆ ZlibBufferWriter()
byteme::ZlibBufferWriter::ZlibBufferWriter |
( |
int | mode = 2, |
|
|
int | compression_level = 6, |
|
|
size_t | buffer_size = 65536 ) |
|
inline |
- Parameters
-
mode | Compression mod of the stream - DEFLATE (0), Zlib (1) or Gzip (2). |
compression_level | Compression level from 1 to 9. Larger values improve compression at the cost of speed. |
buffer_size | Size of the compression buffer in bytes. Larger values improve speed at the cost of memory. |
◆ finish()
void byteme::ZlibBufferWriter::finish |
( |
| ) |
|
|
inlinevirtual |
Indicate that the writing has finished and that the relevant clean-up (buffer flushing, file closing, etc.) should be performed. This should be called exactly once, after which no further calls to write()
or finish()
should be performed.
Implements byteme::Writer.
◆ get_output()
std::vector< unsigned char > & byteme::ZlibBufferWriter::get_output |
( |
| ) |
|
|
inline |
- Returns
- Contents of the output buffer. This should only be used after
finish()
is called.
◆ write() [1/4]
void byteme::Writer::write |
( |
char | x | ) |
|
|
inline |
Write a single character to the output sink.
- Parameters
-
x | Character to be written. |
◆ write() [2/4]
void byteme::Writer::write |
( |
const char * | x | ) |
|
|
inline |
Write a null-terminated C-string to the output sink.
- Parameters
-
[in] | x | Pointer to the string to be written. |
◆ write() [3/4]
void byteme::Writer::write |
( |
const std::string & | x | ) |
|
|
inline |
Write a string to the output sink.
- Parameters
-
◆ write() [4/4]
void byteme::ZlibBufferWriter::write |
( |
const unsigned char * | buffer, |
|
|
size_t | n ) |
|
inlinevirtual |
Write the next chunk of bytes to the output sink. This may or may not be internally buffered at the discretion of the concrete class.
- Parameters
-
[in] | buffer | Pointer to the start of an array containing the bytes to be written. |
| n | Length of the array in buffer . |
Implements byteme::Writer.
The documentation for this class was generated from the following file: