LibTMJ 1.4.0
A library for loading JSON Tiled maps
Loading...
Searching...
No Matches
Functions
Decode

Encoding/decoding routines. More...

Functions

uint8_t * tmj_zstd_decompress (const uint8_t *data, size_t data_size, size_t *decompressed_size)
 Decompresses a zstd-compressed buffer of bytes.
 
uint8_t * tmj_zlib_decompress (const uint8_t *data, size_t data_size, size_t *decompressed_size)
 Decompresses a zlib/gzip-compressed buffer of bytes.
 
uint8_t * tmj_zlib_compress (const uint8_t *data, size_t data_size, int level, size_t *compressed_size)
 Compresses a buffer of bytes with zlib.
 
char * tmj_b64_encode (uint8_t *data, size_t size)
 Encodes a base64 string.
 
uint8_t * tmj_b64_decode (const char *data, size_t *decoded_size)
 Decodes a base64 string.
 

Detailed Description

Encoding/decoding routines.

Function Documentation

◆ tmj_zstd_decompress()

uint8_t * tmj_zstd_decompress ( const uint8_t *  data,
size_t  data_size,
size_t *  decompressed_size 
)

Decompresses a zstd-compressed buffer of bytes.

This routine does not use streaming decompression, so the given buffer must have a frame header that includes the content size. See https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#frame_header for detail.

Parameters
dataA zstd-compressed buffer of unsigned bytes. The zstd frame header for this buffer must include the content size.
data_sizeThe length of the buffer.
[out]decompressed_sizeThe length of the returned decompressed buffer.
Returns
On success, returns a dynamically-allocated (and decompressed) buffer of unsigned bytes. The returned buffer must be freed by the caller.

Definition at line 10 of file decode.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmj_zlib_decompress()

uint8_t * tmj_zlib_decompress ( const uint8_t *  data,
size_t  data_size,
size_t *  decompressed_size 
)

Decompresses a zlib/gzip-compressed buffer of bytes.

Parameters
dataA zlib/gzip-compressed buffer of unsigned bytes.
data_sizeThe length of the buffer.
[out]decompressed_sizeThe length of the returned decompressed buffer.
Returns
On success, returns a dynamically-allocated (and decompressed) buffer of unsigned bytes. The returned buffer must be freed by the caller.

Definition at line 62 of file decode.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmj_zlib_compress()

uint8_t * tmj_zlib_compress ( const uint8_t *  data,
size_t  data_size,
int  level,
size_t *  compressed_size 
)

Compresses a buffer of bytes with zlib.

Parameters
dataA buffer of unsigned bytes.
data_sizeThe length of the buffer.
levelThe desired level of zlib compression (0-9).
[out]compressed_sizeThe length of the returned compressed buffer.
Returns
On success, returns a dynamically-allocated, zlib-compressed buffer of unsigned bytes. The returned buffer must be freed by the caller.

Definition at line 210 of file decode.c.

Here is the call graph for this function:

◆ tmj_b64_encode()

char * tmj_b64_encode ( uint8_t *  data,
size_t  size 
)

Encodes a base64 string.

Parameters
dataAn array of unsigned bytes.
sizeThe length of the array.
Returns
On success, returns a dynamically-allocated null-terminated base64 string. The returned array must be freed by the caller.

Definition at line 479 of file decode.c.

Here is the call graph for this function:

◆ tmj_b64_decode()

uint8_t * tmj_b64_decode ( const char *  data,
size_t *  decoded_size 
)

Decodes a base64 string.

Parameters
dataA null-terminated base64 string.
[out]decoded_sizeThe length of the returned decoded buffer.
Returns
On success, returns a dynamically-allocated array of unsigned bytes. The returned array must be freed by the caller.

Definition at line 410 of file decode.c.

Here is the call graph for this function:
Here is the caller graph for this function: