Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 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 | |
| 14 | #ifndef LLVM_SUPPORT_COMPRESSION_H |
| 15 | #define LLVM_SUPPORT_COMPRESSION_H |
| 16 | |
| 17 | #include "llvm/Support/DataTypes.h" |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame^] | 18 | #include <memory> |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | class MemoryBuffer; |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 23 | class StringRef; |
| 24 | |
| 25 | namespace zlib { |
| 26 | |
| 27 | enum CompressionLevel { |
| 28 | NoCompression, |
| 29 | DefaultCompression, |
| 30 | BestSpeedCompression, |
| 31 | BestSizeCompression |
| 32 | }; |
| 33 | |
| 34 | enum Status { |
| 35 | StatusOK, |
Alp Toker | cb40291 | 2014-01-24 17:20:08 +0000 | [diff] [blame] | 36 | StatusUnsupported, // zlib is unavailable |
| 37 | StatusOutOfMemory, // there was not enough memory |
| 38 | StatusBufferTooShort, // there was not enough room in the output buffer |
| 39 | StatusInvalidArg, // invalid input parameter |
| 40 | StatusInvalidData // data was corrupted or incomplete |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | bool isAvailable(); |
| 44 | |
| 45 | Status compress(StringRef InputBuffer, |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame^] | 46 | std::unique_ptr<MemoryBuffer> &CompressedBuffer, |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 47 | CompressionLevel Level = DefaultCompression); |
| 48 | |
| 49 | Status uncompress(StringRef InputBuffer, |
Ahmed Charles | 56440fd | 2014-03-06 05:51:42 +0000 | [diff] [blame^] | 50 | std::unique_ptr<MemoryBuffer> &UncompressedBuffer, |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 51 | size_t UncompressedSize); |
| 52 | |
Alexey Samsonov | 6ede706 | 2013-08-14 16:03:29 +0000 | [diff] [blame] | 53 | uint32_t crc32(StringRef Buffer); |
| 54 | |
Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 55 | } // End of namespace zlib |
| 56 | |
| 57 | } // End of namespace llvm |
| 58 | |
| 59 | #endif |
| 60 | |