Commit ec35156ab0fef078600e6d3551178adf73b87b3b

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 0ef2def8

Refactor QPDFValue::getDescription

Remove parameters and return the description.
libqpdf/QPDF_Dictionary.cc
... ... @@ -84,12 +84,10 @@ QPDF_Dictionary::getKey(std::string const& key)
84 84 // May be a null object
85 85 return item->second;
86 86 } else {
87   - QPDFObjectHandle null = QPDFObjectHandle::newNull();
88   - QPDF* qpdf = nullptr;
89   - std::string description;
90   - if (getDescription(qpdf, description)) {
  87 + auto null = QPDFObjectHandle::newNull();
  88 + if (qpdf != nullptr) {
91 89 null.setObjectDescription(
92   - qpdf, description + " -> dictionary key " + key);
  90 + qpdf, getDescription() + " -> dictionary key " + key);
93 91 }
94 92 return null;
95 93 }
... ...
libqpdf/QPDF_Stream.cc
... ... @@ -292,12 +292,9 @@ QPDF_Stream::setDescription(
292 292 void
293 293 QPDF_Stream::setDictDescription()
294 294 {
295   - QPDF* qpdf = nullptr;
296   - std::string description;
297   - if ((!this->stream_dict.hasObjectDescription()) &&
298   - getDescription(qpdf, description)) {
  295 + if (!this->stream_dict.hasObjectDescription()) {
299 296 this->stream_dict.setObjectDescription(
300   - qpdf, description + " -> stream dictionary");
  297 + qpdf, getDescription() + " -> stream dictionary");
301 298 }
302 299 }
303 300  
... ...
libqpdf/qpdf/QPDFObject_private.hh
... ... @@ -79,7 +79,9 @@ class QPDFObject
79 79 bool
80 80 getDescription(QPDF*& qpdf, std::string& description)
81 81 {
82   - return value->getDescription(qpdf, description);
  82 + qpdf = value->qpdf;
  83 + description = value->getDescription();
  84 + return qpdf != nullptr;
83 85 }
84 86 bool
85 87 hasDescription()
... ...
libqpdf/qpdf/QPDFValue.hh
... ... @@ -44,11 +44,10 @@ class QPDFValue
44 44 qpdf = a_qpdf;
45 45 og = a_og;
46 46 }
47   - bool
48   - getDescription(QPDF*& qpdf_p, std::string& description)
  47 + std::string
  48 + getDescription()
49 49 {
50   - qpdf_p = qpdf;
51   - description = object_description ? *object_description : "";
  50 + auto description = object_description ? *object_description : "";
52 51 if (auto pos = description.find("$OG"); pos != std::string::npos) {
53 52 description.replace(pos, 3, og.unparse(' '));
54 53 }
... ... @@ -59,7 +58,7 @@ class QPDFValue
59 58  
60 59 description.replace(pos, 3, std::to_string(parsed_offset + shift));
61 60 }
62   - return qpdf != nullptr;
  61 + return description;
63 62 }
64 63 bool
65 64 hasDescription()
... ...