aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-14 12:19:00 +0200
committerm-holger <m-holger@kubitscheck.org>2022-09-01 18:19:31 +0200
commit5033e3b215c36457106cc2dd0150f2322655360c (patch)
tree5b4043c4d1307e46932d593972762f3510abc2c6 /include
parent4a8515912c80e8d98c3c1a42eec4bdf7b6bbd8e1 (diff)
downloadqpdf-5033e3b215c36457106cc2dd0150f2322655360c.tar.zst
Add method QPDFObject::getQPDF and remove QPDFObjectHandle::qpdf
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDFObject.hh6
-rw-r--r--include/qpdf/QPDFObjectHandle.hh13
2 files changed, 12 insertions, 7 deletions
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh
index 751a5736..6801cd5b 100644
--- a/include/qpdf/QPDFObject.hh
+++ b/include/qpdf/QPDFObject.hh
@@ -97,6 +97,12 @@ class QPDFObject
{
return value->type_name;
}
+ // Returns nullptr for direct objects
+ QPDF*
+ getQPDF() const
+ {
+ return value->qpdf;
+ }
void
setDescription(QPDF* qpdf, std::string const& description)
{
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 0dc474cd..d23d0fd4 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -973,8 +973,8 @@ class QPDFObjectHandle
// null for a direct object if allow_nullptr is set to true or
// throws a runtime error otherwise.
QPDF_DLL
- inline QPDF*
- getOwningQPDF(bool allow_nullptr = true, std::string const& error_msg = "");
+ inline QPDF* getOwningQPDF(
+ bool allow_nullptr = true, std::string const& error_msg = "") const;
// Create a shallow copy of an object as a direct object, but do not
// traverse across indirect object boundaries. That means that,
@@ -1584,7 +1584,6 @@ class QPDFObjectHandle
QPDF* qpdf,
QPDFObjGen const& og,
std::shared_ptr<QPDFObject> const& obj) :
- qpdf(qpdf),
og(og),
obj(obj)
{
@@ -1641,7 +1640,6 @@ class QPDFObjectHandle
// Moving members of QPDFObjectHandle into a smart pointer incurs
// a substantial performance penalty since QPDFObjectHandle
// objects are copied around so frequently.
- QPDF* qpdf;
QPDFObjGen og;
std::shared_ptr<QPDFObject> obj;
};
@@ -1896,14 +1894,15 @@ QPDFObjectHandle::isInitialized() const
// Indirect object accessors
inline QPDF*
QPDFObjectHandle::getOwningQPDF(
- bool allow_nullptr, std::string const& error_msg)
+ bool allow_nullptr, std::string const& error_msg) const
{
// Will be null for direct objects
- if (!allow_nullptr && (this->qpdf == nullptr)) {
+ auto result = isInitialized() ? this->obj->getQPDF() : nullptr;
+ if (!allow_nullptr && (result == nullptr)) {
throw std::runtime_error(
error_msg == "" ? "attempt to use a null qpdf object" : error_msg);
}
- return this->qpdf;
+ return result;
}
inline void