std::find to find template
std::find in C++20 can use ranges, which is equivalent here. Less error prone. Namespace is properly to avoid any conflicts with std::find or others Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
c9f7a9f34e
commit
7fd7ee62a3
@ -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) {
|
||||
|
||||
@ -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<const char*>(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) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 << " ";
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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<std::string> tokens = split(td[0].label_, "|");
|
||||
return os << exvGettext(trim(tokens.at(index - 1)).c_str());
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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_;
|
||||
}
|
||||
|
||||
@ -775,7 +775,7 @@ void QuickTimeVideo::CameraTagsDecoder(size_t size_external) {
|
||||
buf.read_uint32(0, littleEndian) / static_cast<double>(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<int>(buf.data()[0]) & 7);
|
||||
td2 = Exiv2::find(PictureControlAdjust, static_cast<int>(buf.data()[0]) & 7);
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.PictureControlAdjust"] = exvGettext(td2->label_);
|
||||
else
|
||||
xmpData_["Xmp.video.PictureControlAdjust"] = static_cast<int>(buf.data()[0]) & 7;
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.PictureControlQuickAdjust"] = exvGettext(td2->label_);
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.Sharpness"] = exvGettext(td2->label_);
|
||||
else
|
||||
xmpData_["Xmp.video.Sharpness"] = static_cast<int>(buf.data()[0]) & 7;
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.Contrast"] = exvGettext(td2->label_);
|
||||
else
|
||||
xmpData_["Xmp.video.Contrast"] = static_cast<int>(buf.data()[0]) & 7;
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
td2 = Exiv2::find(NormalSoftHard, static_cast<int>(buf.data()[0]) & 7);
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.Brightness"] = exvGettext(td2->label_);
|
||||
else
|
||||
xmpData_["Xmp.video.Brightness"] = static_cast<int>(buf.data()[0]) & 7;
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(Saturation, static_cast<int>(buf.data()[0]) & 7);
|
||||
td2 = Exiv2::find(Saturation, static_cast<int>(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<int>(buf.data()[0]) & 7;
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(FilterEffect, static_cast<int>(buf.data()[0]));
|
||||
td2 = Exiv2::find(FilterEffect, static_cast<int>(buf.data()[0]));
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.FilterEffect"] = exvGettext(td2->label_);
|
||||
else
|
||||
xmpData_["Xmp.video.FilterEffect"] = static_cast<int>(buf.data()[0]);
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(ToningEffect, static_cast<int>(buf.data()[0]));
|
||||
td2 = Exiv2::find(ToningEffect, static_cast<int>(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<int>(buf.data()[0]));
|
||||
td2 = Exiv2::find(YesNo, static_cast<int>(buf.data()[0]));
|
||||
if (td2)
|
||||
xmpData_["Xmp.video.DayLightSavings"] = exvGettext(td2->label_);
|
||||
|
||||
io_->readOrThrow(buf.data(), 1);
|
||||
td2 = find(DateDisplayFormat, static_cast<int>(buf.data()[0]));
|
||||
td2 = Exiv2::find(DateDisplayFormat, static_cast<int>(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;
|
||||
}
|
||||
|
||||
@ -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_);
|
||||
|
||||
|
||||
@ -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<IfdId>(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;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ struct TagVocabulary {
|
||||
*/
|
||||
template <size_t N, const StringTagDetails (&array)[N]>
|
||||
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 <size_t N, const TagDetails (&array)[N]>
|
||||
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 <size_t N, const TagDetails (&array)[N]>
|
||||
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 <size_t N, const TagVocabulary (&array)[N]>
|
||||
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 {
|
||||
|
||||
@ -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_;
|
||||
|
||||
@ -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_;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user