# kyotocabinet::Zlib Class Reference

Zlib compressor. More...

`#include <kccompress.h>`

List of all members.

## Public Types

enum | Mode { RAW, DEFLATE, GZIP }
| Compression modes. More...

## Static Public Member Functions

static char * | compress (Mode mode, const void *buf, size_t size, size_t *sp)
| Compress a serial data.
static char * | decompress (Mode mode, const void *buf, size_t size, size_t *sp)
| Decompress a serial data.

## Detailed Description

Zlib compressor.

## Member Enumeration Documentation

enum kyotocabinet::Zlib::Mode

Compression modes.

Enumerator:

  RAW | without any checksum
  DEFLATE | with Adler32 checksum
  GZIP | with CRC32 checksum and various meta data

## Member Function Documentation

static char* kyotocabinet::Zlib::compress | ( | Mode | mode,
|  | const void * | buf,
|  | size_t | size,
|  | size_t * | sp |
| ) |  |  | `[static]`

Compress a serial data.

Parameters:

  | mode | the compression mode.
  | buf | the input buffer.
  | size | the size of the input buffer.
  | sp | the pointer to the variable into which the size of the region of the return value is assigned.

Returns:
  the pointer to the result data, or NULL on failure.

Note:
  Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.

static char* kyotocabinet::Zlib::decompress | ( | Mode | mode,
|  | const void * | buf,
|  | size_t | size,
|  | size_t * | sp |
| ) |  |  | `[static]`

Decompress a serial data.

Parameters:

  | mode | the compression mode.
  | buf | the input buffer.
  | size | the size of the input buffer.
  | sp | the pointer to the variable into which the size of the region of the return value is assigned.

Returns:
  the pointer to the result data, or NULL on failure.

Note:
  Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a C-style string. Because the region of the return value is allocated with the the new[] operator, it should be released with the delete[] operator when it is no longer in use.