Commit b123f79dfd5015453bdbf5d53f8225d73b6b20aa
1 parent
c0168cf8
Replace QPDFObjectHandle::objid and generation with QPDFObjectHandle::og
Showing
2 changed files
with
13 additions
and
20 deletions
include/qpdf/QPDFObjectHandle.hh
| @@ -1550,7 +1550,7 @@ class QPDFObjectHandle | @@ -1550,7 +1550,7 @@ class QPDFObjectHandle | ||
| 1550 | bool isImage(bool exclude_imagemask = true); | 1550 | bool isImage(bool exclude_imagemask = true); |
| 1551 | 1551 | ||
| 1552 | private: | 1552 | private: |
| 1553 | - QPDFObjectHandle(QPDF*, int objid, int generation); | 1553 | + QPDFObjectHandle(QPDF*, QPDFObjGen const& og); |
| 1554 | QPDFObjectHandle(std::shared_ptr<QPDFObject> const&); | 1554 | QPDFObjectHandle(std::shared_ptr<QPDFObject> const&); |
| 1555 | 1555 | ||
| 1556 | enum parser_state_e { | 1556 | enum parser_state_e { |
| @@ -1617,8 +1617,7 @@ class QPDFObjectHandle | @@ -1617,8 +1617,7 @@ class QPDFObjectHandle | ||
| 1617 | // a substantial performance penalty since QPDFObjectHandle | 1617 | // a substantial performance penalty since QPDFObjectHandle |
| 1618 | // objects are copied around so frequently. | 1618 | // objects are copied around so frequently. |
| 1619 | QPDF* qpdf; | 1619 | QPDF* qpdf; |
| 1620 | - int objid; // 0 for direct object | ||
| 1621 | - int generation; | 1620 | + QPDFObjGen og; |
| 1622 | std::shared_ptr<QPDFObject> obj; | 1621 | std::shared_ptr<QPDFObject> obj; |
| 1623 | bool reserved; | 1622 | bool reserved; |
| 1624 | }; | 1623 | }; |
libqpdf/QPDFObjectHandle.cc
| @@ -218,27 +218,22 @@ LastChar::getLastChar() | @@ -218,27 +218,22 @@ LastChar::getLastChar() | ||
| 218 | 218 | ||
| 219 | QPDFObjectHandle::QPDFObjectHandle() : | 219 | QPDFObjectHandle::QPDFObjectHandle() : |
| 220 | initialized(false), | 220 | initialized(false), |
| 221 | - qpdf(0), | ||
| 222 | - objid(0), | ||
| 223 | - generation(0), | 221 | + qpdf(nullptr), |
| 224 | reserved(false) | 222 | reserved(false) |
| 225 | { | 223 | { |
| 226 | } | 224 | } |
| 227 | 225 | ||
| 228 | -QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, int objid, int generation) : | 226 | +QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, QPDFObjGen const& og) : |
| 229 | initialized(true), | 227 | initialized(true), |
| 230 | qpdf(qpdf), | 228 | qpdf(qpdf), |
| 231 | - objid(objid), | ||
| 232 | - generation(generation), | 229 | + og(og), |
| 233 | reserved(false) | 230 | reserved(false) |
| 234 | { | 231 | { |
| 235 | } | 232 | } |
| 236 | 233 | ||
| 237 | QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) : | 234 | QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) : |
| 238 | initialized(true), | 235 | initialized(true), |
| 239 | - qpdf(0), | ||
| 240 | - objid(0), | ||
| 241 | - generation(0), | 236 | + qpdf(nullptr), |
| 242 | obj(data), | 237 | obj(data), |
| 243 | reserved(false) | 238 | reserved(false) |
| 244 | { | 239 | { |
| @@ -1481,19 +1476,19 @@ QPDFObjectHandle::replaceStreamData( | @@ -1481,19 +1476,19 @@ QPDFObjectHandle::replaceStreamData( | ||
| 1481 | QPDFObjGen | 1476 | QPDFObjGen |
| 1482 | QPDFObjectHandle::getObjGen() const | 1477 | QPDFObjectHandle::getObjGen() const |
| 1483 | { | 1478 | { |
| 1484 | - return QPDFObjGen(this->objid, this->generation); | 1479 | + return og; |
| 1485 | } | 1480 | } |
| 1486 | 1481 | ||
| 1487 | int | 1482 | int |
| 1488 | QPDFObjectHandle::getObjectID() const | 1483 | QPDFObjectHandle::getObjectID() const |
| 1489 | { | 1484 | { |
| 1490 | - return this->objid; | 1485 | + return og.getObj(); |
| 1491 | } | 1486 | } |
| 1492 | 1487 | ||
| 1493 | int | 1488 | int |
| 1494 | QPDFObjectHandle::getGeneration() const | 1489 | QPDFObjectHandle::getGeneration() const |
| 1495 | { | 1490 | { |
| 1496 | - return this->generation; | 1491 | + return og.getGen(); |
| 1497 | } | 1492 | } |
| 1498 | 1493 | ||
| 1499 | std::map<std::string, QPDFObjectHandle> | 1494 | std::map<std::string, QPDFObjectHandle> |
| @@ -2485,7 +2480,7 @@ QPDFObjectHandle::newIndirect(QPDF* qpdf, int objid, int generation) | @@ -2485,7 +2480,7 @@ QPDFObjectHandle::newIndirect(QPDF* qpdf, int objid, int generation) | ||
| 2485 | return newNull(); | 2480 | return newNull(); |
| 2486 | } | 2481 | } |
| 2487 | 2482 | ||
| 2488 | - return QPDFObjectHandle(qpdf, objid, generation); | 2483 | + return QPDFObjectHandle(qpdf, QPDFObjGen(objid, generation)); |
| 2489 | } | 2484 | } |
| 2490 | 2485 | ||
| 2491 | QPDFObjectHandle | 2486 | QPDFObjectHandle |
| @@ -2689,7 +2684,7 @@ QPDFObjectHandle::newReserved(QPDF* qpdf) | @@ -2689,7 +2684,7 @@ QPDFObjectHandle::newReserved(QPDF* qpdf) | ||
| 2689 | // number, but then return an unresolved handle to the object. | 2684 | // number, but then return an unresolved handle to the object. |
| 2690 | QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved()); | 2685 | QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved()); |
| 2691 | QPDFObjectHandle result = | 2686 | QPDFObjectHandle result = |
| 2692 | - newIndirect(qpdf, reserved.objid, reserved.generation); | 2687 | + newIndirect(qpdf, reserved.getObjectID(), reserved.getGeneration()); |
| 2693 | result.reserved = true; | 2688 | result.reserved = true; |
| 2694 | return result; | 2689 | return result; |
| 2695 | } | 2690 | } |
| @@ -2789,9 +2784,8 @@ QPDFObjectHandle::copyObject( | @@ -2789,9 +2784,8 @@ QPDFObjectHandle::copyObject( | ||
| 2789 | " reserved object handle direct"); | 2784 | " reserved object handle direct"); |
| 2790 | } | 2785 | } |
| 2791 | 2786 | ||
| 2792 | - this->qpdf = 0; | ||
| 2793 | - this->objid = 0; | ||
| 2794 | - this->generation = 0; | 2787 | + qpdf = nullptr; |
| 2788 | + og = QPDFObjGen(); | ||
| 2795 | 2789 | ||
| 2796 | std::shared_ptr<QPDFObject> new_obj; | 2790 | std::shared_ptr<QPDFObject> new_obj; |
| 2797 | 2791 |