blob: 80eff5c6285af0ffccf3b245507a8698f0ab796a [file] [log] [blame]
Alexey Samsonov2fb337e2013-04-23 08:28:39 +00001//===-- 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 Charles56440fd2014-03-06 05:51:42 +000018#include <memory>
Alexey Samsonov2fb337e2013-04-23 08:28:39 +000019
20namespace llvm {
21
22class MemoryBuffer;
Alexey Samsonov2fb337e2013-04-23 08:28:39 +000023class StringRef;
24
25namespace zlib {
26
27enum CompressionLevel {
28 NoCompression,
29 DefaultCompression,
30 BestSpeedCompression,
31 BestSizeCompression
32};
33
34enum Status {
35 StatusOK,
Alp Tokercb402912014-01-24 17:20:08 +000036 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 Samsonov2fb337e2013-04-23 08:28:39 +000041};
42
43bool isAvailable();
44
45Status compress(StringRef InputBuffer,
Ahmed Charles56440fd2014-03-06 05:51:42 +000046 std::unique_ptr<MemoryBuffer> &CompressedBuffer,
Alexey Samsonov2fb337e2013-04-23 08:28:39 +000047 CompressionLevel Level = DefaultCompression);
48
49Status uncompress(StringRef InputBuffer,
Ahmed Charles56440fd2014-03-06 05:51:42 +000050 std::unique_ptr<MemoryBuffer> &UncompressedBuffer,
Alexey Samsonov2fb337e2013-04-23 08:28:39 +000051 size_t UncompressedSize);
52
Alexey Samsonov6ede7062013-08-14 16:03:29 +000053uint32_t crc32(StringRef Buffer);
54
Alexey Samsonov2fb337e2013-04-23 08:28:39 +000055} // End of namespace zlib
56
57} // End of namespace llvm
58
59#endif
60