1 //===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file contains basic functions for compression/uncompression. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_SUPPORT_COMPRESSION_H 14 #define LLVM_SUPPORT_COMPRESSION_H 15 16 #include "llvm/ADT/ArrayRef.h" 17 #include "llvm/Support/DataTypes.h" 18 19 namespace llvm { 20 template <typename T> class SmallVectorImpl; 21 class Error; 22 23 namespace compression { 24 namespace zlib { 25 26 constexpr int NoCompression = 0; 27 constexpr int BestSpeedCompression = 1; 28 constexpr int DefaultCompression = 6; 29 constexpr int BestSizeCompression = 9; 30 31 bool isAvailable(); 32 33 void compress(ArrayRef<uint8_t> Input, 34 SmallVectorImpl<uint8_t> &CompressedBuffer, 35 int Level = DefaultCompression); 36 37 Error uncompress(ArrayRef<uint8_t> Input, uint8_t *UncompressedBuffer, 38 size_t &UncompressedSize); 39 40 Error uncompress(ArrayRef<uint8_t> Input, 41 SmallVectorImpl<uint8_t> &UncompressedBuffer, 42 size_t UncompressedSize); 43 44 } // End of namespace zlib 45 46 namespace zstd { 47 48 constexpr int NoCompression = -5; 49 constexpr int BestSpeedCompression = 1; 50 constexpr int DefaultCompression = 5; 51 constexpr int BestSizeCompression = 12; 52 53 bool isAvailable(); 54 55 void compress(ArrayRef<uint8_t> Input, 56 SmallVectorImpl<uint8_t> &CompressedBuffer, 57 int Level = DefaultCompression); 58 59 Error uncompress(ArrayRef<uint8_t> Input, uint8_t *UncompressedBuffer, 60 size_t &UncompressedSize); 61 62 Error uncompress(ArrayRef<uint8_t> Input, 63 SmallVectorImpl<uint8_t> &UncompressedBuffer, 64 size_t UncompressedSize); 65 66 } // End of namespace zstd 67 68 } // End of namespace compression 69 70 } // End of namespace llvm 71 72 #endif 73