Qore Programming Language Reference Manual  0.9.3.2
Compression Functions

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]

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);
Exceptions
BZIP2-DECOMPRESS-ERRORthe bzip2 library returned an internal error during processing (possibly due to corrupt input data)

◆ bunzip2_to_binary() [2/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_string() [1/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");
Exceptions
BZIP2-DECOMPRESS-ERRORthe bzip2 library returned an internal error during processing (possibly due to corrupt input data)

◆ bunzip2_to_string() [2/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

◆ bzip2() [1/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);
Exceptions
BZLIB2-LEVEL-ERRORlevel must be between 1 - 9
BZIP2-COMPRESS-ERRORthe bzip2 library returned an error during processing

◆ bzip2() [2/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

◆ bzip2() [3/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

◆ compress() [1/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

◆ 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);
Exceptions
ZLIB-LEVEL-ERRORlevel must be between 1 - 9 or -1
ZLIB-ERRORzlib returned an error while processing

◆ compress() [3/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

◆ 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:
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:
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]

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);
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ gunzip_to_binary() [2/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_string() [1/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");
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ gunzip_to_string() [2/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

◆ gzip() [1/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)

◆ 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);
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]

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

◆ uncompress_to_binary() [1/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);
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ uncompress_to_binary() [2/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_string() [1/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");
Exceptions
ZLIB-ERRORThe zlib library returned an error during processing (possibly due to corrupt input data)

◆ uncompress_to_string() [2/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