libtcoddocumentation

11.2. Using the buffer in output mode

Putting a char in the buffer

void TCODZip::putChar(char val)

void TCOD_zip_put_char(TCOD_zip_t zip, char val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valA 8 bits value to store in the buffer

Putting an integer in the buffer

void TCODZip::putInt(int val)

void TCOD_zip_put_int(TCOD_zip_t zip, int val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valAn integer value to store in the buffer

Putting a floating point value in the buffer

void TCODZip::putFloat(float val)

void TCOD_zip_put_float(TCOD_zip_t zip, float val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valA float value to store in the buffer

Putting a string in the buffer

void TCODZip::putString(const char *val)

void TCOD_zip_put_string(TCOD_zip_t zip, const char *val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valA string to store in the buffer

Putting a color in the buffer

void TCODZip::putColor(const TCODColor *val)

void TCOD_zip_put_color(TCOD_zip_t zip, const TCOD_color_t val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valA color to store in the buffer

Putting an image in the buffer

void TCODZip::putImage(const TCODImage *val)

void TCOD_zip_put_image(TCOD_zip_t zip, const TCOD_image_t val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valAn image to store in the buffer

Putting a console in the buffer

void TCODZip::putConsole(const TCODConsole *val)

void TCOD_zip_put_console(TCOD_zip_t zip, const TCOD_console_t val)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
valA console to store in the buffer

Putting some custom data in the buffer

void TCODZip::putData(int nbBytes, const void *data)

void TCOD_zip_put_data(TCOD_zip_t zip, int nbBytes, const void *data)

ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
nbBytesNumber of bytes to store in the buffer
valAddress of the data to store in the buffer

Reading the number of (uncompressed) bytes in the buffer

uint32 TCODZip::getCurrentBytes()

uint32 TCOD_zip_get_current_bytes(TCOD_zip_t zip)

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

Saving the buffer on disk

Once you have finished adding data in the buffer, you can compress it and save it in a file.
The function returns the number of (uncompressed) bytes saved.

int TCODZip::saveToFile(const char *filename)

int TCOD_zip_save_to_file(TCOD_zip_t zip, const char *filename)

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

TCODZip zip;
zip.putChar('A');
zip.putInt(1764);
zip.putFloat(3.14f);
zip.putString("A string");
zip.putData(nbBytes, dataPtr);
zip.saveToFile("myCompressedFile.gz");

TCOD_zip_t zip=TCOD_zip_new();
TCOD_zip_put_char(zip,'A');
TCOD_zip_put_int(zip,1764);
TCOD_zip_put_float(zip,3.14f);
TCOD_zip_put_string(zip,"A string");
TCOD_zip_put_data(zip,nbBytes, dataPtr);
TCOD_zip_save_to_file(zip,"myCompressedFile.gz");