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:
committed by
Luis Díaz Más
parent
5a4c3cd057
commit
4ceb325c8f
+26
-26
@@ -35,19 +35,15 @@ void syntax(const char* argv[],format_t& formats)
|
||||
std::cout << "Usage: " << argv[0] << " file format" << std::endl;
|
||||
int count = 0;
|
||||
std::cout << "formats: ";
|
||||
for ( format_i i = formats.begin() ; i != formats.end() ; i++ ) {
|
||||
std::cout << ( count++ ? " | " : "") << i->first ;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
for (auto&& format : formats) {
|
||||
std::cout << (count++ ? " | " : "") << format.first;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
size_t formatInit(Exiv2::ExifData& exifData)
|
||||
{
|
||||
size_t result = 0;
|
||||
for (auto i = exifData.begin(); i != exifData.end() ; ++i) {
|
||||
result ++ ;
|
||||
}
|
||||
return result ;
|
||||
return std::distance(exifData.begin(), exifData.end());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@@ -59,12 +55,13 @@ std::string escapeCSV(Exiv2::ExifData::const_iterator it,bool bValue)
|
||||
if ( bValue ) os << it->value() ; else os << it->key() ;
|
||||
|
||||
std::string s = os.str();
|
||||
for ( size_t i = 0 ;i < s.length() ; i ++ ) {
|
||||
if ( s[i] == ',' ) result += '\\';
|
||||
result += s[i];
|
||||
}
|
||||
for (auto&& c : s) {
|
||||
if (c == ',')
|
||||
result += '\\';
|
||||
result += c;
|
||||
}
|
||||
|
||||
return result ;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string formatCSV(Exiv2::ExifData& exifData)
|
||||
@@ -109,13 +106,14 @@ std::string escapeJSON(Exiv2::ExifData::const_iterator it,bool bValue=true)
|
||||
if ( bValue ) os << it->value() ; else os << it->key() ;
|
||||
|
||||
std::string s = os.str();
|
||||
for ( size_t i = 0 ;i < s.length() ; i ++ ) {
|
||||
if ( s[i] == '"' ) result += "\\\"";
|
||||
result += s[i];
|
||||
}
|
||||
for (auto&& c : s) {
|
||||
if (c == '"')
|
||||
result += "\\\"";
|
||||
result += c;
|
||||
}
|
||||
|
||||
std::string q = "\"";
|
||||
return q + result + q ;
|
||||
std::string q = "\"";
|
||||
return q + result + q;
|
||||
}
|
||||
|
||||
std::string formatJSON(Exiv2::ExifData& exifData)
|
||||
@@ -141,13 +139,15 @@ std::string escapeXML(Exiv2::ExifData::const_iterator it,bool bValue=true)
|
||||
if ( bValue ) os << it->value() ; else os << it->key() ;
|
||||
|
||||
std::string s = os.str();
|
||||
for ( size_t i = 0 ;i < s.length() ; i ++ ) {
|
||||
if ( s[i] == '<' ) result += "≶";
|
||||
if ( s[i] == '>' ) result += ">";
|
||||
result += s[i];
|
||||
}
|
||||
for (auto&& c : s) {
|
||||
if (c == '<')
|
||||
result += "≶";
|
||||
if (c == '>')
|
||||
result += ">";
|
||||
result += c;
|
||||
}
|
||||
|
||||
return result ;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string formatXML(Exiv2::ExifData& exifData)
|
||||
|
||||
Reference in New Issue
Block a user