Coverage Report

Created: 2025-11-11 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/QPDFXRefEntry.cc
Line
Count
Source
1
#include <qpdf/QPDFXRefEntry.hh>
2
3
#include <qpdf/QIntC.hh>
4
#include <qpdf/QPDFExc.hh>
5
6
QPDFXRefEntry::QPDFXRefEntry() // NOLINT (modernize-use-equals-default)
7
4.17M
{
8
4.17M
}
9
10
QPDFXRefEntry::QPDFXRefEntry(int type, qpdf_offset_t field1, int field2) :
11
0
    type(type),
12
0
    field1(field1),
13
0
    field2(field2)
14
0
{
15
0
    if ((type < 1) || (type > 2)) {
16
0
        throw std::logic_error("invalid xref type " + std::to_string(type));
17
0
    }
18
0
}
19
20
int
21
QPDFXRefEntry::getType() const
22
1.66M
{
23
1.66M
    return this->type;
24
1.66M
}
25
26
qpdf_offset_t
27
QPDFXRefEntry::getOffset() const
28
1.07M
{
29
1.07M
    if (this->type != 1) {
30
0
        throw std::logic_error("getOffset called for xref entry of type != 1");
31
0
    }
32
1.07M
    return this->field1;
33
1.07M
}
34
35
int
36
QPDFXRefEntry::getObjStreamNumber() const
37
427k
{
38
427k
    if (this->type != 2) {
39
0
        throw std::logic_error("getObjStreamNumber called for xref entry of type != 2");
40
0
    }
41
427k
    return QIntC::to_int(this->field1);
42
427k
}
43
44
int
45
QPDFXRefEntry::getObjStreamIndex() const
46
67.0k
{
47
67.0k
    if (this->type != 2) {
48
0
        throw std::logic_error("getObjStreamIndex called for xref entry of type != 2");
49
0
    }
50
67.0k
    return this->field2;
51
67.0k
}