summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCompress/Zlib.h
blob: 148ecca809cee66fb0fc2018803283f1be12804a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/ByteBuffer.h>
#include <AK/Optional.h>
#include <AK/Span.h>
#include <AK/Types.h>

namespace Compress {

class Zlib {
public:
    Optional<ByteBuffer> decompress();
    u32 checksum();

    static Optional<Zlib> try_create(ReadonlyBytes data);
    static Optional<ByteBuffer> decompress_all(ReadonlyBytes);

private:
    Zlib(const ReadonlyBytes& data);

    u8 m_compression_method;
    u8 m_compression_info;
    u8 m_check_bits;
    u8 m_has_dictionary;
    u8 m_compression_level;

    u32 m_checksum { 0 };
    ReadonlyBytes m_input_data;
    ReadonlyBytes m_data_bytes;
};

}