diff options
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 113 |
1 files changed, 51 insertions, 62 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index fa5e52e8..3ce748b0 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -49,7 +49,7 @@ QPDFObjectHandle::StreamDataProvider::StreamDataProvider(bool supports_retry) : { } -QPDFObjectHandle::StreamDataProvider::~StreamDataProvider() +QPDFObjectHandle::StreamDataProvider::~StreamDataProvider() // NOLINT (modernize-use-equals-default) { // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer } @@ -189,13 +189,12 @@ namespace unsigned char getLastChar(); private: - unsigned char last_char; + unsigned char last_char{0}; }; } // namespace LastChar::LastChar(Pipeline* next) : - Pipeline("lastchar", next), - last_char(0) + Pipeline("lastchar", next) { } @@ -229,11 +228,9 @@ QPDFObjectHandle::isSameObjectAs(QPDFObjectHandle const& rhs) const void QPDFObjectHandle::disconnect() { - // Recursively remove association with any QPDF object. This - // method may only be called during final destruction. - // QPDF::~QPDF() calls it for indirect objects using the object - // pointer itself, so we don't do that here. Other objects call it - // through this method. + // Recursively remove association with any QPDF object. This method may only be called during + // final destruction. QPDF::~QPDF() calls it for indirect objects using the object pointer + // itself, so we don't do that here. Other objects call it through this method. if (!isIndirect()) { this->obj->disconnect(); } @@ -754,7 +751,7 @@ QPDFObjectHandle::getValueAsInlineImage(std::string& value) QPDFObjectHandle::QPDFArrayItems QPDFObjectHandle::aitems() { - return QPDFArrayItems(*this); + return *this; } int @@ -828,11 +825,11 @@ QPDFObjectHandle::getArrayAsRectangle() return {}; } } - return Rectangle( + return { std::min(items[0], items[2]), std::min(items[1], items[3]), std::max(items[0], items[2]), - std::max(items[1], items[3])); + std::max(items[1], items[3])}; } return {}; } @@ -850,7 +847,7 @@ QPDFObjectHandle::getArrayAsMatrix() return {}; } } - return Matrix(items[0], items[1], items[2], items[3], items[4], items[5]); + return {items[0], items[1], items[2], items[3], items[4], items[5]}; } return {}; } @@ -961,7 +958,7 @@ QPDFObjectHandle::eraseItemAndGetOld(int at) QPDFObjectHandle::QPDFDictItems QPDFObjectHandle::ditems() { - return QPDFDictItems(*this); + return {*this}; } bool @@ -1051,7 +1048,7 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF& owning_qpdf) if (!sub.isDictionary()) { continue; } - for (auto i2: sub.ditems()) { + for (auto const& i2: sub.ditems()) { std::string const& key = i2.first; QPDFObjectHandle val = i2.second; if (!val.isIndirect()) { @@ -1072,7 +1069,7 @@ QPDFObjectHandle::mergeResources( auto make_og_to_name = [](QPDFObjectHandle& dict, std::map<QPDFObjGen, std::string>& og_to_name) { - for (auto i: dict.ditems()) { + for (auto const& i: dict.ditems()) { if (i.second.isIndirect()) { og_to_name[i.second.getObjGen()] = i.first; } @@ -1081,7 +1078,7 @@ QPDFObjectHandle::mergeResources( // This algorithm is described in comments in QPDFObjectHandle.hh // above the declaration of mergeResources. - for (auto o_top: other.ditems()) { + for (auto const& o_top: other.ditems()) { std::string const& rtype = o_top.first; QPDFObjectHandle other_val = o_top.second; if (hasKey(rtype)) { @@ -1098,7 +1095,7 @@ QPDFObjectHandle::mergeResources( std::set<std::string> rnames; int min_suffix = 1; bool initialized_maps = false; - for (auto ov_iter: other_val.ditems()) { + for (auto const& ov_iter: other_val.ditems()) { std::string const& key = ov_iter.first; QPDFObjectHandle rval = ov_iter.second; if (!this_val.hasKey(key)) { @@ -1783,10 +1780,9 @@ QPDFObjectHandle::parseContentStream_data( tokenizer.allowEOF(); bool empty = false; while (QIntC::to_size(input->tell()) < stream_length) { - // Read a token and seek to the beginning. The offset we get - // from this process is the beginning of the next - // non-ignorable (space, comment) token. This way, the offset - // and don't including ignorable content. + // Read a token and seek to the beginning. The offset we get from this process is the + // beginning of the next non-ignorable (space, comment) token. This way, the offset and + // don't including ignorable content. tokenizer.readToken(input, "content", true); qpdf_offset_t offset = input->getLastOffset(); input->seek(offset, SEEK_SET); @@ -1865,61 +1861,61 @@ QPDFObjectHandle::getParsedOffset() QPDFObjectHandle QPDFObjectHandle::newBool(bool value) { - return QPDFObjectHandle(QPDF_Bool::create(value)); + return {QPDF_Bool::create(value)}; } QPDFObjectHandle QPDFObjectHandle::newNull() { - return QPDFObjectHandle(QPDF_Null::create()); + return {QPDF_Null::create()}; } QPDFObjectHandle QPDFObjectHandle::newInteger(long long value) { - return QPDFObjectHandle(QPDF_Integer::create(value)); + return {QPDF_Integer::create(value)}; } QPDFObjectHandle QPDFObjectHandle::newReal(std::string const& value) { - return QPDFObjectHandle(QPDF_Real::create(value)); + return {QPDF_Real::create(value)}; } QPDFObjectHandle QPDFObjectHandle::newReal(double value, int decimal_places, bool trim_trailing_zeroes) { - return QPDFObjectHandle(QPDF_Real::create(value, decimal_places, trim_trailing_zeroes)); + return {QPDF_Real::create(value, decimal_places, trim_trailing_zeroes)}; } QPDFObjectHandle QPDFObjectHandle::newName(std::string const& name) { - return QPDFObjectHandle(QPDF_Name::create(name)); + return {QPDF_Name::create(name)}; } QPDFObjectHandle QPDFObjectHandle::newString(std::string const& str) { - return QPDFObjectHandle(QPDF_String::create(str)); + return {QPDF_String::create(str)}; } QPDFObjectHandle QPDFObjectHandle::newUnicodeString(std::string const& utf8_str) { - return QPDFObjectHandle(QPDF_String::create_utf16(utf8_str)); + return {QPDF_String::create_utf16(utf8_str)}; } QPDFObjectHandle QPDFObjectHandle::newOperator(std::string const& value) { - return QPDFObjectHandle(QPDF_Operator::create(value)); + return {QPDF_Operator::create(value)}; } QPDFObjectHandle QPDFObjectHandle::newInlineImage(std::string const& value) { - return QPDFObjectHandle(QPDF_InlineImage::create(value)); + return {QPDF_InlineImage::create(value)}; } QPDFObjectHandle @@ -1931,44 +1927,37 @@ QPDFObjectHandle::newArray() QPDFObjectHandle QPDFObjectHandle::newArray(std::vector<QPDFObjectHandle> const& items) { - return QPDFObjectHandle(QPDF_Array::create(items)); + return {QPDF_Array::create(items)}; } QPDFObjectHandle QPDFObjectHandle::newArray(Rectangle const& rect) { - std::vector<QPDFObjectHandle> items; - items.push_back(newReal(rect.llx)); - items.push_back(newReal(rect.lly)); - items.push_back(newReal(rect.urx)); - items.push_back(newReal(rect.ury)); - return newArray(items); + return newArray({newReal(rect.llx), newReal(rect.lly), newReal(rect.urx), newReal(rect.ury)}); } QPDFObjectHandle QPDFObjectHandle::newArray(Matrix const& matrix) { - std::vector<QPDFObjectHandle> items; - items.push_back(newReal(matrix.a)); - items.push_back(newReal(matrix.b)); - items.push_back(newReal(matrix.c)); - items.push_back(newReal(matrix.d)); - items.push_back(newReal(matrix.e)); - items.push_back(newReal(matrix.f)); - return newArray(items); + return newArray( + {newReal(matrix.a), + newReal(matrix.b), + newReal(matrix.c), + newReal(matrix.d), + newReal(matrix.e), + newReal(matrix.f)}); } QPDFObjectHandle QPDFObjectHandle::newArray(QPDFMatrix const& matrix) { - std::vector<QPDFObjectHandle> items; - items.push_back(newReal(matrix.a)); - items.push_back(newReal(matrix.b)); - items.push_back(newReal(matrix.c)); - items.push_back(newReal(matrix.d)); - items.push_back(newReal(matrix.e)); - items.push_back(newReal(matrix.f)); - return newArray(items); + return newArray( + {newReal(matrix.a), + newReal(matrix.b), + newReal(matrix.c), + newReal(matrix.d), + newReal(matrix.e), + newReal(matrix.f)}); } QPDFObjectHandle @@ -1998,7 +1987,7 @@ QPDFObjectHandle::newDictionary() QPDFObjectHandle QPDFObjectHandle::newDictionary(std::map<std::string, QPDFObjectHandle> const& items) { - return QPDFObjectHandle(QPDF_Dictionary::create(items)); + return {QPDF_Dictionary::create(items)}; } QPDFObjectHandle @@ -2063,7 +2052,7 @@ QPDFObjectHandle::shallowCopy() if (!dereference()) { throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle"); } - return QPDFObjectHandle(obj->copy()); + return {obj->copy()}; } QPDFObjectHandle @@ -2072,7 +2061,7 @@ QPDFObjectHandle::unsafeShallowCopy() if (!dereference()) { throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle"); } - return QPDFObjectHandle(obj->copy(true)); + return {obj->copy(true)}; } void @@ -2474,13 +2463,13 @@ QPDFObjectHandle::QPDFDictItems::iterator::Members::Members(QPDFObjectHandle& oh QPDFObjectHandle::QPDFDictItems::iterator QPDFObjectHandle::QPDFDictItems::begin() { - return iterator(oh, true); + return {oh, true}; } QPDFObjectHandle::QPDFDictItems::iterator QPDFObjectHandle::QPDFDictItems::end() { - return iterator(oh, false); + return {oh, false}; } QPDFObjectHandle::QPDFArrayItems::QPDFArrayItems(QPDFObjectHandle const& oh) : @@ -2554,13 +2543,13 @@ QPDFObjectHandle::QPDFArrayItems::iterator::Members::Members(QPDFObjectHandle& o QPDFObjectHandle::QPDFArrayItems::iterator QPDFObjectHandle::QPDFArrayItems::begin() { - return iterator(oh, true); + return {oh, true}; } QPDFObjectHandle::QPDFArrayItems::iterator QPDFObjectHandle::QPDFArrayItems::end() { - return iterator(oh, false); + return {oh, false}; } QPDFObjGen |