find_if conversion

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent 9766c4532d
commit 932d59a984

@ -550,18 +550,16 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) {
set value set value
*/ */
if (!crwDirs.empty()) { if (!crwDirs.empty()) {
auto [dir, parent] = crwDirs.top(); auto dir = crwDirs.top();
crwDirs.pop(); crwDirs.pop();
// Find the directory // Find the directory
for (auto&& component : components_) { auto it =
if (component->tag() == dir) { std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == dir.first; });
cc_ = component; if (it != components_.end())
break; cc_ = *it;
}
}
if (!cc_) { if (!cc_) {
// Directory doesn't exist yet, add it // Directory doesn't exist yet, add it
m_ = std::make_unique<CiffDirectory>(dir, parent); m_ = std::make_unique<CiffDirectory>(dir.first, dir.second);
cc_ = m_.get(); cc_ = m_.get();
add(std::move(m_)); add(std::move(m_));
} }
@ -569,12 +567,10 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) {
cc_ = cc_->add(crwDirs, crwTagId); cc_ = cc_->add(crwDirs, crwTagId);
} else { } else {
// Find the tag // Find the tag
for (auto&& component : components_) { auto it =
if (component->tagId() == crwTagId) { std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tagId() == crwTagId; });
cc_ = component; if (it != components_.end())
break; cc_ = *it;
}
}
if (!cc_) { if (!cc_) {
// Tag doesn't exist yet, add it // Tag doesn't exist yet, add it
m_ = std::make_unique<CiffEntry>(crwTagId, tag()); m_ = std::make_unique<CiffEntry>(crwTagId, tag());
@ -604,27 +600,23 @@ void CiffComponent::doRemove(CrwDirs& /*crwDirs*/, uint16_t /*crwTagId*/) {
void CiffDirectory::doRemove(CrwDirs& crwDirs, uint16_t crwTagId) { void CiffDirectory::doRemove(CrwDirs& crwDirs, uint16_t crwTagId) {
if (!crwDirs.empty()) { if (!crwDirs.empty()) {
auto [dir, _] = crwDirs.top(); auto dir = crwDirs.top();
crwDirs.pop(); crwDirs.pop();
// Find the directory // Find the directory
for (auto i = components_.begin(); i != components_.end(); ++i) { auto it =
if ((*i)->tag() == dir) { std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == dir.first; });
if (it != components_.end()) {
// Recursive call to next lower level directory // Recursive call to next lower level directory
(*i)->remove(crwDirs, crwTagId); (*it)->remove(crwDirs, crwTagId);
if ((*i)->empty()) if ((*it)->empty())
components_.erase(i); components_.erase(it);
break;
}
} }
} else { } else {
// Find the tag // Find the tag
for (auto i = components_.begin(); i != components_.end(); ++i) { auto it = std::find_if(components_.begin(), components_.end(), [=](const auto& c) { return c->tag() == crwTagId; });
if ((*i)->tagId() == crwTagId) { if (it != components_.end()) {
// Remove the entry and abort the loop delete *it;
delete *i; components_.erase(it);
components_.erase(i);
break;
}
} }
} }
} // CiffDirectory::doRemove } // CiffDirectory::doRemove

@ -889,7 +889,7 @@ 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 = std::find_if(nikonArrayIdx.begin(), nikonArrayIdx.end(), [ix](auto&& aix) { return aix == ix; }); auto it = std::find(nikonArrayIdx.begin(), nikonArrayIdx.end(), ix);
if (it == nikonArrayIdx.end()) if (it == nikonArrayIdx.end())
return -1; return -1;

@ -871,7 +871,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream&
"DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500", "DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500",
}; };
bool f = std::any_of(models.begin(), models.end(), [model = pos->toString()](auto&& m) { return m == model; }); bool f = std::find(models.begin(), models.end(), pos->toString()) != models.end();
if (f) if (f)
return os << value.toInt64(); return os << value.toInt64();
return os << N_("n/a"); return os << N_("n/a");
@ -938,7 +938,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, co
// Models that do not support this tag // Models that do not support this tag
const auto models = std::array{"ILCE-1", "ILCE-7SM3", "ILME-FX3"}; const auto models = std::array{"ILCE-1", "ILCE-7SM3", "ILME-FX3"};
bool f = std::any_of(models.begin(), models.end(), [model = pos->toString()](auto&& m) { return m == model; }); bool f = std::find(models.begin(), models.end(), pos->toString()) != models.end();
if (f) if (f)
return os << N_("n/a"); return os << N_("n/a");
@ -957,7 +957,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cModelReleaseYear(std::ostream& os, c
// Models that do not support this tag // Models that do not support this tag
const auto models = std::array{"ILCE-1", "ILCE-7SM3", "ILME-FX3"}; const auto models = std::array{"ILCE-1", "ILCE-7SM3", "ILME-FX3"};
bool f = std::any_of(models.begin(), models.end(), [model = pos->toString()](auto&& m) { return m == model; }); bool f = std::find(models.begin(), models.end(), pos->toString()) != models.end();
if (f) if (f)
return os << N_("n/a"); return os << N_("n/a");

Loading…
Cancel
Save