Compression.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #ifdef URHO3D_IS_BUILDING
  5. #include "Urho3D.h"
  6. #else
  7. #include <Urho3D/Urho3D.h>
  8. #endif
  9. namespace Urho3D
  10. {
  11. class Deserializer;
  12. class Serializer;
  13. class VectorBuffer;
  14. /// Estimate and return worst case LZ4 compressed output size in bytes for given input size.
  15. URHO3D_API unsigned EstimateCompressBound(unsigned srcSize);
  16. /// Compress data using the LZ4 algorithm and return the compressed data size. The needed destination buffer worst-case size is given by EstimateCompressBound().
  17. URHO3D_API unsigned CompressData(void* dest, const void* src, unsigned srcSize);
  18. /// Uncompress data using the LZ4 algorithm. The uncompressed data size must be known. Return the number of compressed data bytes consumed.
  19. URHO3D_API unsigned DecompressData(void* dest, const void* src, unsigned destSize);
  20. /// Compress a source stream (from current position to the end) to the destination stream using the LZ4 algorithm. Return true on success.
  21. URHO3D_API bool CompressStream(Serializer& dest, Deserializer& src);
  22. /// Decompress a compressed source stream produced using CompressStream() to the destination stream. Return true on success.
  23. URHO3D_API bool DecompressStream(Serializer& dest, Deserializer& src);
  24. /// Compress a VectorBuffer using the LZ4 algorithm and return the compressed result buffer.
  25. URHO3D_API VectorBuffer CompressVectorBuffer(VectorBuffer& src);
  26. /// Decompress a VectorBuffer produced using CompressVectorBuffer().
  27. URHO3D_API VectorBuffer DecompressVectorBuffer(VectorBuffer& src);
  28. }