Coverage Report

Created: 2026-08-25 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/poppler/FlateEncoder.h
Line
Count
Source
1
//========================================================================
2
//
3
// FlateEncoder.h
4
//
5
// Copyright (C) 2016, William Bader <williambader@hotmail.com>
6
// Copyright (C) 2018, 2019, 2021, 2025 Albert Astals Cid <aacid@kde.org>
7
// Copyright (C) 2025 Nelson Benítez León <nbenitezl@gmail.com>
8
// Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
9
// Copyright (C) 2025 Arnav V <arnav0872@gmail.com>
10
//
11
// This file is under the GPLv2 or later license
12
//
13
//========================================================================
14
15
#ifndef FLATEENCODE_H
16
#define FLATEENCODE_H
17
18
#include <cstdio>
19
#include "Object.h"
20
21
#include "Stream.h"
22
23
extern "C" {
24
#include <zlib.h>
25
}
26
27
//------------------------------------------------------------------------
28
// FlateEncoder
29
//------------------------------------------------------------------------
30
31
class FlateEncoder : public FilterStream
32
{
33
public:
34
    explicit FlateEncoder(Stream *strA);
35
    ~FlateEncoder() override;
36
0
    StreamKind getKind() const override { return strWeird; }
37
    [[nodiscard]] bool rewind() override;
38
0
    int getChar() override { return (outBufPtr >= outBufEnd && !fillBuf()) ? EOF : (*outBufPtr++ & 0xff); }
39
0
    int lookChar() override { return (outBufPtr >= outBufEnd && !fillBuf()) ? EOF : (*outBufPtr & 0xff); }
40
0
    std::optional<std::string> getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return {}; }
41
0
    bool isBinary(bool /*last*/ = true) const override { return true; }
42
0
    bool isEncoder() const override { return true; }
43
44
private:
45
    static const int inBufSize = 16384;
46
    static const int outBufSize = inBufSize;
47
    unsigned char inBuf[inBufSize];
48
    unsigned char outBuf[outBufSize];
49
    unsigned char *outBufPtr;
50
    unsigned char *outBufEnd;
51
    bool inBufEof;
52
    bool outBufEof;
53
    z_stream zlib_stream;
54
55
    bool fillBuf();
56
};
57
58
#endif