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
+3 -15
View File
@@ -22,10 +22,11 @@
#define LOVE_FILESYSTEM_FILE_DATA_H
// LOVE
#include <string>
#include "common/Data.h"
#include "common/StringMap.h"
#include "common/int.h"
#include "common/Exception.h"
#include <string>
namespace love
{
@@ -36,13 +37,6 @@ class FileData : public Data
{
public:
enum Decoder
{
FILE,
BASE64,
DECODE_MAX_ENUM
}; // Decoder
FileData(uint64 size, const std::string &filename);
virtual ~FileData();
@@ -54,9 +48,6 @@ public:
const std::string &getFilename() const;
const std::string &getExtension() const;
static bool getConstant(const char *in, Decoder &out);
static bool getConstant(Decoder in, const char *&out);
private:
// The actual data.
@@ -71,9 +62,6 @@ private:
// The extension (without dot). Used to identify file type.
std::string extension;
static StringMap<Decoder, DECODE_MAX_ENUM>::Entry decoderEntries[];
static StringMap<Decoder, DECODE_MAX_ENUM> decoders;
}; // FileData
} // filesystem