Coverage Report

Created: 2025-11-24 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/Pl_Count.cc
Line
Count
Source
1
#include <qpdf/Pl_Count.hh>
2
3
#include <qpdf/QIntC.hh>
4
#include <qpdf/Util.hh>
5
6
using namespace qpdf;
7
8
class Pl_Count::Members
9
{
10
  public:
11
0
    Members() = default;
12
    Members(Members const&) = delete;
13
    ~Members() = default;
14
15
    // Must be qpdf_offset_t, not size_t, to handle writing more than size_t can handle.
16
    qpdf_offset_t count{0};
17
    unsigned char last_char{'\0'};
18
};
19
20
Pl_Count::Pl_Count(char const* identifier, Pipeline* next) :
21
0
    Pipeline(identifier, next),
22
0
    m(std::make_unique<Members>())
23
0
{
24
0
    util::assertion(next, "Attempt to create Pl_Count with nullptr as next");
25
0
}
26
27
0
Pl_Count::~Pl_Count() = default;
28
// Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
29
30
void
31
Pl_Count::write(unsigned char const* buf, size_t len)
32
0
{
33
0
    if (len) {
34
0
        m->count += QIntC::to_offset(len);
35
0
        m->last_char = buf[len - 1];
36
0
        next()->write(buf, len);
37
0
    }
38
0
}
39
40
void
41
Pl_Count::finish()
42
0
{
43
0
    next()->finish();
44
0
}
45
46
qpdf_offset_t
47
Pl_Count::getCount() const
48
0
{
49
0
    return m->count;
50
0
}
51
52
unsigned char
53
Pl_Count::getLastChar() const
54
0
{
55
0
    return m->last_char;
56
0
}