mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
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:
@@ -30,6 +30,7 @@
|
||||
#include "common/math.h"
|
||||
#include "common/Vector.h"
|
||||
#include "common/int.h"
|
||||
#include "common/StringMap.h"
|
||||
|
||||
// Noise
|
||||
#include "libraries/noise1234/noise1234.h"
|
||||
@@ -53,6 +54,13 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
enum EncodeFormat
|
||||
{
|
||||
ENCODE_BASE64,
|
||||
ENCODE_HEX,
|
||||
ENCODE_MAX_ENUM
|
||||
};
|
||||
|
||||
virtual ~Math();
|
||||
|
||||
RandomGenerator *getRandomGenerator()
|
||||
@@ -152,12 +160,21 @@ public:
|
||||
**/
|
||||
char *decompress(Compressor::Format format, const char *cbytes, size_t compressedsize, size_t &rawsize);
|
||||
|
||||
char *encode(EncodeFormat format, const char *src, size_t srclen, size_t &dstlen, size_t linelen = 0);
|
||||
char *decode(EncodeFormat format, const char *src, size_t srclen, size_t &dstlen);
|
||||
|
||||
static bool getConstant(const char *in, EncodeFormat &out);
|
||||
static bool getConstant(EncodeFormat in, const char *&out);
|
||||
|
||||
static Math instance;
|
||||
|
||||
private:
|
||||
|
||||
Math();
|
||||
|
||||
static StringMap<EncodeFormat, ENCODE_MAX_ENUM>::Entry encoderEntries[];
|
||||
static StringMap<EncodeFormat, ENCODE_MAX_ENUM> encoders;
|
||||
|
||||
}; // Math
|
||||
|
||||
inline float Math::noise(float x) const
|
||||
|
||||
Reference in New Issue
Block a user