From ec35156ab0fef078600e6d3551178adf73b87b3b Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 31 Dec 2022 12:13:32 +0000 Subject: Refactor QPDFValue::getDescription Remove parameters and return the description. --- libqpdf/QPDF_Dictionary.cc | 8 +++----- libqpdf/QPDF_Stream.cc | 7 ++----- libqpdf/qpdf/QPDFObject_private.hh | 4 +++- libqpdf/qpdf/QPDFValue.hh | 9 ++++----- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 1df4f8f0..87d93a32 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -84,12 +84,10 @@ QPDF_Dictionary::getKey(std::string const& key) // May be a null object return item->second; } else { - QPDFObjectHandle null = QPDFObjectHandle::newNull(); - QPDF* qpdf = nullptr; - std::string description; - if (getDescription(qpdf, description)) { + auto null = QPDFObjectHandle::newNull(); + if (qpdf != nullptr) { null.setObjectDescription( - qpdf, description + " -> dictionary key " + key); + qpdf, getDescription() + " -> dictionary key " + key); } return null; } diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index b5aac026..66916c21 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -292,12 +292,9 @@ QPDF_Stream::setDescription( void QPDF_Stream::setDictDescription() { - QPDF* qpdf = nullptr; - std::string description; - if ((!this->stream_dict.hasObjectDescription()) && - getDescription(qpdf, description)) { + if (!this->stream_dict.hasObjectDescription()) { this->stream_dict.setObjectDescription( - qpdf, description + " -> stream dictionary"); + qpdf, getDescription() + " -> stream dictionary"); } } diff --git a/libqpdf/qpdf/QPDFObject_private.hh b/libqpdf/qpdf/QPDFObject_private.hh index 416483c2..4d388503 100644 --- a/libqpdf/qpdf/QPDFObject_private.hh +++ b/libqpdf/qpdf/QPDFObject_private.hh @@ -79,7 +79,9 @@ class QPDFObject bool getDescription(QPDF*& qpdf, std::string& description) { - return value->getDescription(qpdf, description); + qpdf = value->qpdf; + description = value->getDescription(); + return qpdf != nullptr; } bool hasDescription() diff --git a/libqpdf/qpdf/QPDFValue.hh b/libqpdf/qpdf/QPDFValue.hh index 2d3b9de3..c64f0d6e 100644 --- a/libqpdf/qpdf/QPDFValue.hh +++ b/libqpdf/qpdf/QPDFValue.hh @@ -44,11 +44,10 @@ class QPDFValue qpdf = a_qpdf; og = a_og; } - bool - getDescription(QPDF*& qpdf_p, std::string& description) + std::string + getDescription() { - qpdf_p = qpdf; - description = object_description ? *object_description : ""; + auto description = object_description ? *object_description : ""; if (auto pos = description.find("$OG"); pos != std::string::npos) { description.replace(pos, 3, og.unparse(' ')); } @@ -59,7 +58,7 @@ class QPDFValue description.replace(pos, 3, std::to_string(parsed_offset + shift)); } - return qpdf != nullptr; + return description; } bool hasDescription() -- cgit v1.2.3-54-g00ecf