clang-tidy: replace pointer magic with data()
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
93dc63b389
commit
b4c90b5e16
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -425,10 +425,10 @@ void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStruct
|
||||
io.seekOrThrow(offset, BasicIo::beg, ErrorCode::kerCorruptedMetadata); // position
|
||||
std::vector<byte> 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
|
||||
|
||||
@ -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<size_t>(rc);
|
||||
} while (buffer.size() <= need);
|
||||
|
||||
if (rc > 0)
|
||||
result = std::string(&buffer[0], need);
|
||||
result = std::string(buffer.data(), need);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<const char*>(&blob[0]), blob.size());
|
||||
std::string(exifHeader, 6) + std::string(reinterpret_cast<const char*>(blob.data()), blob.size());
|
||||
std::string chunk = PngChunk::makeMetadataChunk(rawExif, mdExif);
|
||||
if (outIo.write(reinterpret_cast<const byte*>(chunk.data()), chunk.size()) != chunk.size()) {
|
||||
throw Error(ErrorCode::kerImageWriteFailed);
|
||||
|
||||
@ -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<long>(blob.size()) + 12;
|
||||
if (blob.size() & 1) // even padding
|
||||
|
||||
@ -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<const byte*>(&xmpPacket[0]), xmpPacket.size(), invalidByteOrder);
|
||||
value->read(reinterpret_cast<const byte*>(xmpPacket.data()), xmpPacket.size(), invalidByteOrder);
|
||||
Exifdatum xmpDatum(xmpKey, value.get());
|
||||
exifData_.add(xmpDatum);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -377,7 +377,7 @@ void WebPImage::doWriteMetadata(BasicIo& outIo) {
|
||||
ul2Data(data, static_cast<uint32_t>(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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user