73 [[deprecated(
"This method of serialization is not cross-platform. An alternative such as C++ Cereal should be used instead.")]]
173 [[deprecated(
"This function will corrupt console characters greater than 255.")]]
272 throw std::runtime_error{
"Failed to load file: " + path.string()};
405 void put(
char value) { TCOD_zip_put_char(data, value); }
413 void put(
int value) { TCOD_zip_put_int(data, value); }
421 void put(
float value) { TCOD_zip_put_float(data, value); }
429 void put(
const char* value) { TCOD_zip_put_string(data, value); }
437 void put(
const std::string& value) { TCOD_zip_put_string(data, value.c_str()); }
445 void put(
const std::optional<std::string>& value) {
446 if (value)
return put(value.value());
447 TCOD_zip_put_string(data,
nullptr);
473 TCODLIB_BEGIN_IGNORE_DEPRECATIONS
481 [[deprecated(
"This function will corrupt console characters greater than 255.")]]
void put(
const TCODConsole& value) {
482 TCOD_zip_put_console(data, value.
get_data());
491 [[deprecated(
"This function will corrupt console characters greater than 255.")]]
void put(
493 TCOD_zip_put_console(data, value.
get());
495 TCODLIB_END_IGNORE_DEPRECATIONS
515 template <
typename T>
529 void get(
char& out) { out = TCOD_zip_get_char(data); }
537 void get(
int& out) { out = TCOD_zip_get_int(data); }
545 void get(
float& out) { out = TCOD_zip_get_float(data); }
553 void get(std::optional<std::string>& out) {
555 const char*
string = TCOD_zip_get_string(data);
556 if (
string) out = string;
Classic turn by turn game loop:TCODConsole::initRoot(80,50,"my game",false); while (!...
Definition console.hpp:137
auto get_data() noexcept -> TCOD_Console *
Return a pointer to the underlying TCOD_Console struct.
Definition console.hpp:1772
TCOD_Image * get_data() noexcept
Return the pointer to this objects TCOD_Image data.
Definition image.hpp:535
Definition mersenne.hpp:94
TCOD_Random * get_data() noexcept
Return this objects TCOD_Random* pointer.
Definition mersenne.hpp:427
void get(TCODImage &out)
Extract an image to out.
Definition zip.hpp:597
void get(char &out)
Extract a char to out.
Definition zip.hpp:529
uint32_t getRemainingBytes() const
void get(int &out)
Extract an int to out.
Definition zip.hpp:537
void get(TCODConsole &out)
Extract a console to out.
Definition zip.hpp:621
void saveToFile(const std::filesystem::path &path)
Save this objects buffered objects to the file at path.
Definition zip.hpp:243
void putConsole(const TCODConsole *val)
void put(const tcod::ColorRGB &value)
Save a color to this zip.
Definition zip.hpp:456
int getData(int nbBytes, void *data)
Note that the getData length must match the length of the data when the file was created (with putDat...
int saveToFile(const char *filename)
Once you have finished adding data in the buffer, you can compress it and save it in a file.
TCODLIB_END_IGNORE_DEPRECATIONS void put(const TCODRandom &value)
Save an RNG state to this zip.
Definition zip.hpp:503
int loadFromFile(const char *filename)
You can read data from a file (compressed or not) into the buffer.
void get(tcod::ConsolePtr &out)
Extract a console pointer to out.
Definition zip.hpp:605
void put(const char *value)
Save a string to this zip.
Definition zip.hpp:429
void get(std::optional< std::string > &out)
Extract an optional string to out.
Definition zip.hpp:553
void get(tcod::Console &out)
Extract a console to out.
Definition zip.hpp:613
void putRandom(const TCODRandom *val)
void put(const std::optional< std::string > &value)
Save an optional string to this zip.
Definition zip.hpp:445
void put(float value)
Save a float to this zip.
Definition zip.hpp:421
void put(const std::string &value)
Save a string to this zip.
Definition zip.hpp:437
const char * getString()
The address returned is in the buffer.
void get(TCODColor &out)
Extract a color to out.
Definition zip.hpp:581
TCODZip()
This function initializes a compression buffer.
void putColor(const TCODColor *val)
uint32_t getCurrentBytes() const
void put(char value)
Save a char to this zip.
Definition zip.hpp:405
void put(const TCODColor &value)
Save a color to this zip.
Definition zip.hpp:464
T get()
Return a value of T from this zip object.
Definition zip.hpp:516
TCODConsole * getConsole()
void putData(int nbBytes, const void *data)
~TCODZip()
Once you don't need the buffer anymore, you can release resources.
void skipBytes(uint32_t nbBytes)
void get(tcod::ColorRGB &out)
Extract a color to out.
Definition zip.hpp:573
void put(int value)
Save an int to this zip.
Definition zip.hpp:413
void putImage(const TCODImage *val)
void put(const TCODImage &value)
Save an image to this zip.
Definition zip.hpp:472
void get(float &out)
Extract a float to out.
Definition zip.hpp:545
void put(const tcod::Console &value)
Save a console to this zip.
Definition zip.hpp:491
TCODLIB_BEGIN_IGNORE_DEPRECATIONS void put(const TCODConsole &value)
Save a console to this zip.
Definition zip.hpp:481
void get(tcod::ImagePtr &out)
Extract an image pointer to out.
Definition zip.hpp:589
void loadFromFile(const std::filesystem::path &path)
Load objects from the file at path.
Definition zip.hpp:270
void get(std::string &out)
Extract a string to out.
Definition zip.hpp:565
void get(TCODRandom &out)
Extract an RNG state to out.
Definition zip.hpp:629
void putString(const char *val)
A managed libtcod console containing a grid of tiles with {ch, fg, bg} information.
Definition console_types.hpp:80
auto get() noexcept -> TCOD_Console *
Return a pointer to the internal TCOD_Console struct.
Definition console_types.hpp:167
Random number generator C++ module.
std::unique_ptr< struct TCOD_Console, ConsoleDeleter > ConsolePtr
A unique pointer to a TCOD_Console.
Definition console_types.hpp:56
std::unique_ptr< TCOD_Image, ImageDeleter > ImagePtr
A unique pointer to a TCOD_Image.
Definition image.hpp:56
A C++ RGB color, used to handle conversions between color types.
Definition color.hpp:53
Deprecated serialization and compression module.
TCOD_Random * TCOD_zip_get_random(TCOD_zip_t zip)
Read a TCOD_Random* object.
void TCOD_zip_put_random(TCOD_zip_t zip, const TCOD_Random *val)
Write a TCOD_Random* object.