aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/streams/brotli/brotli.h
blob: b3af869e29cd799de7b21823e33e0cbc52611558 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once

#include <util/generic/ptr.h>
#include <util/stream/input.h>
#include <util/stream/output.h>

/**
 * @addtogroup Streams_Archs
 * @{
 */

class TBrotliCompress: public IOutputStream {
public:
    static constexpr int BEST_QUALITY = 11;

    /**
      @param slave stream to write compressed data to
      @param quality the higher the quality, the slower and better the compression. Range is 0 to 11.
    */
    explicit TBrotliCompress(IOutputStream* slave, int quality = BEST_QUALITY);
    ~TBrotliCompress() override;

private:
    void DoWrite(const void* buffer, size_t size) override;
    void DoFlush() override;
    void DoFinish() override;

public:
    class TImpl;
    THolder<TImpl> Impl_;
};

////////////////////////////////////////////////////////////////////////////////

class TBrotliDecompress: public IInputStream {
public:
    /**
      @param slave stream to read compressed data from
      @param bufferSize approximate size of buffer compressed data is read in
    */
    explicit TBrotliDecompress(IInputStream* slave, size_t bufferSize = 8 * 1024);
    ~TBrotliDecompress() override;

private:
    size_t DoRead(void* buffer, size_t size) override;

private:
    class TImpl;
    THolder<TImpl> Impl_;
};

/** @} */