< index < 11. Compression toolkit < 11.4 Loading compressed data from a file | ===================================== 11.5 Getting data from the buffer ===================================== | > 11.6 Destroying a compression buffer

Once data has been loaded into the buffer, you can get it with one of those functions.

    C++ : char TCODZip::getChar()
    C   : char TCOD_zip_get_char(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

    C++ : int TCODZip::getInt()
    C   : int TCOD_zip_get_int(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

    C++ : float TCODZip::getFloat()
    C   : float TCOD_zip_get_float(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

    C++ : const char *TCODZip::getString()
    C   : const char *TCOD_zip_get_string(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

The address returned is in the buffer. It is valid as long as you don't destroy the buffer.

    C++ : TCODColor TCODZip::getColor()
    C   : TCOD_color_t TCOD_zip_get_color(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

    C++ : TCODImage *TCODZip::getImage()
    C   : TCOD_image_t TCOD_zip_get_image(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

    C++ : TCODConsole *TCODZip::getConsole()
    C   : TCOD_console_t TCOD_zip_get_console(TCOD_zip_t zip)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.

    C++ : int TCODZip::getData(int nbBytes, void *data)
    C   : int TCOD_zip_get_data(TCOD_zip_t zip, int nbBytes, void *data)

Parameter | Description
--- | ---
zip | In the C version, the buffer handler, returned by the constructor.
nbBytes | Number of bytes to read
data | Address of a pre-allocated buffer (at least nbBytes bytes)

Note that the getData length must match the length of the data when the file was created (with putData).
The function returns the number of bytes that were stored in the file by the putData call. If more than nbBytes were stored, the function read only nbBytes and skip the rest of them.

Example :

    C++ : TCODZip zip;
          zip.loadFromFile("myCompressedFile.gz");
          char c=zip.getChar();
          int i=zip.getInt();
          float f= zip.getFloat();
          const char *s=zip.getString();
          zip.getData(nbBytes, dataPtr);
    C   : 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=TCOD_zip_get_string(zip);
          TCOD_zip_get_data(zip,nbBytes, dataPtr);