/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 | 4.70M | { |
8 | 4.70M | } |
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 | 2.40M | { |
23 | 2.40M | return this->type; |
24 | 2.40M | } |
25 | | |
26 | | qpdf_offset_t |
27 | | QPDFXRefEntry::getOffset() const |
28 | 1.34M | { |
29 | 1.34M | if (this->type != 1) { |
30 | 0 | throw std::logic_error("getOffset called for xref entry of type != 1"); |
31 | 0 | } |
32 | 1.34M | return this->field1; |
33 | 1.34M | } |
34 | | |
35 | | int |
36 | | QPDFXRefEntry::getObjStreamNumber() const |
37 | 662k | { |
38 | 662k | if (this->type != 2) { |
39 | 0 | throw std::logic_error("getObjStreamNumber called for xref entry of type != 2"); |
40 | 0 | } |
41 | 662k | return QIntC::to_int(this->field1); |
42 | 662k | } |
43 | | |
44 | | int |
45 | | QPDFXRefEntry::getObjStreamIndex() const |
46 | 93.8k | { |
47 | 93.8k | if (this->type != 2) { |
48 | 0 | throw std::logic_error("getObjStreamIndex called for xref entry of type != 2"); |
49 | 0 | } |
50 | 93.8k | return this->field2; |
51 | 93.8k | } |