blob: 5bc0e56913fe2689975301e321227f5591cf50e7 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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/Support/DataTypes.h"
17
18namespace llvm {
19template <typename T> class SmallVectorImpl;
20class Error;
21class StringRef;
22
23namespace zlib {
24
Andrew Scullcdfcccc2018-10-05 20:58:37 +010025static constexpr int NoCompression = 0;
26static constexpr int BestSpeedCompression = 1;
27static constexpr int DefaultCompression = 6;
28static constexpr int BestSizeCompression = 9;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010029
30bool isAvailable();
31
32Error compress(StringRef InputBuffer, SmallVectorImpl<char> &CompressedBuffer,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010033 int Level = DefaultCompression);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010034
35Error uncompress(StringRef InputBuffer, char *UncompressedBuffer,
36 size_t &UncompressedSize);
37
38Error uncompress(StringRef InputBuffer,
39 SmallVectorImpl<char> &UncompressedBuffer,
40 size_t UncompressedSize);
41
42uint32_t crc32(StringRef Buffer);
43
44} // End of namespace zlib
45
46} // End of namespace llvm
47
48#endif