Qore Programming Language Reference Manual  1.8.0
Compression Functions
Collaboration diagram for Compression Functions:

Modules

 Compression Constants
 
 Compression Stream Transformations
 

Functions

binary Qore::bunzip2_to_binary (binary bin)
 Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a binary object. More...
 
nothing Qore::bunzip2_to_binary ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::bunzip2_to_string (binary bin, *string encoding)
 Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a string. More...
 
nothing Qore::bunzip2_to_string ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
binary Qore::bzip2 (binary bin, softint level=BZ2_DEFAULT_COMPRESSION)
 Compresses the given data with the bzip2 algorithm and returns the compressed data as a binary. More...
 
binary Qore::bzip2 (string str, softint level=BZ2_DEFAULT_COMPRESSION)
 Compresses the given data with the bzip2 algorithm and returns the compressed data as a binary. More...
 
nothing Qore::bzip2 ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
binary Qore::compress (string str, int level=Z_DEFAULT_COMPRESSION)
 Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compressed data. More...
 
binary Qore::compress (binary bin, int level=Z_DEFAULT_COMPRESSION)
 Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compressed data. More...
 
nothing Qore::compress ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
Transform Qore::get_compressor (string alg, int level=COMPRESSION_LEVEL_DEFAULT)
 Returns a Transform object for compressing data using the given algorithm for use with TransformInputStream and TransformOutputStream. More...
 
Transform Qore::get_decompressor (string alg)
 Returns a Transform object for decompressing data using the given algorithm for use with TransformInputStream and TransformOutputStream. More...
 
binary Qore::gunzip_to_binary (binary bin)
 Performs zlib-based decompression of data compressed with the "gzip" algorithm (RFC 1952) and returns a binary object of the uncompressed data. More...
 
nothing Qore::gunzip_to_binary ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::gunzip_to_string (binary bin, *string encoding)
 Performs zlib-based decompression of data compressed with the "gzip" algorithm (RFC 1952) and returns a string of the uncompressed datas. More...
 
nothing Qore::gunzip_to_string ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
binary Qore::gzip (string str, int level=Z_DEFAULT_COMPRESSION)
 Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed data. More...
 
binary Qore::gzip (binary bin, int level=Z_DEFAULT_COMPRESSION)
 Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed data. More...
 
nothing Qore::gzip ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
binary Qore::uncompress_to_binary (binary bin)
 Performs zlib-based decompression of data compressed by the "deflate" algorithm (RFC 1951) and returns a binary object of the decompressed data. More...
 
nothing Qore::uncompress_to_binary ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::uncompress_to_string (binary bin, *string encoding)
 Performs zlib-based decompression of data compressed by the "deflate" algorithm (RFC 1951) and returns a string of the decompressed data. More...
 
nothing Qore::uncompress_to_string ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 

Detailed Description

These functions work with compression and decompression

Function Documentation

◆ bunzip2_to_binary() [1/2]

nothing Qore::bunzip2_to_binary ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ bunzip2_to_binary() [2/2]

binary Qore::bunzip2_to_binary ( binary  bin)

Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a binary object.

Parameters
binthe compressed data to decompress
Returns
the uncompressed data as a binary object
Example:
binary bin = bunzip2_to_binary(bzip2_string);
binary bunzip2_to_binary(binary bin)
Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a binary ob...
Exceptions
BZIP2-DECOMPRESS-ERRORthe bzip2 library returned an internal error during processing (possibly due to corrupt input data)

◆ bunzip2_to_string() [1/2]

nothing Qore::bunzip2_to_string ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ bunzip2_to_string() [2/2]

string Qore::bunzip2_to_string ( binary  bin,
*string  encoding 
)

Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a string.

Parameters
binthe compressed data to decompress
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed.
Returns
the uncompressed data as a string
Example:
string str = bunzip2_to_string(bzip2_string, "iso-8859-1");
string bunzip2_to_string(binary bin, *string encoding)
Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a string.
Exceptions
BZIP2-DECOMPRESS-ERRORthe bzip2 library returned an internal error during processing (possibly due to corrupt input data)

◆ bzip2() [1/3]

nothing Qore::bzip2 ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ bzip2() [2/3]

binary Qore::bzip2 ( binary  bin,
softint  level = BZ2_DEFAULT_COMPRESSION 
)

Compresses the given data with the bzip2 algorithm and returns the compressed data as a binary.

Parameters
binthe data to compress
levelthe compression level, must be a value between 1 and 9 inclusive, 1 = the least compression (and taking the least memory), 9 = the most compression (using the most memory). An invalid option passed to this argument will result in a BZLIB2-LEVEL-ERROR exception being raised.
Returns
the compressed data as a binary object
Example:
binary bin = bzip2(data);
binary bzip2(binary bin, softint level=BZ2_DEFAULT_COMPRESSION)
Compresses the given data with the bzip2 algorithm and returns the compressed data as a binary.
Exceptions
BZLIB2-LEVEL-ERRORlevel must be between 1 - 9
BZIP2-COMPRESS-ERRORthe bzip2 library returned an error during processing

◆ bzip2() [3/3]

binary Qore::bzip2 ( string  str,
softint  level = BZ2_DEFAULT_COMPRESSION 
)

Compresses the given data with the bzip2 algorithm and returns the compressed data as a binary.

Strings are compressed without the trailing null character

Parameters
strthe data to compress
levelthe compression level, must be a value between 1 and 9 inclusive, 1 = the least compression (and taking the least memory), 9 = the most compression (using the most memory). An invalid option passed to this argument will result in a BZLIB2-LEVEL-ERROR exception being raised.
Returns
the compressed data as a binary object
Example:
binary bin = bzip2(str);
Exceptions
BZLIB2-LEVEL-ERRORlevel must be between 1 - 9
BZIP2-COMPRESS-ERRORthe bzip2 library returned an error during processing

◆ compress() [1/3]

nothing Qore::compress ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ compress() [2/3]

binary Qore::compress ( binary  bin,
int  level = Z_DEFAULT_COMPRESSION 
)

Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compressed data.

Note that strings are compressed without the trailing null character.

Parameters
binThe binary object to compress
levelSpecifies the compression level; must be an integer between 1 and 9, 9 meaning the highest compression level. The default value Z_DEFAULT_COMPRESSION gives a tradeoff between speed and compression size
Returns
a binary object of the compressed data
Example:
binary bin = compress(bin_data);
binary compress(string str, int level=Z_DEFAULT_COMPRESSION)
Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compress...
Exceptions
ZLIB-LEVEL-ERRORlevel must be between 1 - 9 or -1
ZLIB-ERRORzlib returned an error while processing

◆ compress() [3/3]

binary Qore::compress ( string  str,
int  level = Z_DEFAULT_COMPRESSION 
)

Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compressed data.

Note that strings are compressed without the trailing null character.

Parameters
strThe string to compress
levelSpecifies the compression level; must be an integer between 1 and 9, 9 meaning the highest compression level. The default value Z_DEFAULT_COMPRESSION gives a tradeoff between speed and compression size
Returns
a binary object of the compressed data
Example:
binary bin = compress(str_data);
Exceptions
ZLIB-LEVEL-ERRORlevel must be between 1 - 9 or -1
ZLIB-ERRORzlib returned an error while processing

◆ get_compressor()

Transform Qore::get_compressor ( string  alg,
int  level = COMPRESSION_LEVEL_DEFAULT 
)

Returns a Transform object for compressing data using the given algorithm for use with TransformInputStream and TransformOutputStream.

Example:
Qore::FileOutputStream of("my-file.txt.bz2");
This class implements the OutputStream interface for writing bytes to a file.
Definition: QC_FileOutputStream.dox.h:28
This class implements the OutputStream interface for writing bytes to another OutputStream while appl...
Definition: QC_TransformOutputStream.dox.h:16
const COMPRESSION_ALG_BZIP2
Identifies the bzip2 algorithm
Definition: ql_compression.dox.h:335
Transform get_compressor(string alg, int level=COMPRESSION_LEVEL_DEFAULT)
Returns a Transform object for compressing data using the given algorithm for use with TransformInput...
Parameters
algthe transformation algorithm; see Compression Stream Transformations for possible values
levelcompression level as defined by the algorithm or COMPRESSION_LEVEL_DEFAULT to use the default compression level
Returns
a Transform object for compressing data using the given algorithm for use with TransformInputStream and TransformOutputStream
See also
Qore::get_decompressor()
Since
Qore 0.8.13

◆ get_decompressor()

Transform Qore::get_decompressor ( string  alg)

Returns a Transform object for decompressing data using the given algorithm for use with TransformInputStream and TransformOutputStream.

Example:
Qore::FileOutputStream of("my-file.txt.bz2");
Transform get_decompressor(string alg)
Returns a Transform object for decompressing data using the given algorithm for use with TransformInp...
Parameters
algthe transformation algorithm; see Compression Stream Transformations for possible values
Returns
a Transform object for decompressing data using the given algorithm for use with TransformInputStream and TransformOutputStream
See also
Qore::get_compressor()
Since
Qore 0.8.13

◆ gunzip_to_binary() [1/2]

nothing Qore::gunzip_to_binary ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ gunzip_to_binary() [2/2]

binary Qore::gunzip_to_binary ( binary  bin)

Performs zlib-based decompression of data compressed with the "gzip" algorithm (RFC 1952) and returns a binary object of the uncompressed data.

Parameters
binthe compressed data to decompress
Returns
the uncompressed data as a binary object
Example:
binary bin = gunzip_to_binary(data);
binary gunzip_to_binary(binary bin)
Performs zlib-based decompression of data compressed with the "gzip" algorithm (RFC 1952) and returns...
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ gunzip_to_string() [1/2]

nothing Qore::gunzip_to_string ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ gunzip_to_string() [2/2]

string Qore::gunzip_to_string ( binary  bin,
*string  encoding 
)

Performs zlib-based decompression of data compressed with the "gzip" algorithm (RFC 1952) and returns a string of the uncompressed datas.

Parameters
binthe compressed data to decompress
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed.
Returns
the uncompressed data as a string
Example:
string str = gunzip_to_string(bin, "iso-8859-1");
string gunzip_to_string(binary bin, *string encoding)
Performs zlib-based decompression of data compressed with the "gzip" algorithm (RFC 1952) and returns...
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ gzip() [1/3]

nothing Qore::gzip ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ gzip() [2/3]

binary Qore::gzip ( binary  bin,
int  level = Z_DEFAULT_COMPRESSION 
)

Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed data.

Parameters
binthe data to compress
levelthe compression level, must be a value between 1 and 9 inclusive, 1 = the least compression (and taking the least memory), 9 = the most compression (using the most memory). An invalid option passed to this argument will result in a ZLIB-LEVEL-ERROR exception being raised.
Returns
the compressed data as a binary object
Example:
binary data = gzip(bin);
binary gzip(string str, int level=Z_DEFAULT_COMPRESSION)
Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed ...
Exceptions
ZLIB-LEVEL-ERRORlevel must be between 1 - 9 or -1
ZLIB-ERRORThe zlib library returned an error during processing (should not normally happen during compression)

◆ gzip() [3/3]

binary Qore::gzip ( string  str,
int  level = Z_DEFAULT_COMPRESSION 
)

Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed data.

Strings are compressed without the trailing null character

Parameters
strthe data to compress
levelthe compression level, must be a value between 1 and 9 inclusive, 1 = the least compression (and taking the least memory), 9 = the most compression (using the most memory). An invalid option passed to this argument will result in a ZLIB-LEVEL-ERROR exception being raised.
Returns
the compressed data as a binary object
Example:
binary data = gzip(str);
Exceptions
ZLIB-LEVEL-ERRORlevel must be between 1 - 9 or -1
ZLIB-ERRORThe zlib library returned an error during processing (should not normally happen during compression)

◆ uncompress_to_binary() [1/2]

nothing Qore::uncompress_to_binary ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ uncompress_to_binary() [2/2]

binary Qore::uncompress_to_binary ( binary  bin)

Performs zlib-based decompression of data compressed by the "deflate" algorithm (RFC 1951) and returns a binary object of the decompressed data.

Parameters
binthe data to decompress
Returns
a binary object of the decompressed data
Example:
binary bin = uncompress_to_binary(data);
binary uncompress_to_binary(binary bin)
Performs zlib-based decompression of data compressed by the "deflate" algorithm (RFC 1951) and return...
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ uncompress_to_string() [1/2]

nothing Qore::uncompress_to_string ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP

◆ uncompress_to_string() [2/2]

string Qore::uncompress_to_string ( binary  bin,
*string  encoding 
)

Performs zlib-based decompression of data compressed by the "deflate" algorithm (RFC 1951) and returns a string of the decompressed data.

Parameters
binthe compressed data to decompress
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed.
Returns
the uncompressed data as a string
Example:
string str = uncompress_to_string(bin, "iso-8859-1");
string uncompress_to_string(binary bin, *string encoding)
Performs zlib-based decompression of data compressed by the "deflate" algorithm (RFC 1951) and return...
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)