Compression.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains basic functions for compression/uncompression.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_SUPPORT_COMPRESSION_H
  14. #define LLVM_SUPPORT_COMPRESSION_H
  15. #include "llvm/Support/DataTypes.h"
  16. namespace llvm {
  17. template <typename T> class SmallVectorImpl;
  18. class StringRef;
  19. namespace zlib {
  20. enum CompressionLevel {
  21. NoCompression,
  22. DefaultCompression,
  23. BestSpeedCompression,
  24. BestSizeCompression
  25. };
  26. enum Status {
  27. StatusOK,
  28. StatusUnsupported, // zlib is unavailable
  29. StatusOutOfMemory, // there was not enough memory
  30. StatusBufferTooShort, // there was not enough room in the output buffer
  31. StatusInvalidArg, // invalid input parameter
  32. StatusInvalidData // data was corrupted or incomplete
  33. };
  34. bool isAvailable();
  35. Status compress(StringRef InputBuffer, SmallVectorImpl<char> &CompressedBuffer,
  36. CompressionLevel Level = DefaultCompression);
  37. Status uncompress(StringRef InputBuffer,
  38. SmallVectorImpl<char> &UncompressedBuffer,
  39. size_t UncompressedSize);
  40. uint32_t crc32(StringRef Buffer);
  41. } // End of namespace zlib
  42. } // End of namespace llvm
  43. #endif