diff --git a/samples/Jzon.cpp b/samples/Jzon.cpp index 52861f3d..39b4e8cc 100644 --- a/samples/Jzon.cpp +++ b/samples/Jzon.cpp @@ -483,28 +483,28 @@ namespace Jzon Object::iterator Object::begin() { if (!children.empty()) - return Object::iterator(&children.front()); - return Object::iterator(nullptr); + return {&children.front()}; + return {nullptr}; } Object::const_iterator Object::begin() const { if (!children.empty()) - return Object::const_iterator(&children.front()); - return Object::const_iterator(nullptr); + return {&children.front()}; + return {nullptr}; } Object::iterator Object::end() { if (!children.empty()) - return Object::iterator(&children.back() + 1); - return Object::iterator(nullptr); + return {&children.back() + 1}; + return {nullptr}; } Object::const_iterator Object::end() const { if (!children.empty()) - return Object::const_iterator(&children.back() + 1); - return Object::const_iterator(nullptr); + return {&children.back() + 1}; + return {nullptr}; } bool Object::Has(const std::string &name) const @@ -586,26 +586,26 @@ namespace Jzon Array::iterator Array::begin() { if (!children.empty()) - return Array::iterator(&children.front()); - return Array::iterator(nullptr); + return {&children.front()}; + return {nullptr}; } Array::const_iterator Array::begin() const { if (!children.empty()) - return Array::const_iterator(&children.front()); - return Array::const_iterator(nullptr); + return {&children.front()}; + return {nullptr}; } Array::iterator Array::end() { if (!children.empty()) - return Array::iterator(&children.back() + 1); - return Array::iterator(nullptr); + return {&children.back() + 1}; + return {nullptr}; } Array::const_iterator Array::end() const { if (!children.empty()) - return Array::const_iterator(&children.back() + 1); - return Array::const_iterator(nullptr); + return {&children.back() + 1}; + return {nullptr}; } size_t Array::GetCount() const diff --git a/src/exif.cpp b/src/exif.cpp index 874386bd..651911da 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -427,7 +427,7 @@ namespace Exiv2 { { auto thumbnail = Thumbnail::create(exifData_); if (!thumbnail) - return DataBuf(); + return {}; return thumbnail->copy(exifData_); } @@ -844,7 +844,8 @@ namespace { { Exiv2::ExifKey key("Exif.Thumbnail.JPEGInterchangeFormat"); auto format = exifData.findKey(key); - if (format == exifData.end()) return Exiv2::DataBuf(); + if (format == exifData.end()) + return {}; return format->dataArea(); } diff --git a/src/image.cpp b/src/image.cpp index c7ea45d5..470769d4 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -910,7 +910,7 @@ namespace Exiv2 { const Registry* r = find(registry, type); if (r == nullptr || type == ImageType::none) { - return Image::UniquePtr(); + return {}; } return r->newInstance_(std::move(io), true); diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 1a166068..e74004b8 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -91,7 +91,7 @@ namespace Exiv2 if (it == data.cend()) throw Error(kerFailedToReadImageData); - return DataBuf(data.c_data() + offset, std::distance(data.cbegin(), it)- offset); + return {data.c_data() + offset, std::distance(data.cbegin(), it) - offset}; } DataBuf PngChunk::parseTXTChunk(const DataBuf& data, size_t keysize, TxtChunkType type) @@ -507,7 +507,7 @@ namespace Exiv2 DataBuf PngChunk::readRawProfile(const DataBuf& text, bool iTXt) { if (text.size() <= 1) { - return DataBuf(); + return {}; } DataBuf info; @@ -527,26 +527,26 @@ namespace Exiv2 const char* eot = text.c_str(text.size()-1); // end of text if (sp >= eot) { - return DataBuf(); + return {}; } // Look for newline while (*sp != '\n') { sp++; if (sp == eot) { - return DataBuf(); + return {}; } } sp++; // step over '\n' if (sp == eot) { - return DataBuf(); + return {}; } // Look for length while (*sp == '\0' || *sp == ' ' || *sp == '\n') { sp++; if (sp == eot) { - return DataBuf(); + return {}; } } @@ -556,17 +556,17 @@ namespace Exiv2 // Compute the new length using unsigned long, so that we can check for overflow. const size_t newlength = (10 * length) + (*sp - '0'); if (newlength > std::numeric_limits::max()) { - return DataBuf(); // Integer overflow. + return {}; // Integer overflow. } length = newlength; sp++; if (sp == eot) { - return DataBuf(); + return {}; } } sp++; // step over '\n' if (sp == eot) { - return DataBuf(); + return {}; } enforce(length <= static_cast(eot - sp) / 2, Exiv2::kerCorruptedMetadata); @@ -582,7 +582,7 @@ namespace Exiv2 #ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: cannot allocate memory\n"; #endif - return DataBuf(); + return {}; } // Copy profile, skipping white space and column 1 "=" signs @@ -597,7 +597,7 @@ namespace Exiv2 #ifdef EXIV2_DEBUG_MESSAGES std::cerr << "Exiv2::PngChunk::readRawProfile: Unable To Copy Raw Profile: ran out of data\n"; #endif - return DataBuf(); + return {}; } sp++; diff --git a/src/preview.cpp b/src/preview.cpp index c771494c..9f62f54a 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -438,7 +438,8 @@ namespace { DataBuf LoaderNative::getData() const { - if (!valid()) return DataBuf(); + if (!valid()) + return {}; BasicIo &io = image_.io(); if (io.open() != 0) { @@ -450,10 +451,10 @@ namespace { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Invalid native preview position or size.\n"; #endif - return DataBuf(); + return {}; } if (nativePreview_.filter_.empty()) { - return DataBuf(data + nativePreview_.position_, static_cast(nativePreview_.size_)); + return {data + nativePreview_.position_, nativePreview_.size_}; } if (nativePreview_.filter_ == "hex-ai7thumbnail-pnm") { const DataBuf ai7thumbnail = decodeHex(data + nativePreview_.position_, static_cast(nativePreview_.size_)); @@ -469,9 +470,9 @@ namespace { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Missing preview IRB in Photoshop EPS preview.\n"; #endif - return DataBuf(); + return {}; } - return DataBuf(record + sizeHdr + 28, sizeData - 28); + return {record + sizeHdr + 28, sizeData - 28}; } throw Error(kerErrorMessage, "Invalid native preview filter: " + nativePreview_.filter_); } @@ -548,7 +549,8 @@ namespace { DataBuf LoaderExifJpeg::getData() const { - if (!valid()) return DataBuf(); + if (!valid()) + return {}; BasicIo &io = image_.io(); if (io.open() != 0) { @@ -558,7 +560,7 @@ namespace { const Exiv2::byte* base = io.mmap(); - return DataBuf(base + offset_, size_); + return {base + offset_, size_}; } bool LoaderExifJpeg::readDimensions() @@ -625,7 +627,8 @@ namespace { DataBuf LoaderExifDataJpeg::getData() const { - if (!valid()) return DataBuf(); + if (!valid()) + return {}; auto pos = image_.exifData().findKey(dataKey_); if (pos != image_.exifData().end()) { @@ -640,7 +643,7 @@ namespace { return buf; } - return DataBuf(); + return {}; } bool LoaderExifDataJpeg::readDimensions() @@ -823,7 +826,7 @@ namespace { IptcData emptyIptc; XmpData emptyXmp; TiffParser::encode(mio, nullptr, 0, Exiv2::littleEndian, preview, emptyIptc, emptyXmp); - return DataBuf(mio.mmap(), static_cast(mio.size())); + return {mio.mmap(), mio.size()}; } LoaderXmpJpeg::LoaderXmpJpeg(PreviewId id, const Image &image, int parIdx) @@ -877,8 +880,8 @@ namespace { DataBuf LoaderXmpJpeg::getData() const { if (!valid()) - return DataBuf(); - return DataBuf(preview_.c_data(), preview_.size()); + return {}; + return {preview_.c_data(), preview_.size()}; } bool LoaderXmpJpeg::readDimensions() @@ -940,12 +943,12 @@ namespace { validSrcSize++; } if (validSrcSize > ULONG_MAX / 3) - return DataBuf(); // avoid integer overflow + return {}; // avoid integer overflow const unsigned long destSize = (validSrcSize * 3) / 4; // allocate dest buffer if (destSize > LONG_MAX) - return DataBuf(); // avoid integer overflow + return {}; // avoid integer overflow DataBuf dest(static_cast(destSize)); // decode @@ -972,7 +975,7 @@ namespace { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Invalid size of AI7 thumbnail: " << src.size() << "\n"; #endif - return DataBuf(); + return {}; } const byte *imageData = src.c_data(colorTableSize); const long imageDataSize = static_cast(src.size()) - colorTableSize; @@ -986,7 +989,7 @@ namespace { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Unexpected end of image data at AI7 thumbnail.\n"; #endif - return DataBuf(); + return {}; } value = imageData[i++]; if (value != 0xFD) { @@ -994,7 +997,7 @@ namespace { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Unexpected end of image data at AI7 thumbnail.\n"; #endif - return DataBuf(); + return {}; } num = value; value = imageData[i++]; @@ -1004,7 +1007,7 @@ namespace { dest.append(reinterpret_cast(colorTable + (3*value)), 3); } } - return DataBuf(reinterpret_cast(dest.data()), static_cast(dest.size())); + return {reinterpret_cast(dest.data()), dest.size()}; } DataBuf makePnm(uint32_t width, uint32_t height, const DataBuf &rgb) @@ -1014,7 +1017,7 @@ namespace { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Invalid size of preview data. Expected " << expectedSize << " bytes, got " << rgb.size() << " bytes.\n"; #endif - return DataBuf(); + return {}; } const std::string header = "P6\n" + toString(width) + " " + toString(height) + "\n255\n"; @@ -1058,7 +1061,7 @@ namespace Exiv2 { DataBuf PreviewImage::copy() const { - return DataBuf(pData(), size()); + return {pData(), size()}; } const byte* PreviewImage::pData() const diff --git a/src/rw2image_int.cpp b/src/rw2image_int.cpp index 124bbe34..6f16227b 100644 --- a/src/rw2image_int.cpp +++ b/src/rw2image_int.cpp @@ -13,7 +13,7 @@ namespace Exiv2 { DataBuf Rw2Header::write() const { // Todo: Implement me! - return DataBuf(); + return {}; } } // namespace Internal diff --git a/src/value.cpp b/src/value.cpp index 30a816c2..f28e21d3 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -125,7 +125,7 @@ namespace Exiv2 { DataBuf Value::dataArea() const { - return DataBuf(nullptr, 0); + return {nullptr, 0}; } DataValue::DataValue(TypeId typeId)