sonarlint cleanups

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 2 years ago
parent 25189ef1e6
commit 6fd143d6a4

@ -1794,10 +1794,8 @@ int metacopy(const std::string& source, const std::string& tgt, Exiv2::ImageType
// if we used a temporary target, copy it to stdout // if we used a temporary target, copy it to stdout
if (rc == 0 && bStdout) { if (rc == 0 && bStdout) {
FILE* f = ::fopen(target.c_str(), "rb");
_setmode(fileno(stdout), O_BINARY); _setmode(fileno(stdout), O_BINARY);
if (auto f = std::fopen(target.c_str(), "rb")) {
if (f) {
char buffer[8 * 1024]; char buffer[8 * 1024];
size_t n = 1; size_t n = 1;
while (!feof(f) && n > 0) { while (!feof(f) && n > 0) {

@ -1445,8 +1445,9 @@ bool parseLine(ModifyCmd& modifyCmd, const std::string& line, int num) {
} // parseLine } // parseLine
CmdId commandId(const std::string& cmdString) { CmdId commandId(const std::string& cmdString) {
auto it = Exiv2::find(cmdIdAndString, cmdString); if (auto it = Exiv2::find(cmdIdAndString, cmdString))
return it ? it->cmdId_ : CmdId::invalid; return it->cmdId_;
return CmdId::invalid;
} }
std::string parseEscapes(const std::string& input) { std::string parseEscapes(const std::string& input) {

@ -94,7 +94,7 @@ class EXIV2API AsfVideo : public Image {
uint64_t remaining_size_{}; uint64_t remaining_size_{};
public: public:
explicit HeaderReader(BasicIo::UniquePtr& io); explicit HeaderReader(const BasicIo::UniquePtr& io);
[[nodiscard]] uint64_t getSize() const { [[nodiscard]] uint64_t getSize() const {
return size_; return size_;
@ -146,7 +146,7 @@ class EXIV2API AsfVideo : public Image {
@brief Interpret Header_Extension tag information, and save it in @brief Interpret Header_Extension tag information, and save it in
the respective XMP container. the respective XMP container.
*/ */
void headerExtension(); void headerExtension() const;
/*! /*!
@brief Interpret Metadata, Extended_Content_Description, @brief Interpret Metadata, Extended_Content_Description,
Metadata_Library tag information, and save it in the respective Metadata_Library tag information, and save it in the respective

@ -119,7 +119,7 @@ class EXIV2API BmffImage : public Image {
static constexpr Exiv2::ByteOrder endian_{Exiv2::bigEndian}; static constexpr Exiv2::ByteOrder endian_{Exiv2::bigEndian};
private: private:
void openOrThrow(); void openOrThrow() const;
/*! /*!
@brief recursiveBoxHandler @brief recursiveBoxHandler
@throw Error if we visit a box more than once @throw Error if we visit a box more than once

@ -129,7 +129,7 @@ class EXIV2API Exifdatum : public Metadatum {
@return Return -1 if the %Exifdatum does not have a value yet or the @return Return -1 if the %Exifdatum does not have a value yet or the
value has no data area, else 0. value has no data area, else 0.
*/ */
int setDataArea(const byte* buf, size_t len); int setDataArea(const byte* buf, size_t len) const;
//@} //@}
//! @name Accessors //! @name Accessors

@ -88,13 +88,13 @@ class EXIV2API RiffVideo : public Image {
@brief Interpret Additional header data (strd), and save it in the respective XMP container. @brief Interpret Additional header data (strd), and save it in the respective XMP container.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void readStreamData(uint64_t size_); void readStreamData(uint64_t size_) const;
/*! /*!
@brief Interpret stream header list element (strn) , and save it in the respective XMP container. @brief Interpret stream header list element (strn) , and save it in the respective XMP container.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void StreamName(uint64_t size_); void StreamName(uint64_t size_) const;
/*! /*!
@brief Interpret INFO List Chunk, and save it in the respective XMP container. @brief Interpret INFO List Chunk, and save it in the respective XMP container.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
@ -106,28 +106,28 @@ class EXIV2API RiffVideo : public Image {
The Movi - Lists contain Video, Audio, Subtitle and (secondary) index data. Those can be grouped into rec - Lists. The Movi - Lists contain Video, Audio, Subtitle and (secondary) index data. Those can be grouped into rec - Lists.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void readMoviList(uint64_t size_); void readMoviList(uint64_t size_) const;
/*! /*!
@brief Interpret Video Properties Header chunk, and save it in the respective XMP container. @brief Interpret Video Properties Header chunk, and save it in the respective XMP container.
The video properties header identifies video signal properties associated with a digital video stream in an AVI file The video properties header identifies video signal properties associated with a digital video stream in an AVI file
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void readVPRPChunk(uint64_t size_); void readVPRPChunk(uint64_t size_) const;
/*! /*!
@brief Interpret Riff INdex Chunk, and save it in the respective XMP container. @brief Interpret Riff INdex Chunk, and save it in the respective XMP container.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void readIndexChunk(uint64_t size_); void readIndexChunk(uint64_t size_) const;
/*! /*!
@brief Interpret Riff Stream Chunk, and save it in the respective XMP container. @brief Interpret Riff Stream Chunk, and save it in the respective XMP container.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void readDataChunk(uint64_t size_); void readDataChunk(uint64_t size_) const;
/*! /*!
@brief Interpret Junk Chunk and save it in the respective XMP container. @brief Interpret Junk Chunk and save it in the respective XMP container.
@param size_ Size of the data block used to store Tag Information. @param size_ Size of the data block used to store Tag Information.
*/ */
void readJunk(uint64_t size_); void readJunk(uint64_t size_) const;
static std::string getStreamType(uint32_t stream); static std::string getStreamType(uint32_t stream);
/*! /*!

@ -315,7 +315,7 @@ class EXIV2API ExifKey : public Key {
*/ */
ExifKey& operator=(const ExifKey& rhs); ExifKey& operator=(const ExifKey& rhs);
//! Set the index. //! Set the index.
void setIdx(int idx); void setIdx(int idx) const;
//@} //@}
//! @name Accessors //! @name Accessors

@ -238,7 +238,7 @@ void AsfVideo::readMetadata() {
xmpData_["Xmp.video.AspectRatio"] = getAspectRatio(width_, height_); xmpData_["Xmp.video.AspectRatio"] = getAspectRatio(width_, height_);
} // AsfVideo::readMetadata } // AsfVideo::readMetadata
AsfVideo::HeaderReader::HeaderReader(BasicIo::UniquePtr& io) : IdBuf_(GUID) { AsfVideo::HeaderReader::HeaderReader(const BasicIo::UniquePtr& io) : IdBuf_(GUID) {
if (io->size() >= io->tell() + GUID + QWORD) { if (io->size() >= io->tell() + GUID + QWORD) {
IdBuf_ = io->read(GUID); IdBuf_ = io->read(GUID);
@ -409,7 +409,7 @@ void AsfVideo::codecList() {
} }
} // AsfVideo::codecList } // AsfVideo::codecList
void AsfVideo::headerExtension() { void AsfVideo::headerExtension() const {
io_->seek(io_->tell() + GUID /*reserved1*/ + WORD /*Reserved2*/, BasicIo::beg); io_->seek(io_->tell() + GUID /*reserved1*/ + WORD /*Reserved2*/, BasicIo::beg);
auto header_ext_data_length = readDWORDTag(io_); auto header_ext_data_length = readDWORDTag(io_);
io_->seek(io_->tell() + header_ext_data_length, BasicIo::beg); io_->seek(io_->tell() + header_ext_data_length, BasicIo::beg);

@ -184,10 +184,9 @@ int FileIo::Impl::switchMode(OpMode opMode) {
} // FileIo::Impl::switchMode } // FileIo::Impl::switchMode
int FileIo::Impl::stat(StructStat& buf) const { int FileIo::Impl::stat(StructStat& buf) const {
int ret = 0;
struct stat st; struct stat st;
ret = ::stat(path_.c_str(), &st); auto ret = ::stat(path_.c_str(), &st);
if (0 == ret) { if (ret == 0) {
buf.st_size = st.st_size; buf.st_size = st.st_size;
buf.st_mode = st.st_mode; buf.st_mode = st.st_mode;
} }
@ -204,16 +203,16 @@ FileIo::~FileIo() {
int FileIo::munmap() { int FileIo::munmap() {
int rc = 0; int rc = 0;
if (p_->pMappedArea_) { if (p_->pMappedArea_) {
#if __has_include(<sys/mman.h>) #if defined _WIN32
if (::munmap(p_->pMappedArea_, p_->mappedLength_) != 0) {
rc = 1;
}
#elif defined _WIN32
UnmapViewOfFile(p_->pMappedArea_); UnmapViewOfFile(p_->pMappedArea_);
CloseHandle(p_->hMap_); CloseHandle(p_->hMap_);
p_->hMap_ = nullptr; p_->hMap_ = nullptr;
CloseHandle(p_->hFile_); CloseHandle(p_->hFile_);
p_->hFile_ = nullptr; p_->hFile_ = nullptr;
#elif __has_include(<sys/mman.h>)
if (::munmap(p_->pMappedArea_, p_->mappedLength_) != 0) {
rc = 1;
}
#else #else
#error Platforms without mmap are not supported. See https://github.com/Exiv2/exiv2/issues/2380 #error Platforms without mmap are not supported. See https://github.com/Exiv2/exiv2/issues/2380
if (p_->isWriteable_) { if (p_->isWriteable_) {
@ -1221,7 +1220,7 @@ size_t RemoteIo::write(BasicIo& src) {
} }
// submit to the remote machine. // submit to the remote machine.
if (auto dataSize = src.size() - left - right; dataSize > 0) { if (auto dataSize = src.size() - left - right) {
std::vector<byte> data(dataSize); std::vector<byte> data(dataSize);
src.seek(left, BasicIo::beg); src.seek(left, BasicIo::beg);
src.read(data.data(), dataSize); src.read(data.data(), dataSize);

@ -183,7 +183,7 @@ class BrotliDecoderWrapper {
BrotliDecoderWrapper(const BrotliDecoderWrapper&) = delete; BrotliDecoderWrapper(const BrotliDecoderWrapper&) = delete;
BrotliDecoderWrapper& operator=(const BrotliDecoderWrapper&) = delete; BrotliDecoderWrapper& operator=(const BrotliDecoderWrapper&) = delete;
BrotliDecoderState* get() const { [[nodiscard]] BrotliDecoderState* get() const {
return decoder_; return decoder_;
} }
}; };
@ -667,12 +667,11 @@ void BmffImage::parseCr3Preview(const DataBuf& data, std::ostream& out, bool bTr
return "image/jpeg"; return "image/jpeg";
return "application/octet-stream"; return "application/octet-stream";
}(); }();
nativePreviews_.push_back(std::move(nativePreview));
if (bTrace) { if (bTrace) {
out << Internal::stringFormat("width,height,size = %zu,%zu,%zu", nativePreview.width_, nativePreview.height_, out << Internal::stringFormat("width,height,size = %zu,%zu,%zu", nativePreview.width_, nativePreview.height_,
nativePreview.size_); nativePreview.size_);
} }
nativePreviews_.push_back(std::move(nativePreview));
} }
void BmffImage::setExifData(const ExifData& /*exifData*/) { void BmffImage::setExifData(const ExifData& /*exifData*/) {
@ -692,7 +691,7 @@ void BmffImage::setComment(const std::string&) {
throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "BMFF")); throw(Error(ErrorCode::kerInvalidSettingForImage, "Image comment", "BMFF"));
} }
void BmffImage::openOrThrow() { void BmffImage::openOrThrow() const {
if (io_->open() != 0) { if (io_->open() != 0) {
throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError()); throw Error(ErrorCode::kerDataSourceOpenFailed, io_->path(), strError());
} }

@ -639,7 +639,6 @@ void Converter::cnvExifDate(const char* from, const char* to) {
return; return;
} }
} else { // "Exif.GPSInfo.GPSTimeStamp" } else { // "Exif.GPSInfo.GPSTimeStamp"
bool ok = true; bool ok = true;
if (pos->count() != 3) if (pos->count() != 3)
ok = false; ok = false;
@ -949,7 +948,6 @@ void Converter::cnvXmpDate(const char* from, const char* to) {
} }
} }
} else { // "Exif.GPSInfo.GPSTimeStamp" } else { // "Exif.GPSInfo.GPSTimeStamp"
// Ignore the time zone, assuming the time is in UTC as it should be // Ignore the time zone, assuming the time is in UTC as it should be
URational rhour(datetime.hour, 1); URational rhour(datetime.hour, 1);
@ -1391,17 +1389,16 @@ void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData) {
bool convertStringCharset(std::string& str, const char* from, const char* to) { bool convertStringCharset(std::string& str, const char* from, const char* to) {
if (0 == strcmp(from, to)) if (0 == strcmp(from, to))
return true; // nothing to do return true; // nothing to do
bool ret = false;
#if defined EXV_HAVE_ICONV #if defined EXV_HAVE_ICONV
ret = convertStringCharsetIconv(str, from, to); return convertStringCharsetIconv(str, from, to);
#elif defined _WIN32 #elif defined _WIN32
ret = convertStringCharsetWindows(str, from, to); return convertStringCharsetWindows(str, from, to);
#else #else
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Charset conversion required but no character mapping functionality available.\n"; EXV_WARNING << "Charset conversion required but no character mapping functionality available.\n";
#endif #endif
#endif #endif
return ret; return false;
} }
} // namespace Exiv2 } // namespace Exiv2
@ -1589,8 +1586,7 @@ const ConvFctList convFctList[] = {
[[maybe_unused]] bool convertStringCharsetWindows(std::string& str, const char* from, const char* to) { [[maybe_unused]] bool convertStringCharsetWindows(std::string& str, const char* from, const char* to) {
bool ret = false; bool ret = false;
std::string tmpstr = str; std::string tmpstr = str;
auto p = Exiv2::find(convFctList, std::pair(from, to)); if (auto p = Exiv2::find(convFctList, std::pair(from, to)))
if (p)
ret = p->convFct_(tmpstr); ret = p->convFct_(tmpstr);
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
else { else {

@ -573,7 +573,7 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) {
return cc_; return cc_;
} // CiffDirectory::doAdd } // CiffDirectory::doAdd
void CiffHeader::remove(uint16_t crwTagId, uint16_t crwDir) { void CiffHeader::remove(uint16_t crwTagId, uint16_t crwDir) const {
if (pRootDir_) { if (pRootDir_) {
CrwDirs crwDirs; CrwDirs crwDirs;
CrwMap::loadStack(crwDirs, crwDir); CrwMap::loadStack(crwDirs, crwDir);
@ -859,7 +859,7 @@ void CrwMap::encode0x0805(const Image& image, const CrwMapping* pCrwMapping, Cif
if (cc && cc->size() > size) if (cc && cc->size() > size)
size = cc->size(); size = cc->size();
DataBuf buf(size); DataBuf buf(size);
std::copy(comment.begin(), comment.end(), buf.begin()); std::move(comment.begin(), comment.end(), buf.begin());
pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf));
} else { } else {
if (cc) { if (cc) {
@ -900,21 +900,19 @@ void CrwMap::encode0x080a(const Image& image, const CrwMapping* pCrwMapping, Cif
} }
void CrwMap::encodeArray(const Image& image, const CrwMapping* pCrwMapping, CiffHeader* pHead) { void CrwMap::encodeArray(const Image& image, const CrwMapping* pCrwMapping, CiffHeader* pHead) {
IfdId ifdId = IfdId::ifdIdNotSet; auto ifdId = [=] {
switch (pCrwMapping->tag_) { switch (pCrwMapping->tag_) {
case 0x0001: case 0x0001:
ifdId = IfdId::canonCsId; return IfdId::canonCsId;
break;
case 0x0004: case 0x0004:
ifdId = IfdId::canonSiId; return IfdId::canonSiId;
break;
case 0x000f: case 0x000f:
ifdId = IfdId::canonCfId; return IfdId::canonCfId;
break;
case 0x0012: case 0x0012:
ifdId = IfdId::canonPiId; return IfdId::canonPiId;
break;
} }
return IfdId::ifdIdNotSet;
}();
DataBuf buf = packIfdId(image.exifData(), ifdId, pHead->byteOrder()); DataBuf buf = packIfdId(image.exifData(), ifdId, pHead->byteOrder());
if (buf.empty()) { if (buf.empty()) {
// Try the undecoded tag // Try the undecoded tag

@ -424,7 +424,7 @@ class CiffHeader {
@param crwTagId Tag id to be removed. @param crwTagId Tag id to be removed.
@param crwDir Parent directory of the tag. @param crwDir Parent directory of the tag.
*/ */
void remove(uint16_t crwTagId, uint16_t crwDir); void remove(uint16_t crwTagId, uint16_t crwDir) const;
//@} //@}
//! Return a pointer to the Canon CRW signature. //! Return a pointer to the Canon CRW signature.

@ -265,7 +265,7 @@ int Exifdatum::setValue(const std::string& value) {
return value_->read(value); return value_->read(value);
} }
int Exifdatum::setDataArea(const byte* buf, size_t len) { int Exifdatum::setDataArea(const byte* buf, size_t len) const {
return value_ ? value_->setDataArea(buf, len) : -1; return value_ ? value_->setDataArea(buf, len) : -1;
} }

@ -346,11 +346,10 @@ static std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& va
longValue -= '0'; longValue -= '0';
} }
auto td = Exiv2::find(fujiFaceElementType, longValue);
if (n != 0) { if (n != 0) {
os << " "; os << " ";
} }
if (td) { if (auto td = Exiv2::find(fujiFaceElementType, longValue)) {
os << exvGettext(td->label_); os << exvGettext(td->label_);
} else { } else {
os << "(" << value.toInt64(n) << ")"; os << "(" << value.toInt64(n) << ")";

@ -139,7 +139,8 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st
// Windows specific code // Windows specific code
#if defined(_WIN32) #if defined(_WIN32)
WSADATA wsaData; WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData); if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
return error(errors, "could not start WinSock");
#endif #endif
const char* servername = request["server"].c_str(); const char* servername = request["server"].c_str();

@ -743,10 +743,9 @@ AccessMode ImageFactory::checkMode(ImageType type, MetadataId metadataId) {
} }
bool ImageFactory::checkType(ImageType type, BasicIo& io, bool advance) { bool ImageFactory::checkType(ImageType type, BasicIo& io, bool advance) {
auto r = Exiv2::find(registry, type); if (auto r = Exiv2::find(registry, type))
if (!r)
return false;
return r->isThisType_(io, advance); return r->isThisType_(io, advance);
return false;
} }
ImageType ImageFactory::getType(const std::string& path) { ImageType ImageFactory::getType(const std::string& path) {
@ -844,10 +843,9 @@ Image::UniquePtr ImageFactory::create(ImageType type, BasicIo::UniquePtr io) {
// BasicIo instance does not need to be open // BasicIo instance does not need to be open
if (type == ImageType::none) if (type == ImageType::none)
return {}; return {};
auto r = Exiv2::find(registry, type); if (auto r = Exiv2::find(registry, type))
if (!r)
return {};
return r->newInstance_(std::move(io), true); return r->newInstance_(std::move(io), true);
return {};
} }
// ***************************************************************************** // *****************************************************************************

@ -142,11 +142,9 @@ bool TiffMnRegistry::operator==(IfdId key) const {
TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, const std::string& make, const byte* pData, size_t size, TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, const std::string& make, const byte* pData, size_t size,
ByteOrder byteOrder) { ByteOrder byteOrder) {
auto tmr = Exiv2::find(registry_, make); if (auto tmr = Exiv2::find(registry_, make))
if (!tmr) {
return nullptr;
}
return tmr->newMnFct_(tag, group, tmr->mnGroup_, pData, size, byteOrder); return tmr->newMnFct_(tag, group, tmr->mnGroup_, pData, size, byteOrder);
return nullptr;
} // TiffMnCreator::create } // TiffMnCreator::create
TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, IfdId mnGroup) { TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, IfdId mnGroup) {
@ -914,11 +912,9 @@ int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* /
return -1; return -1;
auto ix = NikonArrayIdx::Key{tag, reinterpret_cast<const char*>(pData), size}; auto ix = NikonArrayIdx::Key{tag, reinterpret_cast<const char*>(pData), size};
auto it = Exiv2::find(nikonArrayIdx, ix); if (auto it = Exiv2::find(nikonArrayIdx, ix))
if (!it)
return -1;
return it->idx_; return it->idx_;
return -1;
} }
DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot) { DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot) {

@ -254,7 +254,7 @@ enum matroskaEnum : uint64_t {
Cluster = 0xf43b675 Cluster = 0xf43b675
}; };
const MatroskaTag matroskaTags[] = { const MatroskaTag matroskaTags[]{
{ChapterDisplay, "ChapterDisplay", Master, Composite}, {ChapterDisplay, "ChapterDisplay", Master, Composite},
{TrackType, "TrackType", Boolean, Process}, {TrackType, "TrackType", Boolean, Process},
{ChapterString, "ChapterString", String, Skip}, {ChapterString, "ChapterString", String, Skip},
@ -720,60 +720,46 @@ void MatroskaVideo::decodeBlock() {
} // MatroskaVideo::decodeBlock } // MatroskaVideo::decodeBlock
void MatroskaVideo::decodeInternalTags(const MatroskaTag* tag, const byte* buf) { void MatroskaVideo::decodeInternalTags(const MatroskaTag* tag, const byte* buf) {
const MatroskaTag* internalMt = nullptr;
uint64_t key = getULongLong(buf, bigEndian); uint64_t key = getULongLong(buf, bigEndian);
if (!key) if (!key)
return; return;
auto internalMt = [=]() -> const MatroskaTag* {
switch (tag->_id) { switch (tag->_id) {
case Xmp_video_VideoScanTpye: case Xmp_video_VideoScanTpye:
internalMt = Exiv2::find(videoScanType, key); return Exiv2::find(videoScanType, key);
break;
case Xmp_audio_ChannelType: case Xmp_audio_ChannelType:
internalMt = Exiv2::find(audioChannels, key); return Exiv2::find(audioChannels, key);
break;
case Xmp_video_ContentCompressAlgo: case Xmp_video_ContentCompressAlgo:
internalMt = Exiv2::find(compressionAlgorithm, key); return Exiv2::find(compressionAlgorithm, key);
break;
case Xmp_video_ContentEncryptAlgo: case Xmp_video_ContentEncryptAlgo:
internalMt = Exiv2::find(encryptionAlgorithm, key); return Exiv2::find(encryptionAlgorithm, key);
break;
case Xmp_video_ContentSignAlgo_1: case Xmp_video_ContentSignAlgo_1:
case Xmp_video_ContentSignAlgo_2: case Xmp_video_ContentSignAlgo_2:
internalMt = Exiv2::find(contentSignatureAlgorithm, key); return Exiv2::find(contentSignatureAlgorithm, key);
break;
case Xmp_video_ContentSignHashAlgo_1: case Xmp_video_ContentSignHashAlgo_1:
case Xmp_video_ContentSignHashAlgo_2: case Xmp_video_ContentSignHashAlgo_2:
internalMt = Exiv2::find(contentSignatureHashAlgorithm, key); return Exiv2::find(contentSignatureHashAlgorithm, key);
break;
case Xmp_video_ContentEncodingType: case Xmp_video_ContentEncodingType:
internalMt = Exiv2::find(encodingType, key); return Exiv2::find(encodingType, key);
break;
case Xmp_video_DisplayUnit: case Xmp_video_DisplayUnit:
internalMt = Exiv2::find(displayUnit, key); return Exiv2::find(displayUnit, key);
break;
case Xmp_video_AspectRatioType: case Xmp_video_AspectRatioType:
internalMt = Exiv2::find(aspectRatioType, key); return Exiv2::find(aspectRatioType, key);
break;
case Xmp_video_PhysicalEquivalent: case Xmp_video_PhysicalEquivalent:
internalMt = Exiv2::find(chapterPhysicalEquivalent, key); return Exiv2::find(chapterPhysicalEquivalent, key);
break;
case Xmp_video_TranslateCodec: case Xmp_video_TranslateCodec:
internalMt = Exiv2::find(chapterTranslateCodec, key); return Exiv2::find(chapterTranslateCodec, key);
break;
case Video_Audio_CodecID: case Video_Audio_CodecID:
internalMt = Exiv2::find(trackCodec, key); return Exiv2::find(trackCodec, key);
break;
case Video_Audio_CodecName: case Video_Audio_CodecName:
internalMt = Exiv2::find(codecInfo, key); return Exiv2::find(codecInfo, key);
break;
case CodecDownloadURL: case CodecDownloadURL:
case CodecInfoURL: case CodecInfoURL:
internalMt = Exiv2::find(codecDownloadUrl, key); return Exiv2::find(codecDownloadUrl, key);
break;
default:
break;
} }
return nullptr;
}();
if (internalMt) { if (internalMt) {
xmpData_[tag->_label] = internalMt->_label; xmpData_[tag->_label] = internalMt->_label;
} else { } else {
@ -803,7 +789,6 @@ void MatroskaVideo::decodeIntegerTags(const MatroskaTag* tag, const byte* buf) {
} }
void MatroskaVideo::decodeBooleanTags(const MatroskaTag* tag, const byte* buf) { void MatroskaVideo::decodeBooleanTags(const MatroskaTag* tag, const byte* buf) {
std::string str("No");
const MatroskaTag* internalMt = nullptr; const MatroskaTag* internalMt = nullptr;
uint64_t key = getULongLong(buf, bigEndian); uint64_t key = getULongLong(buf, bigEndian);
if (!key) if (!key)
@ -841,8 +826,7 @@ void MatroskaVideo::decodeBooleanTags(const MatroskaTag* tag, const byte* buf) {
} }
if (internalMt) { if (internalMt) {
str = "Yes"; xmpData_[internalMt->_label] = "Yes";
xmpData_[internalMt->_label] = str;
} }
} }
@ -893,8 +877,7 @@ void MatroskaVideo::decodeFloatTags(const MatroskaTag* tag, const byte* buf) {
uint64_t key = getULongLong(buf, bigEndian); uint64_t key = getULongLong(buf, bigEndian);
if (!key) if (!key)
return; return;
const MatroskaTag* internalMt = Exiv2::find(streamRate, key); if (auto internalMt = Exiv2::find(streamRate, key)) {
if (internalMt) {
switch (stream_) { switch (stream_) {
case 1: // video case 1: // video
frame_rate = static_cast<double>(1000000000) / static_cast<double>(key); frame_rate = static_cast<double>(1000000000) / static_cast<double>(key);

@ -1679,7 +1679,8 @@ std::ostream& printMinoltaSonyLensID(std::ostream& os, const Value& value, const
// #1145 - respect lenses with shared LensID // #1145 - respect lenses with shared LensID
uint32_t index = value.toUint32(); uint32_t index = value.toUint32();
if (auto f = Exiv2::find(lensIdFct, index); f && metadata) if (metadata)
if (auto f = Exiv2::find(lensIdFct, index))
return f->fct(os, value, metadata); return f->fct(os, value, metadata);
return EXV_PRINT_TAG(minoltaSonyLensID)(os, value, metadata); return EXV_PRINT_TAG(minoltaSonyLensID)(os, value, metadata);
} }

@ -2007,7 +2007,7 @@ std::ostream& Nikon3MakerNote::printLensId(std::ostream& os, const Value& value,
// Nikkor lenses by their LensID // Nikkor lenses by their LensID
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
static const struct FMntLens { static constexpr struct FMntLens {
unsigned char lid, stps, focs, focl, aps, apl, lfw, ltype, tcinfo, dblid, mid; unsigned char lid, stps, focs, focl, aps, apl, lfw, ltype, tcinfo, dblid, mid;
const char *manuf, *lnumber, *lensname; const char *manuf, *lnumber, *lensname;
@ -3786,8 +3786,7 @@ std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value,
if (l != 0) if (l != 0)
trim = false; trim = false;
std::string d = s.empty() ? "" : "; "; std::string d = s.empty() ? "" : "; ";
auto td = Exiv2::find(nikonRetouchHistory, l); if (auto td = Exiv2::find(nikonRetouchHistory, l)) {
if (td) {
s = std::string(exvGettext(td->label_)).append(d).append(s); s = std::string(exvGettext(td->label_)).append(d).append(s);
} else { } else {
s = std::string(_("Unknown")).append(" (").append(std::to_string(l)).append(")").append(d).append(s); s = std::string(_("Unknown")).append(" (").append(std::to_string(l)).append(")").append(d).append(s);

@ -4993,13 +4993,10 @@ std::string XmpProperties::prefix(const std::string& ns) {
auto i = nsRegistry_.find(ns2); auto i = nsRegistry_.find(ns2);
std::string p; std::string p;
if (i != nsRegistry_.end()) { if (i != nsRegistry_.end())
p = i->second.prefix_; p = i->second.prefix_;
} else { else if (auto xn = Exiv2::find(xmpNsInfo, XmpNsInfo::Ns{ns2}))
auto xn = Exiv2::find(xmpNsInfo, XmpNsInfo::Ns{ns2});
if (xn)
p = std::string(xn->prefix_); p = std::string(xn->prefix_);
}
return p; return p;
} }
@ -5087,8 +5084,7 @@ void XmpProperties::registeredNamespaces(Exiv2::Dictionary& nsDict) {
} }
void XmpProperties::printProperties(std::ostream& os, const std::string& prefix) { void XmpProperties::printProperties(std::ostream& os, const std::string& prefix) {
const XmpPropertyInfo* pl = propertyList(prefix); if (auto pl = propertyList(prefix)) {
if (pl) {
for (int i = 0; pl[i].name_; ++i) { for (int i = 0; pl[i].name_; ++i) {
os << pl[i]; os << pl[i];
} }
@ -5099,8 +5095,7 @@ void XmpProperties::printProperties(std::ostream& os, const std::string& prefix)
std::ostream& XmpProperties::printProperty(std::ostream& os, const std::string& key, const Value& value) { std::ostream& XmpProperties::printProperty(std::ostream& os, const std::string& key, const Value& value) {
PrintFct fct = printValue; PrintFct fct = printValue;
if (value.count() != 0) { if (value.count() != 0) {
auto info = Exiv2::find(xmpPrintInfo, key); if (auto info = Exiv2::find(xmpPrintInfo, key))
if (info)
fct = info->printFct_; fct = info->printFct_;
} }
return fct(os, value, nullptr); return fct(os, value, nullptr);

@ -637,11 +637,11 @@ void RiffVideo::readStreamFormat(uint64_t size_) {
} }
} }
void RiffVideo::readStreamData(uint64_t size_) { void RiffVideo::readStreamData(uint64_t size_) const {
io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }
void RiffVideo::StreamName(uint64_t size_) { void RiffVideo::StreamName(uint64_t size_) const {
// This element contains a name for the stream. That stream name should only use plain ASCII, especially not UTF-8. // This element contains a name for the stream. That stream name should only use plain ASCII, especially not UTF-8.
io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }
@ -658,11 +658,11 @@ void RiffVideo::readInfoListChunk(uint64_t size_) {
} }
} }
void RiffVideo::readMoviList(uint64_t size_) { void RiffVideo::readMoviList(uint64_t size_) const {
io_->seekOrThrow(io_->tell() + size_ - DWORD, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + size_ - DWORD, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }
void RiffVideo::readVPRPChunk(uint64_t size_) { void RiffVideo::readVPRPChunk(uint64_t size_) const {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
EXV_INFO << "--> VideoFormatToken = " << readDWORDTag(io_) << std::endl; EXV_INFO << "--> VideoFormatToken = " << readDWORDTag(io_) << std::endl;
EXV_INFO << "--> VideoStandard = " << readDWORDTag(io_) << std::endl; EXV_INFO << "--> VideoStandard = " << readDWORDTag(io_) << std::endl;
@ -688,7 +688,7 @@ void RiffVideo::readVPRPChunk(uint64_t size_) {
io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }
void RiffVideo::readIndexChunk(uint64_t size_) { void RiffVideo::readIndexChunk(uint64_t size_) const {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
uint64_t current_size = 0; uint64_t current_size = 0;
while (current_size < size_) { while (current_size < size_) {
@ -708,7 +708,7 @@ void RiffVideo::readIndexChunk(uint64_t size_) {
io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }
void RiffVideo::readDataChunk(uint64_t size_) { void RiffVideo::readDataChunk(uint64_t size_) const {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
EXV_INFO << "--> Data = " << readStringTag(io_, static_cast<size_t>(size_)) << std::endl; EXV_INFO << "--> Data = " << readStringTag(io_, static_cast<size_t>(size_)) << std::endl;
uint64_t readed_size = size_; uint64_t readed_size = size_;
@ -724,7 +724,7 @@ void RiffVideo::readDataChunk(uint64_t size_) {
io_->seekOrThrow(io_->tell() + 1, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + 1, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }
void RiffVideo::readJunk(uint64_t size_) { void RiffVideo::readJunk(uint64_t size_) const {
io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData); io_->seekOrThrow(io_->tell() + size_, BasicIo::beg, ErrorCode::kerFailedToReadImageData);
} }

@ -1180,21 +1180,19 @@ static void findLensSpecFlags(const Value& value, std::string& flagsStart, std::
// https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L10545 // https://github.com/exiftool/exiftool/blob/1e17485cbb372a502e5b9d052d01303db735e6fa/lib/Image/ExifTool/Sony.pm#L10545
const auto joinedV0V7 = ((value.toUint32(0) << 8) + value.toUint32(7)); const auto joinedV0V7 = ((value.toUint32(0) << 8) + value.toUint32(7));
auto temp = 0;
for (const auto& i : lSFArray) { for (const auto& i : lSFArray) {
temp = i.mask & joinedV0V7; if (auto temp = i.mask & joinedV0V7) { // Check if a flag matches in the current LensSpecFlags
if (temp) { // Check if a flag matches in the current LensSpecFlags if (auto f = Exiv2::find(i.flags, temp)) {
auto f = Exiv2::find(i.flags, temp);
if (!f) {
// Should never get in here. LensSpecFlags.mask should contain all the
// bits in all the LensSpecFlags.flags.val_ entries
throw Error(ErrorCode::kerErrorMessage,
std::string("LensSpecFlags mask doesn't match the bits in the flags array"));
}
if (i.prepend) if (i.prepend)
flagsStart = (flagsStart.empty() ? f->label_ : f->label_ + std::string(" ") + flagsStart); flagsStart = (flagsStart.empty() ? f->label_ : f->label_ + std::string(" ") + flagsStart);
else else
flagsEnd = (flagsEnd.empty() ? f->label_ : flagsEnd + std::string(" ") + f->label_); flagsEnd = (flagsEnd.empty() ? f->label_ : flagsEnd + std::string(" ") + f->label_);
continue;
}
// Should never get in here. LensSpecFlags.mask should contain all the
// bits in all the LensSpecFlags.flags.val_ entries
throw Error(ErrorCode::kerErrorMessage,
std::string("LensSpecFlags mask doesn't match the bits in the flags array"));
} }
} }
} }

@ -11,8 +11,6 @@
#include "tags_int.hpp" #include "tags_int.hpp"
#include "types.hpp" #include "types.hpp"
#include <array>
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
@ -274,7 +272,7 @@ ExifKey& ExifKey::operator=(const ExifKey& rhs) {
return *this; return *this;
} }
void ExifKey::setIdx(int idx) { void ExifKey::setIdx(int idx) const {
p_->idx_ = idx; p_->idx_ = idx;
} }
@ -344,8 +342,7 @@ std::ostream& operator<<(std::ostream& os, const TagInfo& ti) {
// CSV encoded I am \"dead\" beat" => "I am ""dead"" beat" // CSV encoded I am \"dead\" beat" => "I am ""dead"" beat"
char Q = '"'; char Q = '"';
os << Q; os << Q;
for (size_t i = 0; i < exifKey.tagDesc().size(); i++) { for (char c : exifKey.tagDesc()) {
char c = exifKey.tagDesc()[i];
if (c == Q) if (c == Q)
os << Q; os << Q;
os << c; os << c;

@ -2319,12 +2319,8 @@ const TagInfo* mnTagList() {
} }
bool isMakerIfd(IfdId ifdId) { bool isMakerIfd(IfdId ifdId) {
bool rc = false;
auto ii = Exiv2::find(groupInfo, ifdId); auto ii = Exiv2::find(groupInfo, ifdId);
if (ii && 0 == strcmp(ii->ifdName_, "Makernote")) { return ii && strcmp(ii->ifdName_, "Makernote") == 0;
rc = true;
}
return rc;
} }
bool isExifIfd(IfdId ifdId) { bool isExifIfd(IfdId ifdId) {
@ -2355,8 +2351,7 @@ bool isExifIfd(IfdId ifdId) {
} }
void taglist(std::ostream& os, IfdId ifdId) { void taglist(std::ostream& os, IfdId ifdId) {
const TagInfo* ti = Internal::tagList(ifdId); if (auto ti = tagList(ifdId)) {
if (ti) {
for (int k = 0; ti[k].tag_ != 0xffff; ++k) { for (int k = 0; ti[k].tag_ != 0xffff; ++k) {
os << ti[k] << "\n"; os << ti[k] << "\n";
} }
@ -2364,59 +2359,54 @@ void taglist(std::ostream& os, IfdId ifdId) {
} // taglist } // taglist
const TagInfo* tagList(IfdId ifdId) { const TagInfo* tagList(IfdId ifdId) {
auto ii = Exiv2::find(groupInfo, ifdId); if (auto ii = Exiv2::find(groupInfo, ifdId))
if (!ii || !ii->tagList_) if (ii->tagList_)
return nullptr;
return ii->tagList_(); return ii->tagList_();
return nullptr;
} // tagList } // tagList
const TagInfo* tagInfo(uint16_t tag, IfdId ifdId) { const TagInfo* tagInfo(uint16_t tag, IfdId ifdId) {
const TagInfo* ti = tagList(ifdId); if (auto ti = tagList(ifdId)) {
if (!ti)
return nullptr;
int idx = 0; int idx = 0;
for (idx = 0; ti[idx].tag_ != 0xffff; ++idx) { for (idx = 0; ti[idx].tag_ != 0xffff; ++idx) {
if (ti[idx].tag_ == tag) if (ti[idx].tag_ == tag)
break; break;
} }
return &ti[idx]; return &ti[idx];
}
return nullptr;
} // tagInfo } // tagInfo
const TagInfo* tagInfo(const std::string& tagName, IfdId ifdId) { const TagInfo* tagInfo(const std::string& tagName, IfdId ifdId) {
const TagInfo* ti = tagList(ifdId);
if (!ti)
return nullptr;
if (tagName.empty()) if (tagName.empty())
return nullptr; return nullptr;
if (auto ti = tagList(ifdId)) {
const char* tn = tagName.c_str(); const char* tn = tagName.c_str();
for (int idx = 0; ti[idx].tag_ != 0xffff; ++idx) { for (int idx = 0; ti[idx].tag_ != 0xffff; ++idx) {
if (0 == strcmp(ti[idx].name_, tn)) { if (0 == strcmp(ti[idx].name_, tn)) {
return &ti[idx]; return &ti[idx];
} }
} }
}
return nullptr; return nullptr;
} // tagInfo } // tagInfo
IfdId groupId(const std::string& groupName) { IfdId groupId(const std::string& groupName) {
IfdId ifdId = IfdId::ifdIdNotSet; if (auto ii = Exiv2::find(groupInfo, groupName))
auto ii = Exiv2::find(groupInfo, groupName); return static_cast<IfdId>(ii->ifdId_);
if (ii) return IfdId::ifdIdNotSet;
ifdId = static_cast<IfdId>(ii->ifdId_);
return ifdId;
} }
const char* ifdName(IfdId ifdId) { const char* ifdName(IfdId ifdId) {
auto ii = Exiv2::find(groupInfo, ifdId); if (auto ii = Exiv2::find(groupInfo, ifdId))
if (!ii)
return groupInfo[0].ifdName_;
return ii->ifdName_; return ii->ifdName_;
return groupInfo[0].ifdName_;
} }
const char* groupName(IfdId ifdId) { const char* groupName(IfdId ifdId) {
auto ii = Exiv2::find(groupInfo, ifdId); if (auto ii = Exiv2::find(groupInfo, ifdId))
if (!ii)
return groupInfo[0].groupName_;
return ii->groupName_; return ii->groupName_;
return groupInfo[0].groupName_;
} }
std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*) { std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*) {
@ -2947,13 +2937,15 @@ std::ostream& print0xa001(std::ostream& os, const Value& value, const ExifData*
} }
//! SensingMethod, tag 0xa217 //! SensingMethod, tag 0xa217
constexpr TagDetails exifSensingMethod[] = {{1, N_("Not defined")}, constexpr TagDetails exifSensingMethod[] = {
{1, N_("Not defined")},
{2, N_("One-chip color area")}, {2, N_("One-chip color area")},
{3, N_("Two-chip color area")}, {3, N_("Two-chip color area")},
{4, N_("Three-chip color area")}, {4, N_("Three-chip color area")},
{5, N_("Color sequential area")}, {5, N_("Color sequential area")},
{7, N_("Trilinear sensor")}, {7, N_("Trilinear sensor")},
{8, N_("Color sequential linear")}}; {8, N_("Color sequential linear")},
};
std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData* metadata) { std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData* metadata) {
return EXV_PRINT_TAG(exifSensingMethod)(os, value, metadata); return EXV_PRINT_TAG(exifSensingMethod)(os, value, metadata);
@ -2963,7 +2955,8 @@ std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData*
constexpr TagDetails exifFileSource[] = { constexpr TagDetails exifFileSource[] = {
{1, N_("Film scanner")}, // Not defined to Exif 2.2 spec. {1, N_("Film scanner")}, // Not defined to Exif 2.2 spec.
{2, N_("Reflexion print scanner")}, // but used by some scanner device softwares. {2, N_("Reflexion print scanner")}, // but used by some scanner device softwares.
{3, N_("Digital still camera")}}; {3, N_("Digital still camera")},
};
std::ostream& print0xa300(std::ostream& os, const Value& value, const ExifData* metadata) { std::ostream& print0xa300(std::ostream& os, const Value& value, const ExifData* metadata) {
return EXV_PRINT_TAG(exifFileSource)(os, value, metadata); return EXV_PRINT_TAG(exifFileSource)(os, value, metadata);

@ -2029,7 +2029,7 @@ ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpDa
} }
if (auto rootDir = parse(pData, size, root, pHeader)) { if (auto rootDir = parse(pData, size, root, pHeader)) {
TiffDecoder decoder(exifData, iptcData, xmpData, rootDir.get(), findDecoderFct); auto decoder = TiffDecoder(exifData, iptcData, xmpData, rootDir.get(), findDecoderFct);
rootDir->accept(decoder); rootDir->accept(decoder);
} }
return pHeader->byteOrder(); return pHeader->byteOrder();

@ -39,13 +39,12 @@ class FindExifdatum2 {
}; // class FindExifdatum2 }; // class FindExifdatum2
Exiv2::ByteOrder stringToByteOrder(const std::string& val) { Exiv2::ByteOrder stringToByteOrder(const std::string& val) {
Exiv2::ByteOrder bo = Exiv2::invalidByteOrder;
if (val == "II") if (val == "II")
bo = Exiv2::littleEndian; return Exiv2::littleEndian;
else if (val == "MM") if (val == "MM")
bo = Exiv2::bigEndian; return Exiv2::bigEndian;
return bo; return Exiv2::invalidByteOrder;
} }
} // namespace } // namespace
@ -500,7 +499,7 @@ void TiffEncoder::encodeIptc() {
if (rawIptc.size() % 4 != 0) { if (rawIptc.size() % 4 != 0) {
// Pad the last unsignedLong value with 0s // Pad the last unsignedLong value with 0s
buf.alloc((rawIptc.size() / 4) * 4 + 4); buf.alloc((rawIptc.size() / 4) * 4 + 4);
std::copy(rawIptc.begin(), rawIptc.end(), buf.begin()); std::move(rawIptc.begin(), rawIptc.end(), buf.begin());
} else { } else {
buf = std::move(rawIptc); // Note: This resets rawIptc buf = std::move(rawIptc); // Note: This resets rawIptc
} }
@ -1347,7 +1346,8 @@ void TiffReader::visitBinaryArray(TiffBinaryArray* object) {
// Check duplicates // Check duplicates
TiffFinder finder(object->tag(), object->group()); TiffFinder finder(object->tag(), object->group());
pRoot_->accept(finder); pRoot_->accept(finder);
if (auto te = dynamic_cast<TiffEntryBase*>(finder.result()); te && te->idx() != object->idx()) { if (auto te = dynamic_cast<TiffEntryBase*>(finder.result())) {
if (te->idx() != object->idx()) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Not decoding duplicate binary array tag 0x" << std::setw(4) << std::setfill('0') << std::hex EXV_WARNING << "Not decoding duplicate binary array tag 0x" << std::setw(4) << std::setfill('0') << std::hex
<< object->tag() << std::dec << ", group " << groupName(object->group()) << ", idx " << object->idx() << object->tag() << std::dec << ", group " << groupName(object->group()) << ", idx " << object->idx()
@ -1356,6 +1356,7 @@ void TiffReader::visitBinaryArray(TiffBinaryArray* object) {
object->setDecoded(false); object->setDecoded(false);
return; return;
} }
}
if (object->TiffEntryBase::doSize() == 0) if (object->TiffEntryBase::doSize() == 0)
return; return;

@ -69,24 +69,21 @@ constexpr struct TypeInfoTable {
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
const char* TypeInfo::typeName(TypeId typeId) { const char* TypeInfo::typeName(TypeId typeId) {
auto tit = Exiv2::find(typeInfoTable, typeId); if (auto tit = Exiv2::find(typeInfoTable, typeId))
if (!tit)
return nullptr;
return tit->name_; return tit->name_;
return nullptr;
} }
TypeId TypeInfo::typeId(const std::string& typeName) { TypeId TypeInfo::typeId(const std::string& typeName) {
auto tit = Exiv2::find(typeInfoTable, typeName); if (auto tit = Exiv2::find(typeInfoTable, typeName))
if (!tit)
return invalidTypeId;
return tit->typeId_; return tit->typeId_;
return invalidTypeId;
} }
size_t TypeInfo::typeSize(TypeId typeId) { size_t TypeInfo::typeSize(TypeId typeId) {
auto tit = Exiv2::find(typeInfoTable, typeId); if (auto tit = Exiv2::find(typeInfoTable, typeId))
if (!tit)
return 0;
return tit->size_; return tit->size_;
return 0;
} }
DataBuf::DataBuf(size_t size) : pData_(size) { DataBuf::DataBuf(size_t size) : pData_(size) {
@ -481,11 +478,7 @@ bool isHex(const std::string& str, size_t size, const std::string& prefix) {
if (size > 0 && str.size() != size + prefix.size()) if (size > 0 && str.size() != size + prefix.size())
return false; return false;
for (size_t i = prefix.size(); i < str.size(); ++i) { return std::all_of(str.begin() + prefix.size(), str.end(), ::isxdigit);
if (!isxdigit(str[i]))
return false;
}
return true;
} // isHex } // isHex
int exifTime(const char* buf, tm* tm) { int exifTime(const char* buf, tm* tm) {

Loading…
Cancel
Save