Added love.math.encode(format, data | string [, linelength]) and love.math.decode(format, data | string). Current formats are "base64" and "hex". The optional line length only applies to base64 and specifies the maximum number of characters per line in the encoded string.

Removed the variant of love.filesystem.newFileData which decoded a base64-encoded string since it's redundant.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-03-28 19:28:40 -03:00
parent 9efbe4892c
commit 734789eb93
15 changed files with 394 additions and 141 deletions
+17 -3
View File
@@ -20,21 +20,35 @@
#include "config.h"
#include <stddef.h>
#ifndef LOVE_B64_H
#define LOVE_B64_H
namespace love
{
/**
* Base64-encode data.
*
* @param src The data to encode.
* @param srclen The size in bytes of the data.
* @param linelen The maximum length of each line in the encoded string.
* 0 indicates no maximum length.
* @param dstlen The length of the encoded string is stored here.
* @return A string containing the base64-encoded data (allocated with new[]).
*/
char *b64_encode(const char *src, size_t srclen, size_t linelen, size_t &dstlen);
/**
* Decode base64 encoded data.
*
* @param src The string containing the base64 data.
* @param slen The length of the string.
* @param size The size of the binary data is stored here.
* @param srclen The length of the string.
* @param dstlen The size of the binary data is stored here.
* @return A chunk of memory containing the binary data (allocated with new[]).
*/
char *b64_decode(const char *src, int slen, int &size);
char *b64_decode(const char *src, size_t srclen, size_t &dstlen);
} // love