|
AndroMeta
2.0.0
|
Encoding/decoding to and from binary format, compresssion/decompression, and save/open utility functions. More...
#include <MEncoder.h>
Static Public Member Functions | |
| static bool | open (const mstr &path, mvar &out, bool config=false) |
| static bool | save (const mstr &path, const mvar &in, bool config=false, const mstr &tempPath="") |
| static char * | pack (const mvar &in, size_t &length) |
| static char * | pack (const mvar &in, char *buffer, size_t &size, size_t &pos, bool resize=false) |
| static void | unpack (mvar &out, char *buffer) |
| static void | unpack (mvar &out, char *buffer, size_t &pos) |
| static void | compress (char *in, size_t inSize, char *out, size_t &outSize) |
| static char * | compress (char *in, size_t inSize, size_t &outSize) |
| static char * | decompress (char *in, size_t inSize, char *out, size_t &outSize, bool resize) |
| static char * | decompress (char *in, size_t inSize, size_t &outSize) |
| static void | encode (const mvar &in, mvar &out) |
| static void | decode (const mvar &in, mvar &out) |
| static mstr | checksum (const char *buffer) |
| static mstr | generateKey (const mstr &user, const mstr &password) |
Encoding/decoding to and from binary format, compresssion/decompression, and save/open utility functions.
Also include methods for reading config files, and computing checksums.
| static mstr Meta::MEncoder::checksum | ( | const char * | buffer | ) | [static] |
Compute an MD5 checksum using the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
| buffer | Input buffer. |
| static void Meta::MEncoder::compress | ( | char * | in, |
| size_t | inSize, | ||
| char * | out, | ||
| size_t & | outSize | ||
| ) | [static] |
Compress binary data from an input buffer into an existing output buffer.
| in | The input buffer. |
| inSize | The size of the binary segment to be compressed within the input buffer. |
| out | The output buffer. |
| outSize | On input, the total length of the output buffer, on output the length of buffer that the compressed data segment occupies. |
| static char* Meta::MEncoder::compress | ( | char * | in, |
| size_t | inSize, | ||
| size_t & | outSize | ||
| ) | [static] |
Compress binary data into a newly allocated buffer.
| in | The input buffer. |
| inSize | The size of the binary segment to be compressed within the input buffer. |
| outSize. | On output, the length of the compressed data. |
| static void Meta::MEncoder::decode | ( | const mvar & | in, |
| mvar & | out | ||
| ) | [static] |
Decompress and decode an input mvar into an output mvar.
| in | The input mvar in compressed binary format. |
| out | The decoded output mvar. |
| static char* Meta::MEncoder::decompress | ( | char * | in, |
| size_t | inSize, | ||
| char * | out, | ||
| size_t & | outSize, | ||
| bool | resize | ||
| ) | [static] |
Decompress an input buffer into an existing output buffer.
| in | The input buffer. |
| inSize | The length of the compressed data within the input buffer. |
| out | The output buffer to decompress into, allocated with malloc(). |
| outSize. | On input, the total length of the output buffer. On output, the length of the decompressed data within the output buffer. |
| resize | true if out buffer should be resized as needed. |
| static char* Meta::MEncoder::decompress | ( | char * | in, |
| size_t | inSize, | ||
| size_t & | outSize | ||
| ) | [static] |
Decompress an input buffer into a newly allocated buffer.
| in | The input buffer. |
| inSize | The length of the compressed data within the input buffer. |
| outSize. | On input, the total length of the output buffer. On output, the length of the decompressed data within the output buffer. |
| static void Meta::MEncoder::encode | ( | const mvar & | in, |
| mvar & | out | ||
| ) | [static] |
Pack and compress an input mvar into a binary output mvar.
| in | The input mvar. |
| out | The output mvar to encode and compress into. |
| static mstr Meta::MEncoder::generateKey | ( | const mstr & | user, |
| const mstr & | password | ||
| ) | [static] |
Generate a key for user with the specified password. A given user and password always generates the same key.
| static bool Meta::MEncoder::open | ( | const mstr & | path, |
| mvar & | out, | ||
| bool | config = false |
||
| ) | [static] |
Open an mvar which has been saved to a file in compressed binary format (or plaintext in the case of a config file).
| path | The path of the file to open. |
| out | Stores the opened mvar in out. |
| config | true if this is a config file (which is not in binary format). Config files entail extra handling such as reading environment variables embedded in strings. |
| static char* Meta::MEncoder::pack | ( | const mvar & | in, |
| size_t & | length | ||
| ) | [static] |
Pack an mvar into a newly allocated buffer.
| in | The input mvar to pack. |
| length | The output length of the buffer. |
| static char* Meta::MEncoder::pack | ( | const mvar & | in, |
| char * | buffer, | ||
| size_t & | size, | ||
| size_t & | pos, | ||
| bool | resize = false |
||
| ) | [static] |
Pack an mvar into an existing buffer, optionally resizing the buffer as needed. If buffer is not large enough to accomodate the packed mvar and resize is false, an MError is thrown.
| in | The input mvar to pack. |
| buffer | An existing buffer allocated with malloc(). |
| size | On input the size of the existing buffer. On output, the size of the buffer after any resizing. |
| pos | On input, the pack start position within the buffer. On output, the ending position. |
| resize | true if buffer may be resized as needed. |
| static bool Meta::MEncoder::save | ( | const mstr & | path, |
| const mvar & | in, | ||
| bool | config = false, |
||
| const mstr & | tempPath = "" |
||
| ) | [static] |
Save an mvar as compressed binary format to a file (or write as plaintext in the case of a config file). The file is atomically saved to the specified path.
| path | The path to the filename to create. |
| in | The input mvar to save. |
| config | true if this is config file and is to be saved as plaintext (in MML code). |
| tempPath | The path in which to store temporary files in order to save the file atomically. Uses the mTempPath arg if tempPath is empty. |
| static void Meta::MEncoder::unpack | ( | mvar & | out, |
| char * | buffer | ||
| ) | [static] |
Unpack an encoded mvar in buffer into output mvar.
| out | The output mvar to unpack into. |
| buffer | The input buffer which holds the packed mvar. |
| static void Meta::MEncoder::unpack | ( | mvar & | out, |
| char * | buffer, | ||
| size_t & | pos | ||
| ) | [static] |
Unpack an encoded mvar in buffer into an output mvar.
| out | The output mvar to unpack into. |
| buffer | The input buffer which holds the packed mvar. |
| pos | On input the start position within the buffer. On output, the position at which the packed mvar ends. |
1.7.6.1