diff --git a/samples/tiff-test.cpp b/samples/tiff-test.cpp index acd8e3dc..7b02d4b0 100644 --- a/samples/tiff-test.cpp +++ b/samples/tiff-test.cpp @@ -61,7 +61,7 @@ void mini1(const char* path) { enforce(wm == wmIntrusive, Exiv2::ErrorCode::kerErrorMessage, "encode returned an unexpected value"); std::cout << "Test 3: Wrote non-empty Exif data without original binary data:\n"; exifData.clear(); - ByteOrder bo = ExifParser::decode(exifData, &blob[0], blob.size()); + ByteOrder bo = ExifParser::decode(exifData, blob.data(), blob.size()); enforce(bo == bigEndian, Exiv2::ErrorCode::kerErrorMessage, "decode returned an unexpected value"); print(exifData); } diff --git a/src/crwimage.cpp b/src/crwimage.cpp index d9686ea4..2a79e560 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -93,7 +93,7 @@ void CrwImage::writeMetadata() { // Write new buffer to file MemIo tempIo; - tempIo.write((!blob.empty() ? &blob[0] : nullptr), blob.size()); + tempIo.write((!blob.empty() ? blob.data() : nullptr), blob.size()); io_->close(); io_->transfer(tempIo); // may throw diff --git a/src/image.cpp b/src/image.cpp index ed6c090c..208fe9c2 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -425,10 +425,10 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct io.seekOrThrow(offset, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // position std::vector bytes(count); // allocate memory // TODO: once we have C++11 use bytes.data() - io.readOrThrow(&bytes[0], count, ErrorCode::kerCorruptedMetadata); + io.readOrThrow(bytes.data(), count, ErrorCode::kerCorruptedMetadata); io.seekOrThrow(restore, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // TODO: once we have C++11 use bytes.data() - IptcData::printStructure(out, makeSliceUntil(&bytes[0], count), depth); + IptcData::printStructure(out, makeSliceUntil(bytes.data(), count), depth); } } else if (option == kpsRecursive && tag == 0x927c /* MakerNote */ && count > 10) { const long restore = io.tell(); // save diff --git a/src/image_int.cpp b/src/image_int.cpp index df6420c3..51dc6722 100644 --- a/src/image_int.cpp +++ b/src/image_int.cpp @@ -24,14 +24,14 @@ std::string stringFormat(const char* format, ...) { buffer.resize(need + 1); va_list args; // variable arg list va_start(args, format); // args start after format - rc = vsnprintf(&buffer[0], buffer.size(), format, args); + rc = vsnprintf(buffer.data(), buffer.size(), format, args); va_end(args); // free the args if (rc > 0) need = static_cast(rc); } while (buffer.size() <= need); if (rc > 0) - result = std::string(&buffer[0], need); + result = std::string(buffer.data(), need); return result; } diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index ae726253..da9c32b0 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -188,7 +188,7 @@ void JpegBase::readMetadata() { append(psBlob, buf.c_data(16), size - 16); } // Check whether psBlob is complete - if (!psBlob.empty() && Photoshop::valid(&psBlob[0], psBlob.size())) { + if (!psBlob.empty() && Photoshop::valid(psBlob.data(), psBlob.size())) { --search; foundCompletePsData = true; } @@ -263,7 +263,7 @@ void JpegBase::readMetadata() { const byte* record = nullptr; uint32_t sizeIptc = 0; uint32_t sizeHdr = 0; - const byte* pCur = &psBlob[0]; + const byte* pCur = psBlob.data(); const byte* pEnd = pCur + psBlob.size(); while (pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, pEnd - pCur, &record, sizeHdr, sizeIptc)) { #ifdef EXIV2_DEBUG_MESSAGES @@ -274,7 +274,7 @@ void JpegBase::readMetadata() { } pCur = record + sizeHdr + sizeIptc + (sizeIptc & 1); } - if (!iptcBlob.empty() && IptcParser::decode(iptcData_, &iptcBlob[0], iptcBlob.size())) { + if (!iptcBlob.empty() && IptcParser::decode(iptcData_, iptcBlob.data(), iptcBlob.size())) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode IPTC metadata.\n"; #endif @@ -680,7 +680,7 @@ void JpegBase::doWriteMetadata(BasicIo& outIo) { // Append to psBlob append(psBlob, buf.c_data(16), buf.size() - 16); // Check whether psBlob is complete - if (!psBlob.empty() && Photoshop::valid(&psBlob[0], psBlob.size())) { + if (!psBlob.empty() && Photoshop::valid(psBlob.data(), psBlob.size())) { foundCompletePsData = true; } } else if (marker == com_ && skipCom == notfound) { @@ -750,7 +750,7 @@ void JpegBase::doWriteMetadata(BasicIo& outIo) { size_t exifSize = rawExif.size(); WriteMethod wm = ExifParser::encode(blob, pExifData, exifSize, bo, exifData_); if (wm == wmIntrusive) { - pExifData = !blob.empty() ? &blob[0] : nullptr; + pExifData = !blob.empty() ? blob.data() : nullptr; exifSize = blob.size(); } if (exifSize > 0) { diff --git a/src/photoshop.cpp b/src/photoshop.cpp index 526f2ea0..043a6eb0 100644 --- a/src/photoshop.cpp +++ b/src/photoshop.cpp @@ -170,7 +170,7 @@ DataBuf Photoshop::setIptcIrb(const byte* pPsData, size_t sizePsData, const Iptc // Data is rounded to be even if (!psBlob.empty()) - rc = DataBuf(&psBlob[0], psBlob.size()); + rc = DataBuf(psBlob.data(), psBlob.size()); #ifdef EXIV2_DEBUG_MESSAGES std::cerr << "IRB block at the end of Photoshop::setIptcIrb\n"; if (rc.empty()) diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index a046ebe0..53ae8093 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -246,7 +246,7 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize, pCur = record + sizeHdr + sizeIptc; pCur += (sizeIptc & 1); } - if (!iptcBlob.empty() && IptcParser::decode(pImage->iptcData(), &iptcBlob[0], iptcBlob.size())) { + if (!iptcBlob.empty() && IptcParser::decode(pImage->iptcData(), iptcBlob.data(), iptcBlob.size())) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode IPTC metadata.\n"; #endif diff --git a/src/pngimage.cpp b/src/pngimage.cpp index df4b1ec1..75d509e2 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -572,7 +572,7 @@ void PngImage::doWriteMetadata(BasicIo& outIo) { if (!blob.empty()) { static const char exifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; std::string rawExif = - std::string(exifHeader, 6) + std::string(reinterpret_cast(&blob[0]), blob.size()); + std::string(exifHeader, 6) + std::string(reinterpret_cast(blob.data()), blob.size()); std::string chunk = PngChunk::makeMetadataChunk(rawExif, mdExif); if (outIo.write(reinterpret_cast(chunk.data()), chunk.size()) != chunk.size()) { throw Error(ErrorCode::kerImageWriteFailed); diff --git a/src/psdimage.cpp b/src/psdimage.cpp index 7e5d7b65..94ac7788 100644 --- a/src/psdimage.cpp +++ b/src/psdimage.cpp @@ -610,7 +610,7 @@ uint32_t PsdImage::writeExifData(const ExifData& exifData, BasicIo& out) { if (out.write(buf, 4) != 4) throw Error(ErrorCode::kerImageWriteFailed); // Write encoded Exif data - if (out.write(&blob[0], blob.size()) != blob.size()) + if (out.write(blob.data(), blob.size()) != blob.size()) throw Error(ErrorCode::kerImageWriteFailed); resLength += static_cast(blob.size()) + 12; if (blob.size() & 1) // even padding diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 82f6592c..b7a39ceb 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -557,7 +557,7 @@ void TiffEncoder::encodeXmp() { if (!xmpPacket.empty()) { // Set the XMP Exif tag to the new value auto value = Value::create(unsignedByte); - value->read(reinterpret_cast(&xmpPacket[0]), xmpPacket.size(), invalidByteOrder); + value->read(reinterpret_cast(xmpPacket.data()), xmpPacket.size(), invalidByteOrder); Exifdatum xmpDatum(xmpKey, value.get()); exifData_.add(xmpDatum); } diff --git a/src/value.cpp b/src/value.cpp index 5af114b0..526c57e7 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -490,7 +490,7 @@ size_t XmpValue::copy(byte* buf, ByteOrder /*byteOrder*/) const { write(os); std::string s = os.str(); if (!s.empty()) - std::memcpy(buf, &s[0], s.size()); + std::memcpy(buf, s.data(), s.size()); return s.size(); } diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 3ed1dbaa..c1806c78 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -377,7 +377,7 @@ void WebPImage::doWriteMetadata(BasicIo& outIo) { ul2Data(data, static_cast(blob.size()), littleEndian); if (outIo.write(data, WEBP_TAG_SIZE) != WEBP_TAG_SIZE) throw Error(ErrorCode::kerImageWriteFailed); - if (outIo.write(&blob[0], blob.size()) != blob.size()) { + if (outIo.write(blob.data(), blob.size()) != blob.size()) { throw Error(ErrorCode::kerImageWriteFailed); } if (outIo.tell() % 2) {