std.zlib - D Programming Language

D Programming Language
Report a bug If you spot a problem with this page, click here to create a Bugzilla issue. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

# std.zlib

Compress/decompress data using the zlib.net">zlib library.

References: Wikipedia

License:
Boost License 1.0.
Authors:
Walter Bright

Source: std/zlib.d

class ZlibException: object.Exception;
  Errors throw a ZlibException.
uint adler32(uint adler, const(void)[] buf);

  Compute the Adler-32 checksum of a buffer's worth of data.

  Parameters:

  uint adler | the starting checksum for the computation. Use 0 for a new checksum. Use the output of this function for a cumulative checksum.
  const(void)[] buf | buffer containing input data

  Returns:
  A uint checksum for the provided input data and starting checksum
  See Also:
  http://en.wikipedia.org/wiki/Adler-32
uint crc32(uint crc, const(void)[] buf);

  Compute the CRC32 checksum of a buffer's worth of data.

  Parameters:

  uint crc | the starting checksum for the computation. Use 0 for a new checksum. Use the output of this function for a cumulative checksum.
  const(void)[] buf | buffer containing input data

  Returns:
  A uint checksum for the provided input data and starting checksum
  See Also:
  http://en.wikipedia.org/wiki/Cyclic_redundancy_check
const(void)[] compress(const(void)[] srcbuf, int level);
const(void)[] compress(const(void)[] srcbuf);

  Compress data

  Parameters:

  const(void)[] srcbuf | buffer containing the data to compress
  int level | compression level. Legal values are 1..9, with 1 being the least compression and 9 being the most. The default value is 6.

  Returns:
  the compressed data
void[] uncompress(void[] srcbuf, size_t destlen = 0u, int winbits = 15);
  Decompresses the data in srcbuf[].
  Parameters:

  void[] srcbuf | buffer containing the compressed data.
  size_t destlen | size of the uncompressed data. It need not be accurate, but the decompression will be faster if the exact size is supplied.
  int winbits | the base two logarithm of the maximum window size.

  Returns:
  the decompressed data.
enum HeaderFormat: int;
  the header format the compressed stream is wrapped in
  deflate
    a standard zlib header
  gzip
    a gzip file format header
  determineFromData
    used when decompressing. Try to automatically detect the stream format by looking at the data
class Compress;
  Used when the data to be compressed is not all in one buffer.
  this(int level, HeaderFormat header = HeaderFormat.deflate);
  this(HeaderFormat header = HeaderFormat.deflate);
    Constructor.
    Parameters:

    int level | compression level. Legal values are 1..9, with 1 being the least compression and 9 being the most. The default value is 6.
    HeaderFormat header | sets the compression type to one of the options available in HeaderFormat. Defaults to HeaderFormat.deflate.

    See Also:
    compress, HeaderFormat
  const(void)[] compress(const(void)[] buf);
    Compress the data in buf and return the compressed data.
    Parameters:

    const(void)[] buf | data to compress

    Returns:
    the compressed data. The buffers returned from successive calls to this should be concatenated together.
  void[] flush(int mode = Z_FINISH);
    Compress and return any remaining data. The returned data should be appended to that returned by compress().
    Parameters:

    int mode | one of the following: Z_SYNC_FLUSH Syncs up flushing to the next byte boundary. Used when more data is to be compressed later on. Z_FULL_FLUSH Syncs up flushing to the next byte boundary. Used when more data is to be compressed later on, and the decompressor needs to be restartable at this point. Z_FINISH (default) Used when finished compressing the data.

class UnCompress;
  Used when the data to be decompressed is not all in one buffer.
  this(uint destbufsize);
  this(HeaderFormat format = HeaderFormat.determineFromData);
    Construct. destbufsize is the same as for D.zlib.uncompress().
  const(void)[] uncompress(const(void)[] buf);
    Decompress the data in buf and return the decompressed data. The buffers returned from successive calls to this should be concatenated together.
  void[] flush();
    Decompress and return any remaining data. The returned data should be appended to that returned by uncompress(). The UnCompress object cannot be used further.

Copyright Digital Mars 2000 - 2011. | Page generated by Ddoc on Sun Sep 6 21:47:16 2015