1
0
mirror of https://github.com/Amulet-Team/leveldb-mcpe.git synced 2024-11-24 01:46:16 +00:00
leveldb-amulet/include/leveldb/zlib_compressor.h
2017-08-05 23:46:55 +01:00

57 lines
1.2 KiB
C++

#pragma once
#include "leveldb/compressor.h"
namespace leveldb {
class DLLX ZlibCompressorBase : public Compressor
{
public:
int inflate(const char* input, size_t length, ::std::string &output) const;
const int compressionLevel;
const bool raw;
virtual ~ZlibCompressorBase() {
}
ZlibCompressorBase(char uniqueCompressionID, int compressionLevel, bool raw) :
Compressor(uniqueCompressionID),
compressionLevel(compressionLevel),
raw(raw)
{
assert(compressionLevel >= -1 && compressionLevel <= 9);
}
virtual void compressImpl(const char* input, size_t length, ::std::string& output) const override;
virtual bool decompress(const char* input, size_t length, ::std::string &output) const override;
private:
int _window() const;
};
class DLLX ZlibCompressor : public ZlibCompressorBase {
public:
static const int SERIALIZE_ID = 2;
ZlibCompressor(int compressionLevel = -1) :
ZlibCompressorBase(SERIALIZE_ID, compressionLevel, false) {
}
};
class DLLX ZlibCompressorRaw : public ZlibCompressorBase {
public:
static const int SERIALIZE_ID = 4;
ZlibCompressorRaw(int compressionLevel = -1) :
ZlibCompressorBase(SERIALIZE_ID, compressionLevel, true) {
}
};
}