2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-01 03:12:29 +00:00

Replace QPDFObjectHandle::objid and generation with QPDFObjectHandle::og

This commit is contained in:
m-holger 2022-07-23 14:15:55 +01:00
parent c0168cf88c
commit b123f79dfd
2 changed files with 13 additions and 20 deletions

View File

@ -1550,7 +1550,7 @@ class QPDFObjectHandle
bool isImage(bool exclude_imagemask = true); bool isImage(bool exclude_imagemask = true);
private: private:
QPDFObjectHandle(QPDF*, int objid, int generation); QPDFObjectHandle(QPDF*, QPDFObjGen const& og);
QPDFObjectHandle(std::shared_ptr<QPDFObject> const&); QPDFObjectHandle(std::shared_ptr<QPDFObject> const&);
enum parser_state_e { enum parser_state_e {
@ -1617,8 +1617,7 @@ class QPDFObjectHandle
// a substantial performance penalty since QPDFObjectHandle // a substantial performance penalty since QPDFObjectHandle
// objects are copied around so frequently. // objects are copied around so frequently.
QPDF* qpdf; QPDF* qpdf;
int objid; // 0 for direct object QPDFObjGen og;
int generation;
std::shared_ptr<QPDFObject> obj; std::shared_ptr<QPDFObject> obj;
bool reserved; bool reserved;
}; };

View File

@ -218,27 +218,22 @@ LastChar::getLastChar()
QPDFObjectHandle::QPDFObjectHandle() : QPDFObjectHandle::QPDFObjectHandle() :
initialized(false), initialized(false),
qpdf(0), qpdf(nullptr),
objid(0),
generation(0),
reserved(false) reserved(false)
{ {
} }
QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, int objid, int generation) : QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, QPDFObjGen const& og) :
initialized(true), initialized(true),
qpdf(qpdf), qpdf(qpdf),
objid(objid), og(og),
generation(generation),
reserved(false) reserved(false)
{ {
} }
QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) : QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) :
initialized(true), initialized(true),
qpdf(0), qpdf(nullptr),
objid(0),
generation(0),
obj(data), obj(data),
reserved(false) reserved(false)
{ {
@ -1481,19 +1476,19 @@ QPDFObjectHandle::replaceStreamData(
QPDFObjGen QPDFObjGen
QPDFObjectHandle::getObjGen() const QPDFObjectHandle::getObjGen() const
{ {
return QPDFObjGen(this->objid, this->generation); return og;
} }
int int
QPDFObjectHandle::getObjectID() const QPDFObjectHandle::getObjectID() const
{ {
return this->objid; return og.getObj();
} }
int int
QPDFObjectHandle::getGeneration() const QPDFObjectHandle::getGeneration() const
{ {
return this->generation; return og.getGen();
} }
std::map<std::string, QPDFObjectHandle> std::map<std::string, QPDFObjectHandle>
@ -2485,7 +2480,7 @@ QPDFObjectHandle::newIndirect(QPDF* qpdf, int objid, int generation)
return newNull(); return newNull();
} }
return QPDFObjectHandle(qpdf, objid, generation); return QPDFObjectHandle(qpdf, QPDFObjGen(objid, generation));
} }
QPDFObjectHandle QPDFObjectHandle
@ -2689,7 +2684,7 @@ QPDFObjectHandle::newReserved(QPDF* qpdf)
// number, but then return an unresolved handle to the object. // number, but then return an unresolved handle to the object.
QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved()); QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved());
QPDFObjectHandle result = QPDFObjectHandle result =
newIndirect(qpdf, reserved.objid, reserved.generation); newIndirect(qpdf, reserved.getObjectID(), reserved.getGeneration());
result.reserved = true; result.reserved = true;
return result; return result;
} }
@ -2789,9 +2784,8 @@ QPDFObjectHandle::copyObject(
" reserved object handle direct"); " reserved object handle direct");
} }
this->qpdf = 0; qpdf = nullptr;
this->objid = 0; og = QPDFObjGen();
this->generation = 0;
std::shared_ptr<QPDFObject> new_obj; std::shared_ptr<QPDFObject> new_obj;