2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFXRefEntry.hh>
|
2022-02-04 21:31:31 +00:00
|
|
|
|
2019-06-21 03:35:23 +00:00
|
|
|
#include <qpdf/QIntC.hh>
|
2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFExc.hh>
|
|
|
|
|
2023-01-18 11:25:44 +00:00
|
|
|
QPDFXRefEntry::QPDFXRefEntry()
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-21 23:32:21 +00:00
|
|
|
QPDFXRefEntry::QPDFXRefEntry(int type, qpdf_offset_t field1, int field2) :
|
2008-04-29 12:55:25 +00:00
|
|
|
type(type),
|
|
|
|
field1(field1),
|
|
|
|
field2(field2)
|
|
|
|
{
|
|
|
|
if ((type < 1) || (type > 2)) {
|
2022-09-21 16:49:21 +00:00
|
|
|
throw std::logic_error("invalid xref type " + std::to_string(type));
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDFXRefEntry::getType() const
|
|
|
|
{
|
|
|
|
return this->type;
|
|
|
|
}
|
|
|
|
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t
|
2008-04-29 12:55:25 +00:00
|
|
|
QPDFXRefEntry::getOffset() const
|
|
|
|
{
|
|
|
|
if (this->type != 1) {
|
2022-02-08 14:18:08 +00:00
|
|
|
throw std::logic_error("getOffset called for xref entry of type != 1");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
return this->field1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDFXRefEntry::getObjStreamNumber() const
|
|
|
|
{
|
|
|
|
if (this->type != 2) {
|
2022-02-08 14:18:08 +00:00
|
|
|
throw std::logic_error("getObjStreamNumber called for xref entry of type != 2");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
2019-06-21 03:35:23 +00:00
|
|
|
return QIntC::to_int(this->field1);
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
QPDFXRefEntry::getObjStreamIndex() const
|
|
|
|
{
|
|
|
|
if (this->type != 2) {
|
2022-02-08 14:18:08 +00:00
|
|
|
throw std::logic_error("getObjStreamIndex called for xref entry of type != 2");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
return this->field2;
|
|
|
|
}
|