clang-tidy: for loop conversion

Found with modernize-loop-convert

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 10 months ago
parent 169b6364a8
commit 5605379b3d

@ -98,13 +98,11 @@ void print(const std::string& file) {
auto image = Exiv2::ImageFactory::open(file); auto image = Exiv2::ImageFactory::open(file);
image->readMetadata(); image->readMetadata();
Exiv2::ExifData& ed = image->exifData(); for (const auto& i : image->exifData()) {
auto end = ed.end(); std::cout << std::setw(45) << std::setfill(' ') << std::left << i.key() << " "
for (auto i = ed.begin(); i != end; ++i) { << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i.tag() << " " << std::setw(12)
std::cout << std::setw(45) << std::setfill(' ') << std::left << i->key() << " " << std::setfill(' ') << std::left << i.ifdName() << " " << std::setw(9) << std::setfill(' ') << std::left
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setw(12) << i.typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i.count() << " "
<< std::setfill(' ') << std::left << i->ifdName() << " " << std::setw(9) << std::setfill(' ') << std::left << std::dec << i.toString() << "\n";
<< i->typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i->count()
<< " " << std::dec << i->toString() << "\n";
} }
} }

@ -7,7 +7,6 @@
#include <string> #include <string>
using format_t = std::map<std::string, int>; using format_t = std::map<std::string, int>;
using format_i = format_t::const_iterator;
enum format_e { wolf, csv, json, xml }; enum format_e { wolf, csv, json, xml };
void syntax(const char* argv[], format_t& formats) { void syntax(const char* argv[], format_t& formats) {

@ -77,25 +77,24 @@ int main(int argc, char* const argv[]) {
shortLong.insert("Exif.Photo.StripOffsets"); shortLong.insert("Exif.Photo.StripOffsets");
shortLong.insert("Exif.Photo.StripByteCounts"); shortLong.insert("Exif.Photo.StripByteCounts");
auto end = exifData.end(); for (const auto& i : exifData) {
for (auto i = exifData.begin(); i != end; ++i) {
if (!bLint) { if (!bLint) {
const char* tn = i->typeName(); const char* tn = i.typeName();
std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " " std::cout << std::setw(44) << std::setfill(' ') << std::left << i.key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i.tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec << std::setw(9) << std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec
<< std::setw(3) << std::setfill(' ') << std::right << i->count() << " " << std::dec << i->toString() << std::setw(3) << std::setfill(' ') << std::right << i.count() << " " << std::dec << i.toString()
<< "\n"; << "\n";
} else { } else {
const Exiv2::TagInfo* tagInfo = findTag(Exiv2::ExifTags::tagList(i->groupName()), i->tag()); const Exiv2::TagInfo* tagInfo = findTag(Exiv2::ExifTags::tagList(i.groupName()), i.tag());
if (tagInfo) { if (tagInfo) {
Exiv2::TypeId type = i->typeId(); Exiv2::TypeId type = i.typeId();
if (type != tagInfo->typeId_ && if (type != tagInfo->typeId_ &&
(tagInfo->typeId_ != Exiv2::comment || type != Exiv2::undefined) // comment is stored as undefined (tagInfo->typeId_ != Exiv2::comment || type != Exiv2::undefined) // comment is stored as undefined
&& (shortLong.find(i->key()) == shortLong.end() || && (shortLong.find(i.key()) == shortLong.end() ||
(type != Exiv2::unsignedShort && type != Exiv2::unsignedLong)) // can be short or long! (type != Exiv2::unsignedShort && type != Exiv2::unsignedLong)) // can be short or long!
) { ) {
std::cerr << i->key() << " type " << i->typeName() << " (" << type << ")" std::cerr << i.key() << " type " << i.typeName() << " (" << type << ")"
<< " expected " << Exiv2::TypeInfo::typeName(tagInfo->typeId_) << " (" << tagInfo->typeId_ << ")" << " expected " << Exiv2::TypeInfo::typeName(tagInfo->typeId_) << " (" << tagInfo->typeId_ << ")"
<< '\n'; << '\n';
rc = 2; rc = 2;

@ -24,12 +24,11 @@ int main(int argc, char* const argv[]) try {
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error); throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
} }
auto end = iptcData.end(); for (const auto& md : iptcData) {
for (auto md = iptcData.begin(); md != end; ++md) { std::cout << std::setw(44) << std::setfill(' ') << std::left << md.key() << " "
std::cout << std::setw(44) << std::setfill(' ') << std::left << md->key() << " " << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << md.tag() << " " << std::setw(9)
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << md->tag() << " " << std::setw(9) << std::setfill(' ') << std::left << md.typeName() << " " << std::dec << std::setw(3) << std::setfill(' ')
<< std::setfill(' ') << std::left << md->typeName() << " " << std::dec << std::setw(3) << std::right << md.count() << " " << std::dec << md.value() << '\n';
<< std::setfill(' ') << std::right << md->count() << " " << std::dec << md->value() << '\n';
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;

@ -19,8 +19,7 @@ int main(int argc, char* const argv[]) try {
image->readMetadata(); image->readMetadata();
Exiv2::PreviewManager loader(*image); Exiv2::PreviewManager loader(*image);
Exiv2::PreviewPropertiesList list = loader.getPreviewProperties(); for (const auto& pos : loader.getPreviewProperties()) {
for (auto&& pos : list) {
std::cout << pos.mimeType_ << " preview, type " << pos.id_ << ", " << pos.size_ << " bytes, " << pos.width_ << 'x' std::cout << pos.mimeType_ << " preview, type " << pos.id_ << ", " << pos.size_ << " bytes, " << pos.width_ << 'x'
<< pos.height_ << " pixels" << pos.height_ << " pixels"
<< "\n"; << "\n";

@ -56,14 +56,12 @@ int main(int argc, char* const argv[]) {
error += ": No Exif data found in the file"; error += ": No Exif data found in the file";
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error); throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, error);
} }
auto end = exifReadData.end(); for (const auto& i : exifReadData) {
for (auto i = exifReadData.begin(); i != end; ++i) { const char* tn = i.typeName();
const char* tn = i->typeName(); std::cout << std::setw(44) << std::setfill(' ') << std::left << i.key() << " "
std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " " << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i.tag() << " " << std::setw(9)
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec << std::setw(3)
<< std::setw(9) << std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec << std::setfill(' ') << std::right << i.count() << " " << std::dec << i.value() << "\n";
<< std::setw(3) << std::setfill(' ') << std::right << i->count() << " " << std::dec << i->value()
<< "\n";
} }
// del, reset the metadata // del, reset the metadata

@ -87,11 +87,10 @@ void print(const ExifData& exifData) {
std::string error("No Exif data found in the file"); std::string error("No Exif data found in the file");
throw Exiv2::Error(ErrorCode::kerErrorMessage, error); throw Exiv2::Error(ErrorCode::kerErrorMessage, error);
} }
auto end = exifData.end(); for (const auto& i : exifData) {
for (auto i = exifData.begin(); i != end; ++i) { std::cout << std::setw(44) << std::setfill(' ') << std::left << i.key() << " "
std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " " << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i.tag() << " " << std::setw(9)
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setw(9) << std::setfill(' ') << std::left << i.typeName() << " " << std::dec << std::setw(3) << std::setfill(' ')
<< std::setfill(' ') << std::left << i->typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i.count() << " " << std::dec << i.value() << "\n";
<< std::right << i->count() << " " << std::dec << i->value() << "\n";
} }
} }

@ -153,11 +153,10 @@ void testCase(const std::string& file1, const std::string& file2, const std::str
// ***************************************************************************** // *****************************************************************************
void exifPrint(const ExifData& exifData) { void exifPrint(const ExifData& exifData) {
auto i = exifData.begin(); for (const auto& i : exifData) {
for (; i != exifData.end(); ++i) { std::cout << std::setw(44) << std::setfill(' ') << std::left << i.key() << " "
std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " " << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i.tag() << " " << std::setw(9)
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setw(9) << std::setfill(' ') << std::left << i.typeName() << " " << std::dec << std::setw(3) << std::setfill(' ')
<< std::setfill(' ') << std::left << i->typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i.count() << " " << std::dec << i.value() << "\n";
<< std::right << i->count() << " " << std::dec << i->value() << "\n";
} }
} }

@ -201,13 +201,11 @@ void print(const std::string& file) {
auto image = Exiv2::ImageFactory::open(file); auto image = Exiv2::ImageFactory::open(file);
image->readMetadata(); image->readMetadata();
Exiv2::ExifData& ed = image->exifData(); for (const auto& i : image->exifData()) {
auto end = ed.end(); std::cout << std::setw(45) << std::setfill(' ') << std::left << i.key() << " "
for (auto i = ed.begin(); i != end; ++i) { << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i.tag() << " " << std::setw(12)
std::cout << std::setw(45) << std::setfill(' ') << std::left << i->key() << " " << std::setfill(' ') << std::left << i.ifdName() << " " << std::setw(9) << std::setfill(' ') << std::left
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setw(12) << i.typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i.count() << " "
<< std::setfill(' ') << std::left << i->ifdName() << " " << std::setw(9) << std::setfill(' ') << std::left << std::dec << i.value() << "\n";
<< i->typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i->count()
<< " " << std::dec << i->value() << "\n";
} }
} }

Loading…
Cancel
Save