Name

SPVM::Compress::Raw::Zlib::Deflate - Low-Level Interface to zlib inflate

Description

Compress::Raw::Zlib::Deflate class in SPVM is a low-level interface to zlib inflate function.

Usage

use Compress::Raw::Zlib::Deflate;

my $d = Compress::Raw::Zlib::Deflate->new($options);
my $output_ref = [(string)undef];
$d->deflate($input, $output_ref);
$d->flush($output_ref);
$d->deflateReset;
$d->deflateParams($options);
$d->deflateTune($good_length, $max_lazy, $nice_length, $max_chain);
$d->adler;
$d->total_in;
$d->total_out;
$d->get_Strategy;
$d->get_Level;
$d->get_BufSize;

Super Class

Compress::Raw::Zlib::Base

Class Methods

new

static method new : Compress::Raw::Zlib::Deflate ($options : object[] = undef);

Creates a new Compress::Raw::Zlib::Deflate object, and returns it.

Options:

  • Level : Int = Z_DEFAULT_COMPRESSION

    The compression level.

  • Method : Int = Z_DEFLATED

    The compression method.

  • WindowBits : Int = MAX_WBITS

    To compress an RFC 1950 data stream, set WindowBits to a positive number between 8 and 15.

    To compress an RFC 1951 data stream, set WindowBits to -MAX_WBITS.

    To compress an RFC 1952 data stream (i.e. gzip), set WindowBits to WANT_GZIP.

    For a definition of the meaning and valid values for WindowBits refer to the zlib documentation for deflateInit2.

  • MemLevel : Int = MAX_MEM_LEVEL

    For a definition of the meaning and valid values for MemLevel refer to the zlib documentation for deflateInit2.

  • Strategy : Int = Z_DEFAULT_STRATEGY

    The strategy used to tune the compression.

  • Dictionary : Int = undef

    The dictionary.

  • Bufsize : Int = 4096

    The initial size for the output buffer.

See Compress::Raw::Zlib::Constant about zlib constants.

Instance Methods

deflate

method deflate : int ($input : string, $output_ref : string[]);

Deflates the contents of $input and writes the compressed data to $output_ref->[0].

Returns the zlib status of the last inflate call.

flush

method flush : int ($output_ref : string[], $flush_type : int = -1);

Typically used to finish the deflation.

If $flush_type is a negative value, it is set to Z_FINISH.

Returns the zlib status of the last inflate call.

deflateParams

method deflateParams : void ($options : object[] = undef);

Changes settings of the z_stream object.

Options:

  • Level : Int = Current Level

    The compression level.

  • Strategy : Int = Current Strategy

    The strategy used to tune the compression.

deflateReset

method deflateReset : void ();

Reset the z_stream object.

deflateTune

method deflateTune : void ($good_length : int, $max_lazy : int, $nice_length : int, $max_chain : int);

Tune the internal settings of the z_stream object.

get_Strategy

method get_Strategy : int ();

Returns the deflation strategy currently used.

get_Level

method get_Level : int ();

Returns the compression level being used.

DESTROY

method DESTROY : void ();

Finalizes and frees z_stream object.

See Also

Copyright & License

Copyright (c) 2025 Yuki Kimoto

MIT License