Constructor
Compresses src data. dst must have a length of at least maxCompressedLength(src.length).
Uncompresses src data, checking for dst not to overflow.
Uncompresses src data. dst must have at least the length of the uncompressed data, which must be memorized at compression time.
Checks if status indicates an error.
Calculates the maximum compressed length of data which has a length of uncompressed_length.
Simple compress / decompress example.
// LZO instance. (Usually a single one can be shared globally.) auto lzo = new Lzo; // Typical function to decompress a buffer that was received over the // network. (i.e. where the buffer and the expected length of the // decompressed data are both received from an external source.) void decompress ( in void[] src, size_t expected_decompressed_length, ref void[] dst ) { dst.length = expected_decompressed_length; assumeSafeAppend(dst); auto decompressed_length = lzo.decompressSafe(src, dst); // Check that the length of the uncompressed data is what we expected. // (It is important to verify this, when the data was received // externally.) enforce(decompressed_length == expected_decompressed_length); } auto original = "compress this!"; // Compress. auto compressed = new void[lzo.maxCompressedLength(original.length)]; compressed.length = lzo.compress(original, compressed); // Decompress. void[] decompressed; decompress(compressed, original.length, decompressed); // We should have the original string back now. test!("==")(decompressed, original);
Lzo class