libtcoddocumentation

11.1. Creating a compression buffer

This function initializes a compression buffer.

TCODZip::TCODZip()

TCOD_zip_t TCOD_zip_new()

Once you don't need the buffer anymore, you can release resources. Note that the adresses returned by the getString function are no longer valid once the buffer has been destroyed.

TCODZip::~TCODZip()

void TCOD_zip_delete(TCOD_zip_t zip)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
Example:

TCODZip *zip = new TCODZip();
zip->loadFromFile("myCompressedFile.gz");
char
c=zip->getChar();
int
i=zip->getInt();
float
f= zip->getFloat();
const
char *s=strdup(zip->getString()); // we duplicate the string to be able to use it after the buffer deletion
zip->getData(nbBytes, dataPtr);
delete
zip;

TCOD_zip_t zip=TCOD_zip_new();
TCOD_zip_load_from_file(zip,"myCompressedFile.gz");
char
c=TCOD_zip_get_char(zip);
int
i=TCOD_zip_get_int(zip);
float
f=TCOD_zip_get_float(zip);
const
char *s=strdup(TCOD_zip_get_string(zip));
TCOD_zip_get_data(zip,nbBytes, dataPtr);
TCOD_zip_delete(zip);