diff options
Diffstat (limited to 'Source/cmXCodeObject.cxx')
-rw-r--r-- | Source/cmXCodeObject.cxx | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 0def8c3..1747c9c 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -42,8 +42,8 @@ cmXCodeObject::~cmXCodeObject() cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) { this->Version = 15; - this->Target = 0; - this->Object = 0; + this->Target = nullptr; + this->Object = nullptr; this->IsA = ptype; @@ -71,7 +71,7 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) this->TypeValue = type; if (this->TypeValue == OBJECT) { - this->AddAttribute("isa", 0); + this->AddAttribute("isa", nullptr); } } @@ -86,7 +86,7 @@ bool cmXCodeObject::IsEmpty() const return this->ObjectAttributes.empty(); case OBJECT_REF: case OBJECT: - return this->Object == 0; + return this->Object == nullptr; } return true; // unreachable, but quiets warnings } @@ -115,23 +115,23 @@ 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"; } -void cmXCodeObject::PrintAttribute(std::ostream& out, const int level, - const std::string separator, - const int factor, const std::string& name, +void cmXCodeObject::PrintAttribute(std::ostream& out, int level, + const std::string& separator, int factor, + const std::string& name, const cmXCodeObject* object, const cmXCodeObject* parent) { @@ -166,11 +166,9 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, const 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; @@ -203,9 +201,9 @@ void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs, { cmXCodeObject::Indent(1, out); out << "objects = {\n"; - for (unsigned int i = 0; i < objs.size(); ++i) { - if (objs[i]->TypeValue == OBJECT) { - objs[i]->Print(out); + for (auto obj : objs) { + if (obj->TypeValue == OBJECT) { + obj->Print(out); } } cmXCodeObject::Indent(1, out); @@ -220,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. @@ -233,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; } |