2020-08-01 22:01:39 +02:00
|
|
|
/*
|
2021-04-28 22:46:44 +02:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2020-08-01 22:01:39 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 22:01:39 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-08-26 14:22:25 +02:00
|
|
|
#include <AK/ByteBuffer.h>
|
2020-08-01 22:01:39 +02:00
|
|
|
#include <AK/Span.h>
|
|
|
|
|
#include <AK/Types.h>
|
|
|
|
|
|
|
|
|
|
namespace Compress {
|
2020-08-26 14:22:25 +02:00
|
|
|
|
2020-08-01 22:01:39 +02:00
|
|
|
class Zlib {
|
|
|
|
|
public:
|
2020-09-08 16:49:05 +02:00
|
|
|
Optional<ByteBuffer> decompress();
|
2020-08-01 22:01:39 +02:00
|
|
|
u32 checksum();
|
|
|
|
|
|
2021-03-15 17:03:42 +02:00
|
|
|
static Optional<Zlib> try_create(ReadonlyBytes data);
|
2020-09-08 16:49:05 +02:00
|
|
|
static Optional<ByteBuffer> decompress_all(ReadonlyBytes);
|
2020-08-26 14:22:25 +02:00
|
|
|
|
2020-08-01 22:01:39 +02:00
|
|
|
private:
|
2021-03-15 17:03:42 +02:00
|
|
|
Zlib(const ReadonlyBytes& data);
|
|
|
|
|
|
2020-08-01 22:01:39 +02:00
|
|
|
u8 m_compression_method;
|
|
|
|
|
u8 m_compression_info;
|
|
|
|
|
u8 m_check_bits;
|
|
|
|
|
u8 m_has_dictionary;
|
|
|
|
|
u8 m_compression_level;
|
|
|
|
|
|
2021-03-15 17:03:42 +02:00
|
|
|
u32 m_checksum { 0 };
|
2020-08-01 22:01:39 +02:00
|
|
|
ReadonlyBytes m_input_data;
|
|
|
|
|
ReadonlyBytes m_data_bytes;
|
|
|
|
|
};
|
2020-08-18 20:49:59 +02:00
|
|
|
|
2020-08-01 22:01:39 +02:00
|
|
|
}
|