clang-tidy: range for loop conversions

Found with modernize-loop-convert

Ran through git clang-format.

Also removed several questionable loops and replaced with simpler
algorithms.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2021-04-26 17:01:09 -07:00
committed by Luis Díaz Más
parent 5a4c3cd057
commit 4ceb325c8f
35 changed files with 406 additions and 438 deletions
+27 -18
View File
@@ -72,28 +72,37 @@ int main()
std::cout << std::endl;
for (unsigned int i = 0; i < EXV_COUNTOF(testcases); ++i) try {
std::string s(testcases[i]);
std::cout << std::setw(12) << std::left << s;
bool ok;
for (auto&& testcase : testcases) {
try {
std::string s(testcase);
std::cout << std::setw(12) << std::left << s;
bool ok;
long l = Exiv2::parseLong(s, ok);
std::cout << std::setw(12) << std::left;
if (ok) std::cout << l; else std::cout << "nok";
long l = Exiv2::parseLong(s, ok);
std::cout << std::setw(12) << std::left;
if (ok)
std::cout << l;
else
std::cout << "nok";
float f = Exiv2::parseFloat(s, ok);
std::cout << std::setw(12) << std::left;
if (ok) std::cout << f; else std::cout << "nok";
float f = Exiv2::parseFloat(s, ok);
std::cout << std::setw(12) << std::left;
if (ok)
std::cout << f;
else
std::cout << "nok";
Exiv2::Rational r = Exiv2::parseRational(s, ok);
if (ok) std::cout << r.first << "/" << r.second;
else std::cout << "nok";
Exiv2::Rational r = Exiv2::parseRational(s, ok);
if (ok)
std::cout << r.first << "/" << r.second;
else
std::cout << "nok";
std::cout << std::endl;
}
catch (Exiv2::AnyError& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
std::cout << std::endl;
} catch (Exiv2::AnyError& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
}
return 0;