GDAL

Classes | Typedefs | Enumerations | Functions
cpl_compressor.h File Reference
`#include "cpl_port.h"`
`#include <stdbool.h>`

Go to the source code of this file.

## Classes
struct | CPLCompressor
| Compressor/decompressor description. More...

## Typedefs
typedef bool(* | CPLCompressionFunc) (const void *input_data, size_t input_size, void **output_data, size_t *output_size, CSLConstList options, void *compressor_user_data)
| Callback of a compressor/decompressor. More...

## Enumerations
enum | CPLCompressorType { CCT_COMPRESSOR, CCT_FILTER }
| Type of compressor. More...

## Functions
bool | CPLRegisterCompressor (const CPLCompressor *compressor)
| Register a new compressor. More...
bool | CPLRegisterDecompressor (const CPLCompressor *decompressor)
| Register a new decompressor. More...
char ** | CPLGetCompressors (void)
| Return the list of registered compressors. More...
char ** | CPLGetDecompressors (void)
| Return the list of registered decompressors. More...
const CPLCompressor * | CPLGetCompressor (const char *pszId)
| Return a compressor. More...
const CPLCompressor * | CPLGetDecompressor (const char *pszId)
| Return a decompressor. More...

## Detailed Description

API for compressors and decompressors of binary buffers.

## Typedef Documentation

## ◆ CPLCompressionFunc

typedef bool(* CPLCompressionFunc) (const void *input_data, size_t input_size, void **output_data, size_t *output_size, CSLConstList options, void *compressor_user_data)

Callback of a compressor/decompressor.

For a compressor, input is uncompressed data, and output compressed data. For a decompressor, input is compressed data, and output uncompressed data.

Valid situations for output_data and output_size are:

- output_data != NULL and *output_data != NULL and output_size != NULL and *output_size != 0. The caller provides the output buffer in *output_data and its size in *output_size. In case of successful operation, *output_size will be updated to the actual size. This mode is the one that is always guaranteed to be implemented efficiently. In case of failure due to insufficient space, it will be updated to the size needed (if known), or 0 (if unknown)
- output_data == NULL and output_size != NULL. *output_size will be updated with the minimum size the output buffer should be (if known), or 0 (if unknown).
- output_data != NULL and *output_data == NULL and output_size != NULL. *output_data will be allocated using VSIMalloc(), and should be freed by the caller with VSIFree(). *output_size will be updated to the size of the output buffer.

Parameters

  input_data | Input data. Should not be NULL.
  input_size | Size of input data, in bytes.
  output_data | Pointer to output data.
  output_size | Pointer to output size.
  options | NULL terminated list of options. Or NULL.
  compressor_user_data | User data provided at registration time.

Returns
  true in case of success.

## Enumeration Type Documentation

## ◆ CPLCompressorType

enum CPLCompressorType

Type of compressor.

Enumerator
CCT_COMPRESSOR | Compressor.
CCT_FILTER | Filter.

## Function Documentation

## ◆ CPLGetCompressor()

const CPLCompressor* CPLGetCompressor | ( | const char * | pszId | ) |

Return a compressor.

Parameters

  pszId | Compressor id. Should NOT be NULL.

Returns
  compressor structure, or NULL.

Since
  GDAL 3.4

## ◆ CPLGetCompressors()

char** CPLGetCompressors | ( | void |  | ) |

Return the list of registered compressors.

Returns
  list of strings. Should be freed with CSLDestroy()

Since
  GDAL 3.4

## ◆ CPLGetDecompressor()

const CPLCompressor* CPLGetDecompressor | ( | const char * | pszId | ) |

Return a decompressor.

Parameters

  pszId | Decompressor id. Should NOT be NULL.

Returns
  compressor structure, or NULL.

Since
  GDAL 3.4

## ◆ CPLGetDecompressors()

char** CPLGetDecompressors | ( | void |  | ) |

Return the list of registered decompressors.

Returns
  list of strings. Should be freed with CSLDestroy()

Since
  GDAL 3.4

## ◆ CPLRegisterCompressor()

bool CPLRegisterCompressor | ( | const CPLCompressor * | compressor | ) |

Register a new compressor.

The provided structure is copied. Its pfnFunc and user_data members should remain valid beyond this call however.

Parameters

  compressor | Compressor structure. Should not be null.

Returns
  true if successful

Since
  GDAL 3.4

## ◆ CPLRegisterDecompressor()

bool CPLRegisterDecompressor | ( | const CPLCompressor * | decompressor | ) |

Register a new decompressor.

The provided structure is copied. Its pfnFunc and user_data members should remain valid beyond this call however.

Parameters

  decompressor | Compressor structure. Should not be null.

Returns
  true if successful

Since
  GDAL 3.4