From 113ea4e7ae962d3d0c54cb6bedf255f55b23de84 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 7 Oct 2024 17:44:19 +0100 Subject: [PATCH] Add new method Objects::all --- libqpdf/QPDF.cc | 6 ++++++ libqpdf/QPDF_objects.cc | 8 ++++---- libqpdf/qpdf/QPDF_objects.hh | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index beab50ee..e5bde7ea 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -500,6 +500,12 @@ QPDF::getObjectCount() return toS(og.getObj()); } +std::vector +QPDF::getAllObjects() +{ + return m->objects.all(); +} + void QPDF::setLastObjectDescription(std::string const& description, QPDFObjGen const& og) { diff --git a/libqpdf/QPDF_objects.cc b/libqpdf/QPDF_objects.cc index 6857b2eb..69c444b0 100644 --- a/libqpdf/QPDF_objects.cc +++ b/libqpdf/QPDF_objects.cc @@ -1149,13 +1149,13 @@ Xref_table::resolve() } std::vector -QPDF::getAllObjects() +Objects ::all() { // After fixDanglingReferences is called, all objects are in the object cache. - fixDanglingReferences(); + qpdf.fixDanglingReferences(); std::vector result; - for (auto const& iter: m->objects.obj_cache) { - result.push_back(newIndirect(iter.first, iter.second.object)); + for (auto const& iter: obj_cache) { + result.emplace_back(iter.second.object); } return result; } diff --git a/libqpdf/qpdf/QPDF_objects.hh b/libqpdf/qpdf/QPDF_objects.hh index 43e3048a..ff483a98 100644 --- a/libqpdf/qpdf/QPDF_objects.hh +++ b/libqpdf/qpdf/QPDF_objects.hh @@ -441,6 +441,8 @@ class QPDF::Objects return get(QPDFObjGen(id, gen)); } + std::vector all(); + void erase(QPDFObjGen og); void replace(QPDFObjGen og, QPDFObjectHandle oh);