more std::find to Exiv2::find
The latter is simpler. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
7fd7ee62a3
commit
a7a9835431
@ -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<std::string_view, 3>{
|
||||
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");
|
||||
}
|
||||
|
||||
@ -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<const char*>(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<const char*>(pData), size));
|
||||
if (nci == nikonArrayIdx.end() || nci->start_ == NA || size <= nci->start_)
|
||||
auto nci = Exiv2::find(nikonArrayIdx, NikonArrayIdx::Key(tag, reinterpret_cast<const char*>(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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user