Points: modernize C++: use range-based for loop

This commit is contained in:
wmayer
2023-08-15 15:28:17 +02:00
committed by wwmayer
parent 9b5314bd87
commit 3e8f4d941f
7 changed files with 122 additions and 117 deletions

View File

@@ -761,30 +761,30 @@ std::size_t PlyReader::readHeader(std::istream& in,
number.push_back(list[1]);
}
for (std::list<std::string>::iterator it = number.begin(); it != number.end(); ++it) {
for (const auto & it : number) {
int size = 0;
if (*it == "char" || *it == "int8") {
if (it == "char" || it == "int8") {
size = 1;
}
else if (*it == "uchar" || *it == "uint8") {
else if (it == "uchar" || it == "uint8") {
size = 1;
}
else if (*it == "short" || *it == "int16") {
else if (it == "short" || it == "int16") {
size = 2;
}
else if (*it == "ushort" || *it == "uint16") {
else if (it == "ushort" || it == "uint16") {
size = 2;
}
else if (*it == "int" || *it == "int32") {
else if (it == "int" || it == "int32") {
size = 4;
}
else if (*it == "uint" || *it == "uint32") {
else if (it == "uint" || it == "uint32") {
size = 4;
}
else if (*it == "float" || *it == "float32") {
else if (it == "float" || it == "float32") {
size = 4;
}
else if (*it == "double" || *it == "float64") {
else if (it == "double" || it == "float64") {
size = 8;
}
else {
@@ -795,7 +795,7 @@ std::size_t PlyReader::readHeader(std::istream& in,
if (element == "vertex") {
// store the property name and type
fields.push_back(name);
types.push_back(*it);
types.push_back(it);
sizes.push_back(size);
}
else if (!count_props.empty()) {
@@ -1980,8 +1980,8 @@ void PlyWriter::write(const std::string& filename)
out << "element vertex " << numValid << std::endl;
// the properties
for (std::list<std::string>::iterator it = properties.begin(); it != properties.end(); ++it)
out << "property " << *it << std::endl;
for (const auto & prop : properties)
out << "property " << prop << std::endl;
out << "end_header" << std::endl;
for (std::size_t r=0; r<numPoints; r++) {
@@ -2128,8 +2128,8 @@ void PcdWriter::write(const std::string& filename)
// the fields
out << "FIELDS";
for (std::list<std::string>::iterator it = fields.begin(); it != fields.end(); ++it)
out << " " << *it;
for (const auto & field : fields)
out << " " << field;
out << std::endl;
// the sizes
@@ -2140,8 +2140,8 @@ void PcdWriter::write(const std::string& filename)
// the types
out << "TYPE";
for (std::list<std::string>::iterator it = types.begin(); it != types.end(); ++it)
out << " " << *it;
for (const auto & type : types)
out << " " << type;
out << std::endl;
// the count