Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::CompressBuffer Class Reference

Stream buffer that performs compression. More...

#include <compression.hh>

Inheritance diagram for ghidra::CompressBuffer:
[legend]
Collaboration diagram for ghidra::CompressBuffer:
[legend]

Public Member Functions

 CompressBuffer (ostream &s, int4 level)
 Constructor.
 
 ~CompressBuffer (void)
 Destructor.
 

Protected Member Functions

void flushInput (bool lastBuffer)
 Compress the current set of bytes in the input buffer.
 
virtual int overflow (int c)
 Pass the filled input buffer to the compressor.
 
virtual int sync (void)
 Pass remaining bytes in the input buffer to the compressor.
 

Private Attributes

ostream & outStream
 The backing stream receiving compressed bytes.
 
uint1 * inBuffer
 The input buffer.
 
uint1 * outBuffer
 The output buffer.
 
Compress compressor
 Compressor state.
 

Static Private Attributes

static const int4 IN_BUFFER_SIZE = 4096
 Number of bytes in the input buffer.
 
static const int4 OUT_BUFFER_SIZE = 4096
 Number of bytes in the output buffer.
 

Detailed Description

Stream buffer that performs compression.

Provides an ostream filter that compresses the stream using the deflate algorithm. The stream buffer is provided a backing stream that is the ultimate destination of the compressed bytes. A front-end stream is initialized with this stream buffer. After writing the full sequence of bytes to compressed to the front-end stream, make sure to call the stream's flush() method to emit the final compressed bytes to the backing stream.

Constructor & Destructor Documentation

◆ CompressBuffer()

ghidra::CompressBuffer::CompressBuffer ( ostream &  s,
int4  level 
)

Constructor.

Parameters
sis the backing output stream
levelis the level of compression

References IN_BUFFER_SIZE, inBuffer, OUT_BUFFER_SIZE, and outBuffer.

Member Function Documentation

◆ flushInput()

void ghidra::CompressBuffer::flushInput ( bool  lastBuffer)
protected

Compress the current set of bytes in the input buffer.

The compressor is called repeatedly and its output is written to the backing stream until the compressor can no longer fill the output buffer.

Parameters
lastBufferis true if this is the final set of bytes to add to the compressed stream

References compressor, ghidra::Compress::deflate(), ghidra::Compress::input(), OUT_BUFFER_SIZE, outBuffer, and outStream.

Referenced by overflow(), and sync().

◆ overflow()

int ghidra::CompressBuffer::overflow ( int  c)
protectedvirtual

Pass the filled input buffer to the compressor.

Parameters
cis the final character filling the buffer
Returns
the written character

References flushInput().

◆ sync()

int ghidra::CompressBuffer::sync ( void  )
protectedvirtual

Pass remaining bytes in the input buffer to the compressor.

Returns
0 for success

References flushInput().


The documentation for this class was generated from the following files: