Loading...
Searching...
No Matches
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

  bin | the compressed data to decompress

Returns
  the uncompressed data as a binary object

Example:
  binary bin = bunzip2_to_binary(bzip2_string);

Exceptions

  BZIP2-DECOMPRESS-ERROR | the 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

  bin | the compressed data to decompress
  encoding | the 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-ERROR | the 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

  bin | the data to compress
  level | the 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-ERROR | level must be between 1 - 9
  BZIP2-COMPRESS-ERROR | the 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

  str | the data to compress
  level | the 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-ERROR | level must be between 1 - 9
  BZIP2-COMPRESS-ERROR | the 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

  bin | The binary object to compress
  level | Specifies 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-ERROR | level must be between 1 - 9 or -1
  ZLIB-ERROR | zlib 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

  str | The string to compress
  level | Specifies 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-ERROR | level must be between 1 - 9 or -1
  ZLIB-ERROR | zlib 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");
  Qore::TransformOutputStream ts(of, get_compressor(Qore::COMPRESSION_ALG_BZIP2));
  Qore::FileOutputStream
  This class implements the OutputStream interface for writing bytes to a file.
  Definition: QC_FileOutputStream.dox.h:28
  Qore::TransformOutputStream
  This class implements the OutputStream interface for writing bytes to another OutputStream while appl...
  Definition: QC_TransformOutputStream.dox.h:16
  Qore::COMPRESSION_ALG_BZIP2
  const COMPRESSION_ALG_BZIP2
  Identifies the bzip2 algorithm
  Definition: ql_compression.dox.h:335
  Qore::get_compressor
  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

  alg | the transformation algorithm; see Compression Stream Transformations for possible values
  level | compression 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");
  Qore::TransformOutputStream ts(of, get_decompressor(Qore::COMPRESSION_ALG_BZIP2));
  Qore::get_decompressor
  Transform get_decompressor(string alg)
  Returns a Transform object for decompressing data using the given algorithm for use with TransformInp...

Parameters

  alg | the 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

  bin | the compressed data to decompress

Returns
  the uncompressed data as a binary object

Example:
  binary bin = gunzip_to_binary(data);

Exceptions

  ZLIB-ERROR | The 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

  bin | the compressed data to decompress
  encoding | the 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-ERROR | The 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

  bin | the data to compress
  level | the 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-ERROR | level must be between 1 - 9 or -1
  ZLIB-ERROR | The 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

  str | the data to compress
  level | the 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-ERROR | level must be between 1 - 9 or -1
  ZLIB-ERROR | The 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

  bin | the data to decompress

Returns
  a binary object of the decompressed data

Example:
  binary bin = uncompress_to_binary(data);

Exceptions

  ZLIB-ERROR | The 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

  bin | the compressed data to decompress
  encoding | the 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-ERROR | The zlib library returned an error during processing (possibly due to corrupt input data)