Commit 0afaaea22a0a8697aee42ce6183bf4441d07018b
Committed by
m-holger
1 parent
5a33c75b
Deprecate QPDFObjectHandle::isInitialized and remove from library
Showing
14 changed files
with
46 additions
and
53 deletions
examples/pdf-mod-info.cc
| @@ -131,7 +131,7 @@ main(int argc, char* argv[]) | @@ -131,7 +131,7 @@ main(int argc, char* argv[]) | ||
| 131 | QPDFObjectHandle fileinfo; | 131 | QPDFObjectHandle fileinfo; |
| 132 | 132 | ||
| 133 | for (auto const& it: Keys) { | 133 | for (auto const& it: Keys) { |
| 134 | - if (!fileinfo.isInitialized()) { | 134 | + if (!fileinfo) { |
| 135 | if (filetrailer.hasKey("/Info")) { | 135 | if (filetrailer.hasKey("/Info")) { |
| 136 | QTC::TC("examples", "pdf-mod-info has info"); | 136 | QTC::TC("examples", "pdf-mod-info has info"); |
| 137 | fileinfo = filetrailer.getKey("/Info"); | 137 | fileinfo = filetrailer.getKey("/Info"); |
include/qpdf/QPDFObjectHandle.hh
| @@ -300,8 +300,7 @@ class QPDFObjectHandle | @@ -300,8 +300,7 @@ class QPDFObjectHandle | ||
| 300 | QPDF_DLL | 300 | QPDF_DLL |
| 301 | explicit inline operator bool() const noexcept; | 301 | explicit inline operator bool() const noexcept; |
| 302 | 302 | ||
| 303 | - QPDF_DLL | ||
| 304 | - inline bool isInitialized() const; | 303 | + [[deprecated("use operator bool()")]] QPDF_DLL inline bool isInitialized() const; |
| 305 | 304 | ||
| 306 | // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying | 305 | // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying |
| 307 | // object, meaning that changes to one are reflected in the other, or "if you paint one, the | 306 | // object, meaning that changes to one are reflected in the other, or "if you paint one, the |
include/qpdf/QPDFObjectHandle_future.hh
| @@ -300,8 +300,7 @@ class QPDFObjectHandle | @@ -300,8 +300,7 @@ class QPDFObjectHandle | ||
| 300 | QPDF_DLL | 300 | QPDF_DLL |
| 301 | explicit inline operator bool() const noexcept; | 301 | explicit inline operator bool() const noexcept; |
| 302 | 302 | ||
| 303 | - QPDF_DLL | ||
| 304 | - inline bool isInitialized() const noexcept; | 303 | + [[deprecated("use operator bool()")]] QPDF_DLL inline bool isInitialized() const noexcept; |
| 305 | 304 | ||
| 306 | // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying | 305 | // This method returns true if the QPDFObjectHandle objects point to exactly the same underlying |
| 307 | // object, meaning that changes to one are reflected in the other, or "if you paint one, the | 306 | // object, meaning that changes to one are reflected in the other, or "if you paint one, the |
libqpdf/NNTree.cc
| @@ -188,7 +188,7 @@ NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list<PathElement>::itera | @@ -188,7 +188,7 @@ NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list<PathElement>::itera | ||
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| 190 | } | 190 | } |
| 191 | - if (first.isInitialized() && last.isInitialized()) { | 191 | + if (first && last) { |
| 192 | auto limits = QPDFObjectHandle::newArray(); | 192 | auto limits = QPDFObjectHandle::newArray(); |
| 193 | limits.appendItem(first); | 193 | limits.appendItem(first); |
| 194 | limits.appendItem(last); | 194 | limits.appendItem(last); |
libqpdf/QPDF.cc
| @@ -526,7 +526,7 @@ QPDF::warn( | @@ -526,7 +526,7 @@ QPDF::warn( | ||
| 526 | void | 526 | void |
| 527 | QPDF::setTrailer(QPDFObjectHandle obj) | 527 | QPDF::setTrailer(QPDFObjectHandle obj) |
| 528 | { | 528 | { |
| 529 | - if (m->trailer.isInitialized()) { | 529 | + if (m->trailer) { |
| 530 | return; | 530 | return; |
| 531 | } | 531 | } |
| 532 | m->trailer = obj; | 532 | m->trailer = obj; |
| @@ -591,7 +591,7 @@ QPDF::reconstruct_xref(QPDFExc& e) | @@ -591,7 +591,7 @@ QPDF::reconstruct_xref(QPDFExc& e) | ||
| 591 | } | 591 | } |
| 592 | } | 592 | } |
| 593 | m->file->seek(pos, SEEK_SET); | 593 | m->file->seek(pos, SEEK_SET); |
| 594 | - } else if (!m->trailer.isInitialized() && t1.isWord("trailer")) { | 594 | + } else if (!m->trailer && t1.isWord("trailer")) { |
| 595 | auto pos = m->file->tell(); | 595 | auto pos = m->file->tell(); |
| 596 | QPDFObjectHandle t = readTrailer(); | 596 | QPDFObjectHandle t = readTrailer(); |
| 597 | if (!t.isDictionary()) { | 597 | if (!t.isDictionary()) { |
| @@ -606,7 +606,7 @@ QPDF::reconstruct_xref(QPDFExc& e) | @@ -606,7 +606,7 @@ QPDF::reconstruct_xref(QPDFExc& e) | ||
| 606 | } | 606 | } |
| 607 | m->deleted_objects.clear(); | 607 | m->deleted_objects.clear(); |
| 608 | 608 | ||
| 609 | - if (!m->trailer.isInitialized()) { | 609 | + if (!m->trailer) { |
| 610 | qpdf_offset_t max_offset{0}; | 610 | qpdf_offset_t max_offset{0}; |
| 611 | // If there are any xref streams, take the last one to appear. | 611 | // If there are any xref streams, take the last one to appear. |
| 612 | for (auto const& iter: m->xref_table) { | 612 | for (auto const& iter: m->xref_table) { |
| @@ -640,7 +640,7 @@ QPDF::reconstruct_xref(QPDFExc& e) | @@ -640,7 +640,7 @@ QPDF::reconstruct_xref(QPDFExc& e) | ||
| 640 | } | 640 | } |
| 641 | } | 641 | } |
| 642 | 642 | ||
| 643 | - if (!m->trailer.isInitialized()) { | 643 | + if (!m->trailer) { |
| 644 | // We could check the last encountered object to see if it was an xref stream. If so, we | 644 | // We could check the last encountered object to see if it was an xref stream. If so, we |
| 645 | // could try to get the trailer from there. This may make it possible to recover files with | 645 | // could try to get the trailer from there. This may make it possible to recover files with |
| 646 | // bad startxref pointers even when they have object streams. | 646 | // bad startxref pointers even when they have object streams. |
| @@ -730,7 +730,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) | @@ -730,7 +730,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) | ||
| 730 | } | 730 | } |
| 731 | } | 731 | } |
| 732 | 732 | ||
| 733 | - if (!m->trailer.isInitialized()) { | 733 | + if (!m->trailer) { |
| 734 | throw damagedPDF("", 0, "unable to find trailer while reading xref"); | 734 | throw damagedPDF("", 0, "unable to find trailer while reading xref"); |
| 735 | } | 735 | } |
| 736 | int size = m->trailer.getKey("/Size").getIntValueAsInt(); | 736 | int size = m->trailer.getKey("/Size").getIntValueAsInt(); |
| @@ -1000,7 +1000,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) | @@ -1000,7 +1000,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) | ||
| 1000 | throw damagedPDF("", "expected trailer dictionary"); | 1000 | throw damagedPDF("", "expected trailer dictionary"); |
| 1001 | } | 1001 | } |
| 1002 | 1002 | ||
| 1003 | - if (!m->trailer.isInitialized()) { | 1003 | + if (!m->trailer) { |
| 1004 | setTrailer(cur_trailer); | 1004 | setTrailer(cur_trailer); |
| 1005 | 1005 | ||
| 1006 | if (!m->trailer.hasKey("/Size")) { | 1006 | if (!m->trailer.hasKey("/Size")) { |
| @@ -1258,7 +1258,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj) | @@ -1258,7 +1258,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj) | ||
| 1258 | } | 1258 | } |
| 1259 | } | 1259 | } |
| 1260 | 1260 | ||
| 1261 | - if (!m->trailer.isInitialized()) { | 1261 | + if (!m->trailer) { |
| 1262 | setTrailer(dict); | 1262 | setTrailer(dict); |
| 1263 | } | 1263 | } |
| 1264 | 1264 | ||
| @@ -2052,7 +2052,7 @@ QPDF::makeIndirectFromQPDFObject(std::shared_ptr<QPDFObject> const& obj) | @@ -2052,7 +2052,7 @@ QPDF::makeIndirectFromQPDFObject(std::shared_ptr<QPDFObject> const& obj) | ||
| 2052 | QPDFObjectHandle | 2052 | QPDFObjectHandle |
| 2053 | QPDF::makeIndirectObject(QPDFObjectHandle oh) | 2053 | QPDF::makeIndirectObject(QPDFObjectHandle oh) |
| 2054 | { | 2054 | { |
| 2055 | - if (!oh.isInitialized()) { | 2055 | + if (!oh) { |
| 2056 | throw std::logic_error("attempted to make an uninitialized QPDFObjectHandle indirect"); | 2056 | throw std::logic_error("attempted to make an uninitialized QPDFObjectHandle indirect"); |
| 2057 | } | 2057 | } |
| 2058 | return makeIndirectFromQPDFObject(oh.getObj()); | 2058 | return makeIndirectFromQPDFObject(oh.getObj()); |
| @@ -2163,7 +2163,7 @@ QPDF::replaceObject(int objid, int generation, QPDFObjectHandle oh) | @@ -2163,7 +2163,7 @@ QPDF::replaceObject(int objid, int generation, QPDFObjectHandle oh) | ||
| 2163 | void | 2163 | void |
| 2164 | QPDF::replaceObject(QPDFObjGen const& og, QPDFObjectHandle oh) | 2164 | QPDF::replaceObject(QPDFObjGen const& og, QPDFObjectHandle oh) |
| 2165 | { | 2165 | { |
| 2166 | - if (!oh.isInitialized() || (oh.isIndirect() && !(oh.isStream() && oh.getObjGen() == og))) { | 2166 | + if (!oh || (oh.isIndirect() && !(oh.isStream() && oh.getObjGen() == og))) { |
| 2167 | QTC::TC("qpdf", "QPDF replaceObject called with indirect object"); | 2167 | QTC::TC("qpdf", "QPDF replaceObject called with indirect object"); |
| 2168 | throw std::logic_error("QPDF::replaceObject called with indirect object handle"); | 2168 | throw std::logic_error("QPDF::replaceObject called with indirect object handle"); |
| 2169 | } | 2169 | } |
libqpdf/QPDFFormFieldObjectHelper.cc
| @@ -396,7 +396,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) | @@ -396,7 +396,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) | ||
| 396 | } else { | 396 | } else { |
| 397 | annot = kid; | 397 | annot = kid; |
| 398 | } | 398 | } |
| 399 | - if (!annot.isInitialized()) { | 399 | + if (!annot) { |
| 400 | QTC::TC("qpdf", "QPDFObjectHandle broken radio button"); | 400 | QTC::TC("qpdf", "QPDFObjectHandle broken radio button"); |
| 401 | this->oh.warnIfPossible("unable to set the value of this radio button"); | 401 | this->oh.warnIfPossible("unable to set the value of this radio button"); |
| 402 | continue; | 402 | continue; |
| @@ -459,7 +459,7 @@ QPDFFormFieldObjectHelper::setCheckBoxValue(bool value) | @@ -459,7 +459,7 @@ QPDFFormFieldObjectHelper::setCheckBoxValue(bool value) | ||
| 459 | // Set /AS to the on value or /Off in addition to setting /V. | 459 | // Set /AS to the on value or /Off in addition to setting /V. |
| 460 | QPDFObjectHandle name = QPDFObjectHandle::newName(value ? on_value : "/Off"); | 460 | QPDFObjectHandle name = QPDFObjectHandle::newName(value ? on_value : "/Off"); |
| 461 | setFieldAttribute("/V", name); | 461 | setFieldAttribute("/V", name); |
| 462 | - if (!annot.isInitialized()) { | 462 | + if (!annot) { |
| 463 | QTC::TC("qpdf", "QPDFObjectHandle broken checkbox"); | 463 | QTC::TC("qpdf", "QPDFObjectHandle broken checkbox"); |
| 464 | this->oh.warnIfPossible("unable to set the value of this checkbox"); | 464 | this->oh.warnIfPossible("unable to set the value of this checkbox"); |
| 465 | return; | 465 | return; |
| @@ -815,7 +815,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao | @@ -815,7 +815,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao | ||
| 815 | QPDFObjectHandle resources = AS.getDict().getKey("/Resources"); | 815 | QPDFObjectHandle resources = AS.getDict().getKey("/Resources"); |
| 816 | QPDFObjectHandle font = getFontFromResource(resources, font_name); | 816 | QPDFObjectHandle font = getFontFromResource(resources, font_name); |
| 817 | bool found_font_in_dr = false; | 817 | bool found_font_in_dr = false; |
| 818 | - if (!font.isInitialized()) { | 818 | + if (!font) { |
| 819 | QPDFObjectHandle dr = getDefaultResources(); | 819 | QPDFObjectHandle dr = getDefaultResources(); |
| 820 | font = getFontFromResource(dr, font_name); | 820 | font = getFontFromResource(dr, font_name); |
| 821 | found_font_in_dr = font.isDictionary(); | 821 | found_font_in_dr = font.isDictionary(); |
libqpdf/QPDFObjectHandle.cc
| @@ -2165,7 +2165,7 @@ QPDFObjectHandle::parseContentStream_data( | @@ -2165,7 +2165,7 @@ QPDFObjectHandle::parseContentStream_data( | ||
| 2165 | input->seek(offset, SEEK_SET); | 2165 | input->seek(offset, SEEK_SET); |
| 2166 | auto obj = | 2166 | auto obj = |
| 2167 | QPDFParser(*input, "content", tokenizer, nullptr, context, false).parse(empty, true); | 2167 | QPDFParser(*input, "content", tokenizer, nullptr, context, false).parse(empty, true); |
| 2168 | - if (!obj.isInitialized()) { | 2168 | + if (!obj) { |
| 2169 | // EOF | 2169 | // EOF |
| 2170 | break; | 2170 | break; |
| 2171 | } | 2171 | } |
| @@ -2520,7 +2520,7 @@ QPDFObjectHandle::makeDirect(bool allow_streams) | @@ -2520,7 +2520,7 @@ QPDFObjectHandle::makeDirect(bool allow_streams) | ||
| 2520 | void | 2520 | void |
| 2521 | QPDFObjectHandle::assertInitialized() const | 2521 | QPDFObjectHandle::assertInitialized() const |
| 2522 | { | 2522 | { |
| 2523 | - if (!isInitialized()) { | 2523 | + if (!obj) { |
| 2524 | throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle"); | 2524 | throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle"); |
| 2525 | } | 2525 | } |
| 2526 | } | 2526 | } |
| @@ -3018,34 +3018,30 @@ QPDFObjectHandle::QPDFArrayItems::end() | @@ -3018,34 +3018,30 @@ QPDFObjectHandle::QPDFArrayItems::end() | ||
| 3018 | QPDFObjGen | 3018 | QPDFObjGen |
| 3019 | QPDFObjectHandle::getObjGen() const | 3019 | QPDFObjectHandle::getObjGen() const |
| 3020 | { | 3020 | { |
| 3021 | - return isInitialized() ? obj->getObjGen() : QPDFObjGen(); | 3021 | + return obj ? obj->getObjGen() : QPDFObjGen(); |
| 3022 | } | 3022 | } |
| 3023 | 3023 | ||
| 3024 | // Indirect object accessors | 3024 | // Indirect object accessors |
| 3025 | QPDF* | 3025 | QPDF* |
| 3026 | QPDFObjectHandle::getOwningQPDF() const | 3026 | QPDFObjectHandle::getOwningQPDF() const |
| 3027 | { | 3027 | { |
| 3028 | - return isInitialized() ? this->obj->getQPDF() : nullptr; | 3028 | + return obj ? obj->getQPDF() : nullptr; |
| 3029 | } | 3029 | } |
| 3030 | 3030 | ||
| 3031 | QPDF& | 3031 | QPDF& |
| 3032 | QPDFObjectHandle::getQPDF(std::string const& error_msg) const | 3032 | QPDFObjectHandle::getQPDF(std::string const& error_msg) const |
| 3033 | { | 3033 | { |
| 3034 | - auto result = isInitialized() ? this->obj->getQPDF() : nullptr; | ||
| 3035 | - if (result == nullptr) { | ||
| 3036 | - throw std::runtime_error( | ||
| 3037 | - error_msg.empty() ? "attempt to use a null qpdf object" : error_msg); | 3034 | + if (auto result = obj ? obj->getQPDF() : nullptr) { |
| 3035 | + return *result; | ||
| 3038 | } | 3036 | } |
| 3039 | - return *result; | 3037 | + throw std::runtime_error(error_msg.empty() ? "attempt to use a null qpdf object" : error_msg); |
| 3040 | } | 3038 | } |
| 3041 | 3039 | ||
| 3042 | void | 3040 | void |
| 3043 | QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset) | 3041 | QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset) |
| 3044 | { | 3042 | { |
| 3045 | - // This is called during parsing on newly created direct objects, | ||
| 3046 | - // so we can't call dereference() here. | ||
| 3047 | - if (isInitialized()) { | ||
| 3048 | - this->obj->setParsedOffset(offset); | 3043 | + if (obj) { |
| 3044 | + obj->setParsedOffset(offset); | ||
| 3049 | } | 3045 | } |
| 3050 | } | 3046 | } |
| 3051 | 3047 |
libqpdf/QPDFOutlineDocumentHelper.cc
| @@ -67,7 +67,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) | @@ -67,7 +67,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) | ||
| 67 | { | 67 | { |
| 68 | QPDFObjectHandle result; | 68 | QPDFObjectHandle result; |
| 69 | if (name.isName()) { | 69 | if (name.isName()) { |
| 70 | - if (!m->dest_dict.isInitialized()) { | 70 | + if (!m->dest_dict) { |
| 71 | m->dest_dict = qpdf.getRoot().getKey("/Dests"); | 71 | m->dest_dict = qpdf.getRoot().getKey("/Dests"); |
| 72 | } | 72 | } |
| 73 | QTC::TC("qpdf", "QPDFOutlineDocumentHelper name named dest"); | 73 | QTC::TC("qpdf", "QPDFOutlineDocumentHelper name named dest"); |
| @@ -85,7 +85,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) | @@ -85,7 +85,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) | ||
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | - if (!result.isInitialized()) { | 88 | + if (!result) { |
| 89 | return QPDFObjectHandle::newNull(); | 89 | return QPDFObjectHandle::newNull(); |
| 90 | } | 90 | } |
| 91 | if (result.isDictionary()) { | 91 | if (result.isDictionary()) { |
libqpdf/QPDFOutlineObjectHelper.cc
| @@ -59,8 +59,8 @@ QPDFOutlineObjectHelper::getDest() | @@ -59,8 +59,8 @@ QPDFOutlineObjectHelper::getDest() | ||
| 59 | QTC::TC("qpdf", "QPDFOutlineObjectHelper action dest"); | 59 | QTC::TC("qpdf", "QPDFOutlineObjectHelper action dest"); |
| 60 | dest = A.getKey("/D"); | 60 | dest = A.getKey("/D"); |
| 61 | } | 61 | } |
| 62 | - if (!dest.isInitialized()) { | ||
| 63 | - dest = QPDFObjectHandle::newNull(); | 62 | + if (!dest) { |
| 63 | + return QPDFObjectHandle::newNull(); | ||
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | if (dest.isName() || dest.isString()) { | 66 | if (dest.isName() || dest.isString()) { |
libqpdf/QPDFWriter.cc
| @@ -1381,7 +1381,7 @@ QPDFWriter::unparseObject( | @@ -1381,7 +1381,7 @@ QPDFWriter::unparseObject( | ||
| 1381 | } | 1381 | } |
| 1382 | } | 1382 | } |
| 1383 | 1383 | ||
| 1384 | - if (extensions.isInitialized()) { | 1384 | + if (extensions) { |
| 1385 | std::set<std::string> keys = extensions.getKeys(); | 1385 | std::set<std::string> keys = extensions.getKeys(); |
| 1386 | if (keys.count("/ADBE") > 0) { | 1386 | if (keys.count("/ADBE") > 0) { |
| 1387 | have_extensions_adbe = true; | 1387 | have_extensions_adbe = true; |
| @@ -1412,7 +1412,7 @@ QPDFWriter::unparseObject( | @@ -1412,7 +1412,7 @@ QPDFWriter::unparseObject( | ||
| 1412 | } | 1412 | } |
| 1413 | } | 1413 | } |
| 1414 | 1414 | ||
| 1415 | - if (extensions.isInitialized()) { | 1415 | + if (extensions) { |
| 1416 | QTC::TC("qpdf", "QPDFWriter preserve Extensions"); | 1416 | QTC::TC("qpdf", "QPDFWriter preserve Extensions"); |
| 1417 | QPDFObjectHandle adbe = extensions.getKey("/ADBE"); | 1417 | QPDFObjectHandle adbe = extensions.getKey("/ADBE"); |
| 1418 | if (adbe.isDictionary() && | 1418 | if (adbe.isDictionary() && |
libqpdf/QPDF_Stream.cc
| @@ -661,18 +661,17 @@ void | @@ -661,18 +661,17 @@ void | ||
| 661 | QPDF_Stream::replaceFilterData( | 661 | QPDF_Stream::replaceFilterData( |
| 662 | QPDFObjectHandle const& filter, QPDFObjectHandle const& decode_parms, size_t length) | 662 | QPDFObjectHandle const& filter, QPDFObjectHandle const& decode_parms, size_t length) |
| 663 | { | 663 | { |
| 664 | - if (filter.isInitialized()) { | ||
| 665 | - this->stream_dict.replaceKey("/Filter", filter); | 664 | + if (filter) { |
| 665 | + stream_dict.replaceKey("/Filter", filter); | ||
| 666 | } | 666 | } |
| 667 | - if (decode_parms.isInitialized()) { | ||
| 668 | - this->stream_dict.replaceKey("/DecodeParms", decode_parms); | 667 | + if (decode_parms) { |
| 668 | + stream_dict.replaceKey("/DecodeParms", decode_parms); | ||
| 669 | } | 669 | } |
| 670 | if (length == 0) { | 670 | if (length == 0) { |
| 671 | QTC::TC("qpdf", "QPDF_Stream unknown stream length"); | 671 | QTC::TC("qpdf", "QPDF_Stream unknown stream length"); |
| 672 | - this->stream_dict.removeKey("/Length"); | 672 | + stream_dict.removeKey("/Length"); |
| 673 | } else { | 673 | } else { |
| 674 | - this->stream_dict.replaceKey( | ||
| 675 | - "/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(length))); | 674 | + stream_dict.replaceKey("/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(length))); |
| 676 | } | 675 | } |
| 677 | } | 676 | } |
| 678 | 677 |
libqpdf/QPDF_json.cc
| @@ -325,7 +325,7 @@ QPDF::JSONReactor::anyErrors() const | @@ -325,7 +325,7 @@ QPDF::JSONReactor::anyErrors() const | ||
| 325 | void | 325 | void |
| 326 | QPDF::JSONReactor::containerStart() | 326 | QPDF::JSONReactor::containerStart() |
| 327 | { | 327 | { |
| 328 | - if (next_obj.isInitialized()) { | 328 | + if (next_obj) { |
| 329 | stack.emplace_back(next_state, std::move(next_obj)); | 329 | stack.emplace_back(next_state, std::move(next_obj)); |
| 330 | next_obj = QPDFObjectHandle(); | 330 | next_obj = QPDFObjectHandle(); |
| 331 | } else { | 331 | } else { |
| @@ -558,7 +558,7 @@ QPDF::JSONReactor::dictionaryItem(std::string const& key, JSON const& value) | @@ -558,7 +558,7 @@ QPDF::JSONReactor::dictionaryItem(std::string const& key, JSON const& value) | ||
| 558 | throw std::logic_error("stack empty in st_object_top"); | 558 | throw std::logic_error("stack empty in st_object_top"); |
| 559 | } | 559 | } |
| 560 | auto& tos = stack.back(); | 560 | auto& tos = stack.back(); |
| 561 | - if (!tos.object.isInitialized()) { | 561 | + if (!tos.object) { |
| 562 | throw std::logic_error("current object uninitialized in st_object_top"); | 562 | throw std::logic_error("current object uninitialized in st_object_top"); |
| 563 | } | 563 | } |
| 564 | if (key == "value") { | 564 | if (key == "value") { |
| @@ -767,7 +767,7 @@ QPDF::JSONReactor::makeObject(JSON const& value) | @@ -767,7 +767,7 @@ QPDF::JSONReactor::makeObject(JSON const& value) | ||
| 767 | result = QPDFObjectHandle::newNull(); | 767 | result = QPDFObjectHandle::newNull(); |
| 768 | } | 768 | } |
| 769 | } | 769 | } |
| 770 | - if (!result.isInitialized()) { | 770 | + if (!result) { |
| 771 | throw std::logic_error("JSONReactor::makeObject didn't initialize the object"); | 771 | throw std::logic_error("JSONReactor::makeObject didn't initialize the object"); |
| 772 | } | 772 | } |
| 773 | 773 |
libqpdf/qpdf-c.cc
| @@ -955,7 +955,7 @@ qpdf_oh_is_initialized(qpdf_data qpdf, qpdf_oh oh) | @@ -955,7 +955,7 @@ qpdf_oh_is_initialized(qpdf_data qpdf, qpdf_oh oh) | ||
| 955 | { | 955 | { |
| 956 | QTC::TC("qpdf", "qpdf-c called qpdf_oh_is_initialized"); | 956 | QTC::TC("qpdf", "qpdf-c called qpdf_oh_is_initialized"); |
| 957 | return do_with_oh<QPDF_BOOL>( | 957 | return do_with_oh<QPDF_BOOL>( |
| 958 | - qpdf, oh, return_false, [](QPDFObjectHandle& o) { return o.isInitialized(); }); | 958 | + qpdf, oh, return_false, [](QPDFObjectHandle& o) { return static_cast<bool>(o); }); |
| 959 | } | 959 | } |
| 960 | 960 | ||
| 961 | QPDF_BOOL | 961 | QPDF_BOOL |
qpdf/test_driver.cc
| @@ -1428,7 +1428,7 @@ test_42(QPDF& pdf, char const* arg2) | @@ -1428,7 +1428,7 @@ test_42(QPDF& pdf, char const* arg2) | ||
| 1428 | assert(i == ai.end()); | 1428 | assert(i == ai.end()); |
| 1429 | ++i; | 1429 | ++i; |
| 1430 | assert(i == ai.end()); | 1430 | assert(i == ai.end()); |
| 1431 | - assert(!i_value.isInitialized()); | 1431 | + assert(!i_value); |
| 1432 | --i; | 1432 | --i; |
| 1433 | assert(i_value.getName() == "/Item2"); | 1433 | assert(i_value.getName() == "/Item2"); |
| 1434 | assert(i->getName() == "/Item2"); | 1434 | assert(i->getName() == "/Item2"); |
| @@ -1444,7 +1444,7 @@ test_42(QPDF& pdf, char const* arg2) | @@ -1444,7 +1444,7 @@ test_42(QPDF& pdf, char const* arg2) | ||
| 1444 | ++i; | 1444 | ++i; |
| 1445 | ++i; | 1445 | ++i; |
| 1446 | assert(i == di.end()); | 1446 | assert(i == di.end()); |
| 1447 | - assert(!i_value.second.isInitialized()); | 1447 | + assert(!i_value.second); |
| 1448 | } | 1448 | } |
| 1449 | assert("" == qtest.getStringValue()); | 1449 | assert("" == qtest.getStringValue()); |
| 1450 | array.getArrayItem(-1).assertNull(); | 1450 | array.getArrayItem(-1).assertNull(); |
| @@ -1542,7 +1542,7 @@ test_42(QPDF& pdf, char const* arg2) | @@ -1542,7 +1542,7 @@ test_42(QPDF& pdf, char const* arg2) | ||
| 1542 | assert(m1.a == 0 && m1.b == 0 && m1.c == 0 && m1.d == 0 && m1.e == 0 && m1.f == 0); | 1542 | assert(m1.a == 0 && m1.b == 0 && m1.c == 0 && m1.d == 0 && m1.e == 0 && m1.f == 0); |
| 1543 | // Uninitialized | 1543 | // Uninitialized |
| 1544 | QPDFObjectHandle uninitialized; | 1544 | QPDFObjectHandle uninitialized; |
| 1545 | - assert(!uninitialized.isInitialized()); | 1545 | + assert(!uninitialized); |
| 1546 | assert(!uninitialized.isInteger()); | 1546 | assert(!uninitialized.isInteger()); |
| 1547 | assert(!uninitialized.isDictionary()); | 1547 | assert(!uninitialized.isDictionary()); |
| 1548 | assert(!uninitialized.isScalar()); | 1548 | assert(!uninitialized.isScalar()); |
| @@ -1692,7 +1692,7 @@ test_46(QPDF& pdf, char const* arg2) | @@ -1692,7 +1692,7 @@ test_46(QPDF& pdf, char const* arg2) | ||
| 1692 | assert(iter1_val.first == 2); | 1692 | assert(iter1_val.first == 2); |
| 1693 | ++iter1; | 1693 | ++iter1; |
| 1694 | assert(iter1 == new1.end()); | 1694 | assert(iter1 == new1.end()); |
| 1695 | - assert(!iter1_val.second.isInitialized()); | 1695 | + assert(!iter1_val.second); |
| 1696 | ++iter1; | 1696 | ++iter1; |
| 1697 | assert(iter1->first == 1); | 1697 | assert(iter1->first == 1); |
| 1698 | --iter1; | 1698 | --iter1; |
| @@ -1842,7 +1842,7 @@ test_48(QPDF& pdf, char const* arg2) | @@ -1842,7 +1842,7 @@ test_48(QPDF& pdf, char const* arg2) | ||
| 1842 | assert(iter1_val.first == "2"); | 1842 | assert(iter1_val.first == "2"); |
| 1843 | ++iter1; | 1843 | ++iter1; |
| 1844 | assert(iter1 == new1.end()); | 1844 | assert(iter1 == new1.end()); |
| 1845 | - assert(!iter1_val.second.isInitialized()); | 1845 | + assert(!iter1_val.second); |
| 1846 | ++iter1; | 1846 | ++iter1; |
| 1847 | assert(iter1->first == "1"); | 1847 | assert(iter1->first == "1"); |
| 1848 | --iter1; | 1848 | --iter1; |