Several love.data functions now take an enum ("data" or "string") to determine whether they return a Data object or a string.

Changed functions are love.data.compress, decompress, encode, decode, and pack.
This commit is contained in:
Alex Szpakowski
2017-12-22 16:13:20 -04:00
parent 9bae1f01ba
commit 9fa73f8b87
9 changed files with 455 additions and 386 deletions
+14 -2
View File
@@ -42,17 +42,24 @@ enum EncodeFormat
ENCODE_MAX_ENUM
};
enum ContainerType
{
CONTAINER_DATA,
CONTAINER_STRING,
CONTAINER_MAX_ENUM
};
/**
* Compresses a block of memory using the given compression format.
*
* @param format The compression format to use.
* @param rawdata The data to compress.
* @param rawbytes The data to compress.
* @param rawsize The size in bytes of the data to compress.
* @param level The amount of compression to apply (between 0 and 9.)
* A value of -1 indicates the default amount of compression.
* Specific formats may not use every level.
* @return The newly compressed data.
**/
CompressedData *compress(Compressor::Format format, Data *rawdata, int level = -1);
CompressedData *compress(Compressor::Format format, const char *rawbytes, size_t rawsize, int level = -1);
/**
@@ -98,6 +105,10 @@ bool getConstant(const char *in, EncodeFormat &out);
bool getConstant(EncodeFormat in, const char *&out);
std::vector<std::string> getConstants(EncodeFormat);
bool getConstant(const char *in, ContainerType &out);
bool getConstant(ContainerType in, const char *&out);
std::vector<std::string> getConstants(ContainerType);
class DataModule : public Module
{
@@ -112,6 +123,7 @@ public:
DataView *newDataView(Data *data, size_t offset, size_t size);
ByteData *newByteData(size_t size);
ByteData *newByteData(const void *d, size_t size);
ByteData *newByteData(void *d, size_t size, bool own);
static DataModule instance;