Coverage Report

Created: 2025-07-01 06:10

/src/qpdf/libqpdf/QPDFXRefEntry.cc
Line
Count
Source (jump to first uncovered line)
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
0
{
8
0
}
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
0
{
23
0
    return this->type;
24
0
}
25
26
qpdf_offset_t
27
QPDFXRefEntry::getOffset() const
28
0
{
29
0
    if (this->type != 1) {
30
0
        throw std::logic_error("getOffset called for xref entry of type != 1");
31
0
    }
32
0
    return this->field1;
33
0
}
34
35
int
36
QPDFXRefEntry::getObjStreamNumber() const
37
0
{
38
0
    if (this->type != 2) {
39
0
        throw std::logic_error("getObjStreamNumber called for xref entry of type != 2");
40
0
    }
41
0
    return QIntC::to_int(this->field1);
42
0
}
43
44
int
45
QPDFXRefEntry::getObjStreamIndex() const
46
0
{
47
0
    if (this->type != 2) {
48
0
        throw std::logic_error("getObjStreamIndex called for xref entry of type != 2");
49
0
    }
50
0
    return this->field2;
51
0
}