diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 106ca1dca4..e0838b932d 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -41,12 +41,19 @@ constexpr auto emptyYodAdjust_ = std::array{ }; //! List of all command identifiers and corresponding strings -constexpr auto cmdIdAndString = std::array{ - std::pair(CmdId::add, "add"), - std::pair(CmdId::set, "set"), - std::pair(CmdId::del, "del"), - std::pair(CmdId::reg, "reg"), - std::pair(CmdId::invalid, "invalidCmd"), // End of list marker +constexpr struct CmdIdAndString { + CmdId cmdId_; + const char* string_; + //! Comparison operator for \em string + bool operator==(const std::string& string) const { + return string == string_; + } +} cmdIdAndString[] = { + {CmdId::add, "add"}, + {CmdId::set, "set"}, + {CmdId::del, "del"}, + {CmdId::reg, "reg"}, + {CmdId::invalid, "invalidCmd"}, // End of list marker }; // Return a command Id for a command string @@ -1433,8 +1440,8 @@ bool parseLine(ModifyCmd& modifyCmd, const std::string& line, int num) { } // parseLine CmdId commandId(const std::string& cmdString) { - auto it = std::find_if(cmdIdAndString.begin(), cmdIdAndString.end(), [&](auto cs) { return cs.second == cmdString; }); - return it != cmdIdAndString.end() ? it->first : CmdId::invalid; + auto it = Exiv2::find(cmdIdAndString, cmdString); + return it ? it->cmdId_ : CmdId::invalid; } std::string parseEscapes(const std::string& input) { diff --git a/src/asfvideo.cpp b/src/asfvideo.cpp index 0ddabeb4fe..1d47cb31d8 100644 --- a/src/asfvideo.cpp +++ b/src/asfvideo.cpp @@ -265,7 +265,6 @@ void AsfVideo::readMetadata() { void AsfVideo::decodeBlock() { DataBuf buf(BUFF_MIN_SIZE + 1); uint64_t size = 0; - const Internal::TagVocabulary* tv; uint64_t cur_pos = io_->tell(); byte guidBuf[GUI_SIZE]; @@ -278,12 +277,11 @@ void AsfVideo::decodeBlock() { char GUID[GUID_SIZE] = ""; // the getGUID function write the GUID[36], - getGUID(guidBuf, GUID); - tv = find(GUIDReferenceTags, GUID); - io_->read(buf.data(), BUFF_MIN_SIZE); size = Util::getUint64_t(buf); + getGUID(guidBuf, GUID); + auto tv = Exiv2::find(GUIDReferenceTags, GUID); if (tv) { auto tagDecoder = [&](const Internal::TagVocabulary* tv, uint64_t size) { uint64_t cur_pos = io_->tell(); @@ -392,7 +390,7 @@ void AsfVideo::contentDescription(uint64_t size) { io_->read(buf.data(), length[i]); if (io_->error() || io_->eof()) throw Error(ErrorCode::kerFailedToReadImageData); - const TagDetails* td = find(contentDescriptionTags, i); + auto td = Exiv2::find(contentDescriptionTags, i); assert(td); std::string str(reinterpret_cast(buf.data()), length[i]); if (convertStringCharset(str, "UCS-2LE", "UTF-8")) { @@ -414,8 +412,7 @@ void AsfVideo::streamProperties() { char streamType[GUID_SIZE] = ""; getGUID(guidBuf, streamType); - const TagVocabulary* tv; - tv = find(GUIDReferenceTags, streamType); + auto tv = Exiv2::find(GUIDReferenceTags, streamType); io_->read(guidBuf, GUI_SIZE); if (compareTag(exvGettext(tv->label_), "Audio_Media")) @@ -632,7 +629,7 @@ void AsfVideo::fileProperties() { const TagDetails* td; while (count--) { - td = find(filePropertiesTags, (count + 1)); + td = Exiv2::find(filePropertiesTags, (count + 1)); io_->read(buf.data(), BUFF_MIN_SIZE); if (count == 0) { diff --git a/src/convert.cpp b/src/convert.cpp index 577fd08000..28aba7e5a6 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1553,8 +1553,8 @@ const ConvFctList convFctList[] = { [[maybe_unused]] bool convertStringCharsetWindows(std::string& str, const char* from, const char* to) { bool ret = false; - const ConvFctList* p = find(convFctList, std::pair(from, to)); std::string tmpstr = str; + auto p = Exiv2::find(convFctList, std::pair(from, to)); if (p) ret = p->convFct_(tmpstr); #ifndef SUPPRESS_WARNINGS diff --git a/src/epsimage.cpp b/src/epsimage.cpp index 9189de1d2d..43b865a6e5 100644 --- a/src/epsimage.cpp +++ b/src/epsimage.cpp @@ -36,7 +36,7 @@ using namespace Exiv2::Internal; constexpr auto dosEpsSignature = std::string_view("\xC5\xD0\xD3\xC6"); // first line of EPS -constexpr auto epsFirstLine = std::array{ +constexpr std::string_view epsFirstLine[] = { "%!PS-Adobe-3.0 EPSF-3.0", "%!PS-Adobe-3.0 EPSF-3.0 ", // OpenOffice "%!PS-Adobe-3.1 EPSF-3.0", // Illustrator @@ -317,7 +317,7 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList #ifdef DEBUG EXV_DEBUG << "readWriteEpsMetadata: First line: " << firstLine << "\n"; #endif - bool matched = std::find(epsFirstLine.begin(), epsFirstLine.end(), firstLine) != epsFirstLine.end(); + auto matched = Exiv2::find(epsFirstLine, firstLine); if (!matched) { throw Error(ErrorCode::kerNotAnImage, "EPS"); } diff --git a/src/fujimn_int.cpp b/src/fujimn_int.cpp index 7a8f916182..9ffdbdba4c 100644 --- a/src/fujimn_int.cpp +++ b/src/fujimn_int.cpp @@ -241,7 +241,7 @@ std::ostream& printFujiDriveSetting(std::ostream& os, const Value& value, const auto byte3 = (value.toInt64() >> 16) & 0xff; auto fps = value.toInt64() >> 24; - auto setting = find(fujiDriveSettingByte1, byte1); + auto setting = Exiv2::find(fujiDriveSettingByte1, byte1); if (setting) { os << exvGettext(setting->label_); } else { @@ -347,7 +347,7 @@ std::ostream& printFujiFaceElementTypes(std::ostream& os, const Value& value, co longValue -= '0'; } - auto td = find(fujiFaceElementType, longValue); + auto td = Exiv2::find(fujiFaceElementType, longValue); if (n != 0) { os << " "; } diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 00064c2c01..36c4a417c2 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -137,16 +137,16 @@ bool TiffMnRegistry::operator==(IfdId key) const { TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, const std::string& make, const byte* pData, size_t size, ByteOrder byteOrder) { - auto tmr = std::find(std::begin(registry_), std::end(registry_), make); - if (tmr != std::end(registry_)) { - return tmr->newMnFct_(tag, group, tmr->mnGroup_, pData, size, byteOrder); + auto tmr = Exiv2::find(registry_, make); + if (!tmr) { + return nullptr; } - return nullptr; + return tmr->newMnFct_(tag, group, tmr->mnGroup_, pData, size, byteOrder); } // TiffMnCreator::create TiffComponent* TiffMnCreator::create(uint16_t tag, IfdId group, IfdId mnGroup) { - auto tmr = std::find(std::begin(registry_), std::end(registry_), mnGroup); - if (tmr != std::end(registry_)) { + auto tmr = Exiv2::find(registry_, mnGroup); + if (tmr) { if (tmr->newMnFct2_) { return tmr->newMnFct2_(tag, group, mnGroup); } @@ -859,35 +859,46 @@ struct NikonArrayIdx { #define NA ((uint32_t)-1) //! Nikon binary array version lookup table -constexpr auto nikonArrayIdx = std::array{ +constexpr NikonArrayIdx nikonArrayIdx[] = { // NikonSi - NikonArrayIdx{0x0091, "0208", 0, 0, 4}, // D80 - NikonArrayIdx{0x0091, "0209", 0, 1, 4}, // D40 - NikonArrayIdx{0x0091, "0210", 5291, 2, 4}, // D300 - NikonArrayIdx{0x0091, "0210", 5303, 3, 4}, // D300, firmware version 1.10 - NikonArrayIdx{0x0091, "02", 0, 4, 4}, // Other v2.* (encrypted) - NikonArrayIdx{0x0091, "01", 0, 5, NA}, // Other v1.* (not encrypted) + {0x0091, "0208", 0, 0, 4}, // D80 + {0x0091, "0209", 0, 1, 4}, // D40 + {0x0091, "0210", 5291, 2, 4}, // D300 + {0x0091, "0210", 5303, 3, 4}, // D300, firmware version 1.10 + {0x0091, "02", 0, 4, 4}, // Other v2.* (encrypted) + {0x0091, "01", 0, 5, NA}, // Other v1.* (not encrypted) // NikonCb - NikonArrayIdx{0x0097, "0100", 0, 0, NA}, NikonArrayIdx{0x0097, "0102", 0, 1, NA}, - NikonArrayIdx{0x0097, "0103", 0, 4, NA}, NikonArrayIdx{0x0097, "0205", 0, 2, 4}, - NikonArrayIdx{0x0097, "0209", 0, 5, 284}, NikonArrayIdx{0x0097, "0212", 0, 5, 284}, - NikonArrayIdx{0x0097, "0214", 0, 5, 284}, NikonArrayIdx{0x0097, "02", 0, 3, 284}, + {0x0097, "0100", 0, 0, NA}, + {0x0097, "0102", 0, 1, NA}, + {0x0097, "0103", 0, 4, NA}, + {0x0097, "0205", 0, 2, 4}, + {0x0097, "0209", 0, 5, 284}, + {0x0097, "0212", 0, 5, 284}, + {0x0097, "0214", 0, 5, 284}, + {0x0097, "02", 0, 3, 284}, // NikonLd - NikonArrayIdx{0x0098, "0100", 0, 0, NA}, NikonArrayIdx{0x0098, "0101", 0, 1, NA}, - NikonArrayIdx{0x0098, "0201", 0, 1, 4}, NikonArrayIdx{0x0098, "0202", 0, 1, 4}, - NikonArrayIdx{0x0098, "0203", 0, 1, 4}, NikonArrayIdx{0x0098, "0204", 0, 2, 4}, - NikonArrayIdx{0x0098, "0800", 0, 3, 4}, // for e.g. Z6/7 - NikonArrayIdx{0x0098, "0801", 0, 3, 4}, // for e.g. Z6/7 - NikonArrayIdx{0x0098, "0802", 0, 3, 4}, // for e.g. Z9 + {0x0098, "0100", 0, 0, NA}, + {0x0098, "0101", 0, 1, NA}, + {0x0098, "0201", 0, 1, 4}, + {0x0098, "0202", 0, 1, 4}, + {0x0098, "0203", 0, 1, 4}, + {0x0098, "0204", 0, 2, 4}, + {0x0098, "0800", 0, 3, 4}, // for e.g. Z6/7 + {0x0098, "0801", 0, 3, 4}, // for e.g. Z6/7 + {0x0098, "0802", 0, 3, 4}, // for e.g. Z9 // NikonFl - NikonArrayIdx{0x00a8, "0100", 0, 0, NA}, NikonArrayIdx{0x00a8, "0101", 0, 0, NA}, - NikonArrayIdx{0x00a8, "0102", 0, 1, NA}, NikonArrayIdx{0x00a8, "0103", 0, 2, NA}, - NikonArrayIdx{0x00a8, "0104", 0, 2, NA}, NikonArrayIdx{0x00a8, "0105", 0, 2, NA}, - NikonArrayIdx{0x00a8, "0106", 0, 3, NA}, NikonArrayIdx{0x00a8, "0107", 0, 4, NA}, - NikonArrayIdx{0x00a8, "0108", 0, 4, NA}, + {0x00a8, "0100", 0, 0, NA}, + {0x00a8, "0101", 0, 0, NA}, + {0x00a8, "0102", 0, 1, NA}, + {0x00a8, "0103", 0, 2, NA}, + {0x00a8, "0104", 0, 2, NA}, + {0x00a8, "0105", 0, 2, NA}, + {0x00a8, "0106", 0, 3, NA}, + {0x00a8, "0107", 0, 4, NA}, + {0x00a8, "0108", 0, 4, NA}, // NikonAf - NikonArrayIdx{0x00b7, "0100", 30, 0, NA}, // These sizes have been found in tiff headers of MN - NikonArrayIdx{0x00b7, "0101", 84, 1, NA}, // tag 0xb7 in sample image metadata for each version + {0x00b7, "0100", 30, 0, NA}, // These sizes have been found in tiff headers of MN + {0x00b7, "0101", 84, 1, NA}, // tag 0xb7 in sample image metadata for each version }; int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* /*pRoot*/) { @@ -895,8 +906,8 @@ int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* / return -1; auto ix = NikonArrayIdx::Key(tag, reinterpret_cast(pData), size); - auto it = std::find(nikonArrayIdx.begin(), nikonArrayIdx.end(), ix); - if (it == nikonArrayIdx.end()) + auto it = Exiv2::find(nikonArrayIdx, ix); + if (!it) return -1; return it->idx_; @@ -907,9 +918,8 @@ DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* if (size < 4) return buf; - auto nci = std::find(nikonArrayIdx.begin(), nikonArrayIdx.end(), - NikonArrayIdx::Key(tag, reinterpret_cast(pData), size)); - if (nci == nikonArrayIdx.end() || nci->start_ == NA || size <= nci->start_) + auto nci = Exiv2::find(nikonArrayIdx, NikonArrayIdx::Key(tag, reinterpret_cast(pData), size)); + if (!nci || nci->start_ == NA || size <= nci->start_) return buf; // Find Exif.Nikon3.ShutterCount @@ -955,12 +965,12 @@ int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, Tif return idx; } int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) { - static constexpr auto models = std::array{ + static constexpr const char* models[] = { "SLT-A58", "SLT-A99", "ILCE-3000", "ILCE-3500", "NEX-3N", "NEX-5R", "NEX-5T", "NEX-6", "VG30E", "VG900", "DSC-RX100", "DSC-RX1", "DSC-RX1R", "DSC-HX300", "DSC-HX50V", "DSC-TX30", "DSC-WX60", "DSC-WX200", "DSC-WX300", }; - return std::find(models.begin(), models.end(), getExifModel(pRoot)) != models.end() ? 0 : -1; + return Exiv2::find(models, getExifModel(pRoot)) ? 0 : -1; } int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) { diff --git a/src/minoltamn_int.cpp b/src/minoltamn_int.cpp index a9b9806439..a7c6ca8485 100644 --- a/src/minoltamn_int.cpp +++ b/src/minoltamn_int.cpp @@ -1483,7 +1483,7 @@ static bool inRange(long value, long min, long max) { } static std::ostream& resolvedLens(std::ostream& os, long lensID, long index) { - const TagDetails* td = find(minoltaSonyLensID, lensID); + auto td = Exiv2::find(minoltaSonyLensID, lensID); std::vector tokens = split(td[0].label_, "|"); return os << exvGettext(trim(tokens.at(index - 1)).c_str()); } @@ -1606,7 +1606,7 @@ static std::ostream& resolveLens0xffff(std::ostream& os, const Value& value, con std::string maxAperture = getKeyString("Exif.Photo.MaxApertureValue", metadata); std::string F1_8 = "434/256"; - static constexpr auto maxApertures = std::array{ + static constexpr const char* maxApertures[] = { "926/256", // F3.5 "1024/256", // F4 "1110/256", // F4.5 @@ -1626,7 +1626,7 @@ static std::ostream& resolveLens0xffff(std::ostream& os, const Value& value, con } catch (...) { } - if (model == "ILCE-6000" && std::find(maxApertures.begin(), maxApertures.end(), maxAperture) != maxApertures.end()) + if (model == "ILCE-6000" && Exiv2::find(maxApertures, maxAperture)) try { long focalLength = getKeyLong("Exif.Photo.FocalLength", metadata); if (focalLength > 0) { diff --git a/src/nikonmn_int.cpp b/src/nikonmn_int.cpp index 9aacdae9c3..dce90acfe5 100644 --- a/src/nikonmn_int.cpp +++ b/src/nikonmn_int.cpp @@ -3791,7 +3791,7 @@ std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value, if (l != 0) trim = false; std::string d = s.empty() ? "" : "; "; - const TagDetails* td = find(nikonRetouchHistory, l); + auto td = Exiv2::find(nikonRetouchHistory, l); if (td) { s = std::string(exvGettext(td->label_)).append(d).append(s); } else { diff --git a/src/pentaxmn_int.cpp b/src/pentaxmn_int.cpp index 257e1e7d08..88cb7e8c16 100644 --- a/src/pentaxmn_int.cpp +++ b/src/pentaxmn_int.cpp @@ -1096,7 +1096,7 @@ std::ostream& resolveLens0x32c(std::ostream& os, const Value& value, const ExifD if (index > 0) { const unsigned long lensID = 0x32c; - const TagDetails* td = find(pentaxLensType, lensID); + auto td = Exiv2::find(pentaxLensType, lensID); os << exvGettext(td[index].label_); return os; } @@ -1160,7 +1160,7 @@ std::ostream& resolveLens0x3ff(std::ostream& os, const Value& value, const ExifD if (index > 0) { const unsigned long lensID = 0x3ff; - const TagDetails* td = find(pentaxLensType, lensID); + auto td = Exiv2::find(pentaxLensType, lensID); os << exvGettext(td[index].label_); return os; } @@ -1187,7 +1187,7 @@ std::ostream& resolveLens0x8ff(std::ostream& os, const Value& value, const ExifD if (index > 0) { const unsigned long lensID = 0x8ff; - const TagDetails* td = find(pentaxLensType, lensID); + auto td = Exiv2::find(pentaxLensType, lensID); os << exvGettext(td[index].label_); return os; } @@ -1221,7 +1221,7 @@ std::ostream& resolveLens0x319(std::ostream& os, const Value& value, const ExifD if (index > 0) { const unsigned long lensID = 0x319; - const TagDetails* td = find(pentaxLensType, lensID); + auto td = Exiv2::find(pentaxLensType, lensID); os << exvGettext(td[index].label_); return os; } @@ -1245,12 +1245,11 @@ struct LensIdFct { }; //! List of lens ids which require special treatment using resolveLensType -constexpr auto lensIdFct = std::array{ - LensIdFct{0x0317, resolveLensType}, LensIdFct{0x0319, resolveLens0x319}, LensIdFct{0x031b, resolveLensType}, - LensIdFct{0x031c, resolveLensType}, LensIdFct{0x031d, resolveLensType}, LensIdFct{0x031f, resolveLensType}, - LensIdFct{0x0329, resolveLensType}, LensIdFct{0x032c, resolveLens0x32c}, LensIdFct{0x032e, resolveLensType}, - LensIdFct{0x0334, resolveLensType}, LensIdFct{0x03ff, resolveLens0x3ff}, LensIdFct{0x041a, resolveLensType}, - LensIdFct{0x042d, resolveLensType}, LensIdFct{0x08ff, resolveLens0x8ff}, +constexpr LensIdFct lensIdFct[] = { + {0x0317, resolveLensType}, {0x0319, resolveLens0x319}, {0x031b, resolveLensType}, {0x031c, resolveLensType}, + {0x031d, resolveLensType}, {0x031f, resolveLensType}, {0x0329, resolveLensType}, {0x032c, resolveLens0x32c}, + {0x032e, resolveLensType}, {0x0334, resolveLensType}, {0x03ff, resolveLens0x3ff}, {0x041a, resolveLensType}, + {0x042d, resolveLensType}, {0x08ff, resolveLens0x8ff}, }; //! A lens id and a pretty-print function for special treatment of the id. @@ -1265,8 +1264,8 @@ std::ostream& printLensType(std::ostream& os, const Value& value, const ExifData const auto index = value.toUint32(0) * 256 + value.toUint32(1); // std::cout << std::endl << "printLensType value =" << value.toLong() << " index = " << index << std::endl; - auto lif = std::find(lensIdFct.begin(), lensIdFct.end(), index); - if (lif == lensIdFct.end()) + auto lif = Exiv2::find(lensIdFct, index); + if (!lif) return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata); if (metadata && lif->fct_) return lif->fct_(os, value, metadata); diff --git a/src/pentaxmn_int.hpp b/src/pentaxmn_int.hpp index 1219fae662..94f114980f 100644 --- a/src/pentaxmn_int.hpp +++ b/src/pentaxmn_int.hpp @@ -70,7 +70,7 @@ std::ostream& printCombiTag(std::ostream& os, const Value& value, const ExifData } l += (value.toUint32(c) << ((count - c - 1) * 8)); } - const TagDetails* td = find(array, l); + auto td = Exiv2::find(array, l); if (td) { os << exvGettext(td->label_); } else { diff --git a/src/properties.cpp b/src/properties.cpp index 005e2aa838..b63bee5db4 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -5003,7 +5003,7 @@ std::string XmpProperties::prefix(const std::string& ns) { if (i != nsRegistry_.end()) { p = i->second.prefix_; } else { - const XmpNsInfo* xn = find(xmpNsInfo, XmpNsInfo::Ns(ns2)); + auto xn = Exiv2::find(xmpNsInfo, XmpNsInfo::Ns(ns2)); if (xn) p = std::string(xn->prefix_); } @@ -5082,7 +5082,7 @@ const XmpNsInfo* XmpProperties::nsInfoUnsafe(const std::string& prefix) { const XmpNsInfo::Prefix pf(prefix); const XmpNsInfo* xn = lookupNsRegistryUnsafe(pf); if (!xn) - xn = find(xmpNsInfo, pf); + xn = Exiv2::find(xmpNsInfo, pf); if (!xn) throw Error(ErrorCode::kerNoNamespaceInfoForXmpPrefix, prefix); return xn; @@ -5108,7 +5108,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) { PrintFct fct = printValue; if (value.count() != 0) { - const XmpPrintInfo* info = find(xmpPrintInfo, key); + auto info = Exiv2::find(xmpPrintInfo, key); if (info) fct = info->printFct_; } diff --git a/src/quicktimevideo.cpp b/src/quicktimevideo.cpp index 850fe58dff..487aa4a838 100644 --- a/src/quicktimevideo.cpp +++ b/src/quicktimevideo.cpp @@ -775,7 +775,7 @@ void QuickTimeVideo::CameraTagsDecoder(size_t size_external) { buf.read_uint32(0, littleEndian) / static_cast(buf2.read_uint32(0, littleEndian)); io_->readOrThrow(buf.data(), 10); io_->readOrThrow(buf.data(), 4); - td = find(whiteBalance, buf.read_uint32(0, littleEndian)); + td = Exiv2::find(whiteBalance, buf.read_uint32(0, littleEndian)); if (td) xmpData_["Xmp.video.WhiteBalance"] = exvGettext(td->label_); io_->readOrThrow(buf.data(), 4); @@ -814,9 +814,9 @@ void QuickTimeVideo::userDataDecoder(size_t size_external) { if (buf.data()[0] == 169) buf.data()[0] = ' '; - td = find(userDatatags, Exiv2::toString(buf.data())); + td = Exiv2::find(userDatatags, Exiv2::toString(buf.data())); - tv = find(userDataReferencetags, Exiv2::toString(buf.data())); + tv = Exiv2::find(userDataReferencetags, Exiv2::toString(buf.data())); if (size <= 12) break; @@ -840,7 +840,7 @@ void QuickTimeVideo::userDataDecoder(size_t size_external) { enforce(tv, Exiv2::ErrorCode::kerCorruptedMetadata); io_->readOrThrow(buf.data(), 2); buf.data()[2] = '\0'; - tv_internal = find(cameraByteOrderTags, Exiv2::toString(buf.data())); + tv_internal = Exiv2::find(cameraByteOrderTags, Exiv2::toString(buf.data())); if (tv_internal) xmpData_[exvGettext(tv->label_)] = exvGettext(tv_internal->label_); @@ -870,7 +870,7 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { for (int i = 0; i < 100; i++) { io_->readOrThrow(buf.data(), 4); TagID = buf.read_uint32(0, bigEndian); - td = find(NikonNCTGTags, TagID); + td = Exiv2::find(NikonNCTGTags, TagID); io_->readOrThrow(buf.data(), 2); dataType = buf.read_uint16(0, bigEndian); @@ -893,40 +893,40 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { std::memset(buf.data(), 0x0, buf.size()); io_->readOrThrow(buf.data(), 1); - td2 = find(PictureControlAdjust, static_cast(buf.data()[0]) & 7); + td2 = Exiv2::find(PictureControlAdjust, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.PictureControlAdjust"] = exvGettext(td2->label_); else xmpData_["Xmp.video.PictureControlAdjust"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); + td2 = Exiv2::find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.PictureControlQuickAdjust"] = exvGettext(td2->label_); io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); + td2 = Exiv2::find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Sharpness"] = exvGettext(td2->label_); else xmpData_["Xmp.video.Sharpness"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); + td2 = Exiv2::find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Contrast"] = exvGettext(td2->label_); else xmpData_["Xmp.video.Contrast"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(NormalSoftHard, static_cast(buf.data()[0]) & 7); + td2 = Exiv2::find(NormalSoftHard, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Brightness"] = exvGettext(td2->label_); else xmpData_["Xmp.video.Brightness"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(Saturation, static_cast(buf.data()[0]) & 7); + td2 = Exiv2::find(Saturation, static_cast(buf.data()[0]) & 7); if (td2) xmpData_["Xmp.video.Saturation"] = exvGettext(td2->label_); else @@ -936,14 +936,14 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { xmpData_["Xmp.video.HueAdjustment"] = static_cast(buf.data()[0]) & 7; io_->readOrThrow(buf.data(), 1); - td2 = find(FilterEffect, static_cast(buf.data()[0])); + td2 = Exiv2::find(FilterEffect, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.FilterEffect"] = exvGettext(td2->label_); else xmpData_["Xmp.video.FilterEffect"] = static_cast(buf.data()[0]); io_->readOrThrow(buf.data(), 1); - td2 = find(ToningEffect, static_cast(buf.data()[0])); + td2 = Exiv2::find(ToningEffect, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.ToningEffect"] = exvGettext(td2->label_); else @@ -963,12 +963,12 @@ void QuickTimeVideo::NikonTagsDecoder(size_t size_external) { io_->readOrThrow(buf.data(), 2); xmpData_["Xmp.video.TimeZone"] = Exiv2::getShort(buf.data(), bigEndian); io_->readOrThrow(buf.data(), 1); - td2 = find(YesNo, static_cast(buf.data()[0])); + td2 = Exiv2::find(YesNo, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.DayLightSavings"] = exvGettext(td2->label_); io_->readOrThrow(buf.data(), 1); - td2 = find(DateDisplayFormat, static_cast(buf.data()[0])); + td2 = Exiv2::find(DateDisplayFormat, static_cast(buf.data()[0])); if (td2) xmpData_["Xmp.video.DateDisplayFormat"] = exvGettext(td2->label_); @@ -1143,14 +1143,14 @@ void QuickTimeVideo::audioDescDecoder() { io_->readOrThrow(buf.data(), 4); switch (i) { case AudioFormat: - td = find(qTimeFileType, Exiv2::toString(buf.data())); + td = Exiv2::find(qTimeFileType, Exiv2::toString(buf.data())); if (td) xmpData_["Xmp.audio.Compressor"] = exvGettext(td->label_); else xmpData_["Xmp.audio.Compressor"] = Exiv2::toString(buf.data()); break; case AudioVendorID: - td = find(vendorIDTags, Exiv2::toString(buf.data())); + td = Exiv2::find(vendorIDTags, Exiv2::toString(buf.data())); if (td) xmpData_["Xmp.audio.VendorID"] = exvGettext(td->label_); break; @@ -1183,14 +1183,14 @@ void QuickTimeVideo::imageDescDecoder() { switch (i) { case codec: - td = find(qTimeFileType, Exiv2::toString(buf.data())); + td = Exiv2::find(qTimeFileType, Exiv2::toString(buf.data())); if (td) xmpData_["Xmp.video.Codec"] = exvGettext(td->label_); else xmpData_["Xmp.video.Codec"] = Exiv2::toString(buf.data()); break; case VendorID: - td = find(vendorIDTags, Exiv2::toString(buf.data())); + td = Exiv2::find(vendorIDTags, Exiv2::toString(buf.data())); if (td) xmpData_["Xmp.video.VendorID"] = exvGettext(td->label_); break; @@ -1247,7 +1247,7 @@ void QuickTimeVideo::videoHeaderDecoder(size_t size) { switch (i) { case GraphicsMode: - td = find(graphicsModetags, buf.read_uint16(0, bigEndian)); + td = Exiv2::find(graphicsModetags, buf.read_uint16(0, bigEndian)); if (td) xmpData_["Xmp.video.GraphicsMode"] = exvGettext(td->label_); break; @@ -1274,7 +1274,7 @@ void QuickTimeVideo::handlerDecoder(size_t size) { switch (i) { case HandlerClass: - tv = find(handlerClassTags, Exiv2::toString(buf.data())); + tv = Exiv2::find(handlerClassTags, Exiv2::toString(buf.data())); if (tv) { if (currentStream_ == Video) xmpData_["Xmp.video.HandlerClass"] = exvGettext(tv->label_); @@ -1283,7 +1283,7 @@ void QuickTimeVideo::handlerDecoder(size_t size) { } break; case HandlerType: - tv = find(handlerTypeTags, Exiv2::toString(buf.data())); + tv = Exiv2::find(handlerTypeTags, Exiv2::toString(buf.data())); if (tv) { if (currentStream_ == Video) xmpData_["Xmp.video.HandlerType"] = exvGettext(tv->label_); @@ -1292,7 +1292,7 @@ void QuickTimeVideo::handlerDecoder(size_t size) { } break; case HandlerVendorID: - tv = find(vendorIDTags, Exiv2::toString(buf.data())); + tv = Exiv2::find(vendorIDTags, Exiv2::toString(buf.data())); if (tv) { if (currentStream_ == Video) xmpData_["Xmp.video.HandlerVendorID"] = exvGettext(tv->label_); @@ -1314,7 +1314,7 @@ void QuickTimeVideo::fileTypeDecoder(size_t size) { for (int i = 0; size / 4 != 0; size -= 4, i++) { io_->readOrThrow(buf.data(), 4); - td = find(qTimeFileType, Exiv2::toString(buf.data())); + td = Exiv2::find(qTimeFileType, Exiv2::toString(buf.data())); switch (i) { case 0: @@ -1598,7 +1598,7 @@ bool isQTimeType(BasicIo& iIo, bool advance) { // we only match if we actually know the video type. This is done // to avoid matching just on ftyp because bmffimage also has that // header. - auto td = find(qTimeFileType, std::string{buf.c_str(8), 4}); + auto td = Exiv2::find(qTimeFileType, std::string{buf.c_str(8), 4}); if (td) { matched = true; } diff --git a/src/riffvideo.cpp b/src/riffvideo.cpp index f4f7e6a17c..fca4d38a37 100644 --- a/src/riffvideo.cpp +++ b/src/riffvideo.cpp @@ -772,7 +772,7 @@ void RiffVideo::nikonTagsHandler() { io_->read(buf.data(), 2); dataSize = Exiv2::getULong(buf.data(), littleEndian); temp -= (RIFF_TAG_SIZE + dataSize); - td = find(nikonAVITags, tagID); + td = Exiv2::find(nikonAVITags, tagID); if (dataSize <= 0) { #ifndef SUPPRESS_WARNINGS @@ -861,7 +861,7 @@ void RiffVideo::infoTagsHandler() { size -= RIFF_TAG_SIZE; if (!Exiv2::getULong(buf.data(), littleEndian)) break; - tv = find(infoTags, Exiv2::toString(buf.data())); + tv = Exiv2::find(infoTags, Exiv2::toString(buf.data())); io_->read(buf.data(), RIFF_TAG_SIZE); size -= RIFF_TAG_SIZE; infoSize = Exiv2::getULong(buf.data(), littleEndian); @@ -1132,7 +1132,7 @@ void RiffVideo::streamFormatHandler(size_t size) { switch (tag) { case encoding: - td = find(audioEncodingValues, Exiv2::getUShort(buf.data(), littleEndian)); + td = Exiv2::find(audioEncodingValues, Exiv2::getUShort(buf.data(), littleEndian)); if (td) { xmpData_["Xmp.audio.Compressor"] = exvGettext(td->label_); } else { @@ -1175,8 +1175,7 @@ double RiffVideo::returnSampleRate(Exiv2::DataBuf& buf, size_t divisor) { } // RiffVideo::returnSampleRate const char* RiffVideo::printAudioEncoding(uint64_t i) { - const TagDetails* td; - td = find(audioEncodingValues, i); + auto td = Exiv2::find(audioEncodingValues, i); if (td) return exvGettext(td->label_); diff --git a/src/sonymn_int.cpp b/src/sonymn_int.cpp index 213d2b8a56..5d2b98009f 100644 --- a/src/sonymn_int.cpp +++ b/src/sonymn_int.cpp @@ -2077,7 +2077,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream& // Tag only valid for certain camera models. See // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8170 - static constexpr auto models = std::array{ + static constexpr const char* models[] = { "ILCA-68", "ILCA-77M2", "ILCA-99M2", "ILCE-5000", "ILCE-5100", "ILCE-6000", "ILCE-6300", "ILCE-6500", "ILCE-7", "ILCE-7M2", "ILCE-7R", "ILCE-7RM2", "ILCE-7S", "ILCE-7SM2", "ILCE-7SM5", "ILCE-QX1", "DSC-HX350", "DSC-HX400V", "DSC-HX60V", "DSC-HX80", "DSC-HX90", @@ -2085,7 +2085,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream& "DSC-RX100M3", "DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500", }; - if (std::find(models.begin(), models.end(), model) != models.end()) { + if (Exiv2::find(models, model)) { return os << value.toInt64(); } return os << N_("n/a"); @@ -2110,9 +2110,9 @@ std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Val // Tag only valid for certain camera models. See // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8219 - constexpr std::array models{"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"}; + constexpr const char* models[] = {"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"}; - if (std::find(models.begin(), models.end(), model) != models.end()) { + if (Exiv2::find(models, model)) { EXV_PRINT_TAG(sonyMisc3cQuality2a)(os, val, metadata); return os; } @@ -2133,9 +2133,9 @@ std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, co // Tag only valid for certain camera models. See // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8239 - constexpr std::array models{"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"}; + constexpr const char* models[] = {"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"}; - if (std::find(models.begin(), models.end(), model) != models.end()) { + if (Exiv2::find(models, model)) { return os << N_("n/a"); } const auto val = value.toInt64(); @@ -2156,9 +2156,9 @@ std::ostream& SonyMakerNote::printSonyMisc3cModelReleaseYear(std::ostream& os, c // Tag only valid for certain camera models. See // https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8245 - constexpr std::array models{"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"}; + constexpr const char* models[] = {"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"}; - if (std::find(models.begin(), models.end(), model) != models.end()) { + if (Exiv2::find(models, model)) { return os << N_("n/a"); } diff --git a/src/tags_int.cpp b/src/tags_int.cpp index 8d61f7cc5c..1fb67e34c9 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2320,7 +2320,7 @@ const TagInfo* mnTagList() { bool isMakerIfd(IfdId ifdId) { bool rc = false; - const GroupInfo* ii = find(groupInfo, ifdId); + auto ii = Exiv2::find(groupInfo, ifdId); if (ii && 0 == strcmp(ii->ifdName_, "Makernote")) { rc = true; } @@ -2364,7 +2364,7 @@ void taglist(std::ostream& os, IfdId ifdId) { } // taglist const TagInfo* tagList(IfdId ifdId) { - const GroupInfo* ii = find(groupInfo, ifdId); + auto ii = Exiv2::find(groupInfo, ifdId); if (!ii || !ii->tagList_) return nullptr; return ii->tagList_(); @@ -2399,21 +2399,21 @@ const TagInfo* tagInfo(const std::string& tagName, IfdId ifdId) { IfdId groupId(const std::string& groupName) { IfdId ifdId = IfdId::ifdIdNotSet; - const GroupInfo* ii = find(groupInfo, GroupInfo::GroupName(groupName)); + auto ii = Exiv2::find(groupInfo, GroupInfo::GroupName(groupName)); if (ii) ifdId = static_cast(ii->ifdId_); return ifdId; } const char* ifdName(IfdId ifdId) { - const GroupInfo* ii = find(groupInfo, ifdId); + auto ii = Exiv2::find(groupInfo, ifdId); if (!ii) return groupInfo[0].ifdName_; return ii->ifdName_; } const char* groupName(IfdId ifdId) { - const GroupInfo* ii = find(groupInfo, ifdId); + auto ii = Exiv2::find(groupInfo, ifdId); if (!ii) return groupInfo[0].groupName_; return ii->groupName_; @@ -3047,7 +3047,7 @@ const GroupInfo* groupList() { } const TagInfo* tagList(const std::string& groupName) { - const GroupInfo* ii = find(groupInfo, GroupInfo::GroupName(groupName)); + auto ii = Exiv2::find(groupInfo, GroupInfo::GroupName(groupName)); if (!ii || !ii->tagList_) { return nullptr; } diff --git a/src/tags_int.hpp b/src/tags_int.hpp index 5eaa1afee6..6dca64a31d 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -95,7 +95,7 @@ struct TagVocabulary { */ template std::ostream& printTagString(std::ostream& os, const std::string value, const ExifData*) { - const StringTagDetails* td = find(array, value); + auto td = Exiv2::find(array, value); if (td) { os << exvGettext(td->label_); } else { @@ -152,7 +152,7 @@ std::ostream& printTagString4(std::ostream& os, const Value& value, const ExifDa */ template std::ostream& printTagNoError(std::ostream& os, const int64_t value, const ExifData*) { - const TagDetails* td = find(array, value); + auto td = Exiv2::find(array, value); if (td) { os << exvGettext(td->label_); } else { @@ -179,7 +179,7 @@ std::ostream& printTagNoError(std::ostream& os, const Value& value, const ExifDa */ template std::ostream& printTag(std::ostream& os, const int64_t value, const ExifData*) { - const TagDetails* td = find(array, value); + auto td = Exiv2::find(array, value); if (td) { os << exvGettext(td->label_); } else { @@ -300,7 +300,7 @@ std::ostream& printTagBitlistAllLE(std::ostream& os, const Value& value, const E */ template std::ostream& printTagVocabulary(std::ostream& os, const Value& value, const ExifData*) { - const TagVocabulary* td = find(array, value.toString()); + auto td = Exiv2::find(array, value.toString()); if (td) { os << exvGettext(td->label_); } else { @@ -322,7 +322,7 @@ std::ostream& printTagVocabularyMulti(std::ostream& os, const Value& value, cons for (size_t i = 0; i < value.count(); i++) { if (i != 0) os << ", "; - const TagVocabulary* td = find(array, value.toString(i)); + auto td = Exiv2::find(array, value.toString(i)); if (td) { os << exvGettext(td->label_); } else { diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index 26a789c378..8dcf3bd7bb 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -1967,7 +1967,7 @@ const TiffMappingInfo TiffMapping::tiffMappingInfo_[] = { DecoderFct TiffMapping::findDecoder(const std::string& make, uint32_t extendedTag, IfdId group) { DecoderFct decoderFct = &TiffDecoder::decodeStdTiffEntry; - const TiffMappingInfo* td = find(tiffMappingInfo_, TiffMappingInfo::Key(make, extendedTag, group)); + auto td = Exiv2::find(tiffMappingInfo_, TiffMappingInfo::Key(make, extendedTag, group)); if (td) { // This may set decoderFct to 0, meaning that the tag should not be decoded decoderFct = td->decoderFct_; @@ -1977,7 +1977,7 @@ DecoderFct TiffMapping::findDecoder(const std::string& make, uint32_t extendedTa EncoderFct TiffMapping::findEncoder(const std::string& make, uint32_t extendedTag, IfdId group) { EncoderFct encoderFct = nullptr; - const TiffMappingInfo* td = find(tiffMappingInfo_, TiffMappingInfo::Key(make, extendedTag, group)); + auto td = Exiv2::find(tiffMappingInfo_, TiffMappingInfo::Key(make, extendedTag, group)); if (td) { // Returns 0 if no special encoder function is found encoderFct = td->encoderFct_; diff --git a/src/types.cpp b/src/types.cpp index 9b9e57309b..04a27b91d6 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -22,7 +22,7 @@ // ***************************************************************************** namespace { //! Information pertaining to the defined %Exiv2 value type identifiers. -struct TypeInfoTable { +constexpr struct TypeInfoTable { Exiv2::TypeId typeId_; //!< Type id const char* name_; //!< Name of the type size_t size_; //!< Bytes per data entry @@ -34,34 +34,32 @@ struct TypeInfoTable { bool operator==(const std::string& name) const { return name == name_; } -}; // struct TypeInfoTable - -//! Lookup list with information of Exiv2 types -constexpr auto typeInfoTable = std::array{ - TypeInfoTable{Exiv2::invalidTypeId, "Invalid", 0}, - TypeInfoTable{Exiv2::unsignedByte, "Byte", 1}, - TypeInfoTable{Exiv2::asciiString, "Ascii", 1}, - TypeInfoTable{Exiv2::unsignedShort, "Short", 2}, - TypeInfoTable{Exiv2::unsignedLong, "Long", 4}, - TypeInfoTable{Exiv2::unsignedRational, "Rational", 8}, - TypeInfoTable{Exiv2::signedByte, "SByte", 1}, - TypeInfoTable{Exiv2::undefined, "Undefined", 1}, - TypeInfoTable{Exiv2::signedShort, "SShort", 2}, - TypeInfoTable{Exiv2::signedLong, "SLong", 4}, - TypeInfoTable{Exiv2::signedRational, "SRational", 8}, - TypeInfoTable{Exiv2::tiffFloat, "Float", 4}, - TypeInfoTable{Exiv2::tiffDouble, "Double", 8}, - TypeInfoTable{Exiv2::tiffIfd, "Ifd", 4}, - TypeInfoTable{Exiv2::string, "String", 1}, - TypeInfoTable{Exiv2::date, "Date", 8}, - TypeInfoTable{Exiv2::time, "Time", 11}, - TypeInfoTable{Exiv2::comment, "Comment", 1}, - TypeInfoTable{Exiv2::directory, "Directory", 1}, - TypeInfoTable{Exiv2::xmpText, "XmpText", 1}, - TypeInfoTable{Exiv2::xmpAlt, "XmpAlt", 1}, - TypeInfoTable{Exiv2::xmpBag, "XmpBag", 1}, - TypeInfoTable{Exiv2::xmpSeq, "XmpSeq", 1}, - TypeInfoTable{Exiv2::langAlt, "LangAlt", 1}, +} typeInfoTable[] = { + //! Lookup list with information of Exiv2 types + {Exiv2::invalidTypeId, "Invalid", 0}, + {Exiv2::unsignedByte, "Byte", 1}, + {Exiv2::asciiString, "Ascii", 1}, + {Exiv2::unsignedShort, "Short", 2}, + {Exiv2::unsignedLong, "Long", 4}, + {Exiv2::unsignedRational, "Rational", 8}, + {Exiv2::signedByte, "SByte", 1}, + {Exiv2::undefined, "Undefined", 1}, + {Exiv2::signedShort, "SShort", 2}, + {Exiv2::signedLong, "SLong", 4}, + {Exiv2::signedRational, "SRational", 8}, + {Exiv2::tiffFloat, "Float", 4}, + {Exiv2::tiffDouble, "Double", 8}, + {Exiv2::tiffIfd, "Ifd", 4}, + {Exiv2::string, "String", 1}, + {Exiv2::date, "Date", 8}, + {Exiv2::time, "Time", 11}, + {Exiv2::comment, "Comment", 1}, + {Exiv2::directory, "Directory", 1}, + {Exiv2::xmpText, "XmpText", 1}, + {Exiv2::xmpAlt, "XmpAlt", 1}, + {Exiv2::xmpBag, "XmpBag", 1}, + {Exiv2::xmpSeq, "XmpSeq", 1}, + {Exiv2::langAlt, "LangAlt", 1}, }; } // namespace @@ -70,22 +68,22 @@ constexpr auto typeInfoTable = std::array{ // class member definitions namespace Exiv2 { const char* TypeInfo::typeName(TypeId typeId) { - auto tit = std::find(typeInfoTable.begin(), typeInfoTable.end(), typeId); - if (tit == typeInfoTable.end()) + auto tit = Exiv2::find(typeInfoTable, typeId); + if (!tit) return nullptr; return tit->name_; } TypeId TypeInfo::typeId(const std::string& typeName) { - auto tit = std::find(typeInfoTable.begin(), typeInfoTable.end(), typeName); - if (tit == typeInfoTable.end()) + auto tit = Exiv2::find(typeInfoTable, typeName); + if (!tit) return invalidTypeId; return tit->typeId_; } size_t TypeInfo::typeSize(TypeId typeId) { - auto tit = std::find(typeInfoTable.begin(), typeInfoTable.end(), typeId); - if (tit == typeInfoTable.end()) + auto tit = Exiv2::find(typeInfoTable, typeId); + if (!tit) return 0; return tit->size_; }