Replace for-loop with while to improve readability.

Note that I also moved the std::string out of the loop so that we do not
need to allocate/deallocate the string several times.
v0.27.3
Luis Díaz Más 6 years ago committed by Dan Čermák
parent c44188db9a
commit 23eb91aa6e
No known key found for this signature in database
GPG Key ID: E632C3380610D1C5

@ -46,14 +46,14 @@ int main(int argc, char* argv[])
if (item == "all" || item == "ALL" ) { if (item == "all" || item == "ALL" ) {
const GroupInfo* groupList = ExifTags::groupList(); const GroupInfo* groupList = ExifTags::groupList();
if (groupList) { if (groupList) {
std::string line;
while (groupList->tagList_) { while (groupList->tagList_) {
std::ostringstream tags; std::ostringstream tags;
ExifTags::taglist(tags,groupList->groupName_); ExifTags::taglist(tags,groupList->groupName_);
// https://en.cppreference.com/w/cpp/string/basic_string/getline
std::istringstream input(tags.str()) ; std::istringstream input(tags.str()) ;
for (std::string line,comma(","); std::getline(input, line); ) { while (std::getline(input, line)) {
std::cout << groupList->groupName_ << "." std::cout << groupList->groupName_ << "."
<< (item == "all" ? line.substr(0,line.find(comma)) : line) << (item == "all" ? line.substr(0,line.find(",")) : line)
<< std::endl; << std::endl;
} }
groupList++; groupList++;

Loading…
Cancel
Save