summaryrefslogtreecommitdiffstats
path: root/Source/cmXCodeObject.cxx
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2017-11-07 07:41:47 (GMT)
committerCraig Scott <craig.scott@crascit.com>2017-11-10 05:12:57 (GMT)
commit98cbcedd7414f9e33e166b09ef082c6ecabcb7cf (patch)
treee2dab415e4b43795a86e58c80703717a90d6d012 /Source/cmXCodeObject.cxx
parentc37c4771cb876146ae0d23a2008482d6fcd53e35 (diff)
downloadCMake-98cbcedd7414f9e33e166b09ef082c6ecabcb7cf.zip
CMake-98cbcedd7414f9e33e166b09ef082c6ecabcb7cf.tar.gz
CMake-98cbcedd7414f9e33e166b09ef082c6ecabcb7cf.tar.bz2
Xcode: use ranged for loops, cleanup existing for loops
The changes are mostly converting old-style explicit iterator for loops into ranged for statements. A number of for loops had already been changed over, but local variables had been left behind instead of being absorbed into the ranged for statement, so these have been cleaned up too. A couple of minor improvements were made in areas already being updated by the for loop changes to slightly simplify the code or to avoid unnecessary conversions between `const char*` and `std::string`.
Diffstat (limited to 'Source/cmXCodeObject.cxx')
-rw-r--r--Source/cmXCodeObject.cxx26
1 files changed, 11 insertions, 15 deletions
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index e54f1f3..1747c9c 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -115,16 +115,15 @@ void cmXCodeObject::Print(std::ostream& out)
if (separator == "\n") {
out << separator;
}
- std::map<std::string, cmXCodeObject*>::iterator i;
cmXCodeObject::Indent(3 * indentFactor, out);
out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator;
- for (i = this->ObjectAttributes.begin(); i != this->ObjectAttributes.end();
- ++i) {
- if (i->first == "isa") {
+ for (const auto& keyVal : this->ObjectAttributes) {
+ if (keyVal.first == "isa") {
continue;
}
- PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this);
+ PrintAttribute(out, 3, separator, indentFactor, keyVal.first,
+ keyVal.second, this);
}
cmXCodeObject::Indent(2 * indentFactor, out);
out << "};\n";
@@ -167,11 +166,9 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, int level,
if (separator == "\n") {
out << separator;
}
- std::map<std::string, cmXCodeObject*>::const_iterator i;
- for (i = object->ObjectAttributes.begin();
- i != object->ObjectAttributes.end(); ++i) {
- PrintAttribute(out, (level + 1) * factor, separator, factor, i->first,
- i->second, object);
+ for (const auto& keyVal : object->ObjectAttributes) {
+ PrintAttribute(out, (level + 1) * factor, separator, factor,
+ keyVal.first, keyVal.second, object);
}
cmXCodeObject::Indent(level * factor, out);
out << "};" << separator;
@@ -221,7 +218,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
this->Object = copy->Object;
}
-void cmXCodeObject::PrintString(std::ostream& os, std::string String)
+void cmXCodeObject::PrintString(std::ostream& os, const std::string& String)
{
// The string needs to be quoted if it contains any characters
// considered special by the Xcode project file parser.
@@ -234,13 +231,12 @@ void cmXCodeObject::PrintString(std::ostream& os, std::string String)
// Print the string, quoted and escaped as necessary.
os << quote;
- for (std::string::const_iterator i = String.begin(); i != String.end();
- ++i) {
- if (*i == '"' || *i == '\\') {
+ for (auto c : String) {
+ if (c == '"' || c == '\\') {
// Escape double-quotes and backslashes.
os << '\\';
}
- os << *i;
+ os << c;
}
os << quote;
}