diff options
| author | Tillmann Karras <tilkax@gmail.com> | 2014-02-12 16:00:34 +0100 |
|---|---|---|
| committer | Tillmann Karras <tilkax@gmail.com> | 2014-02-13 09:05:50 +0100 |
| commit | 404624bf0b0125e5a408021c616ee9b9e2dde382 (patch) | |
| tree | d2c3cd6256b09ebdc04b8c913b21c2e56d30c2e1 /Source/Core/Common/IniFile.cpp | |
| parent | 2ff794d299b0426d1f2a523523260efad84a9837 (diff) | |
Turn loops into range-based form
and some things suggested by cppcheck and compiler warnings.
Diffstat (limited to 'Source/Core/Common/IniFile.cpp')
| -rw-r--r-- | Source/Core/Common/IniFile.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index b07fb09224..6999c58693 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -87,10 +87,9 @@ void IniFile::Section::Set(const std::string& key, const std::vector<std::string { std::string temp; // Join the strings with , - std::vector<std::string>::const_iterator it; - for (it = newValues.begin(); it != newValues.end(); ++it) + for (const std::string& value : newValues) { - temp = (*it) + ","; + temp = value + ","; } // remove last , temp.resize(temp.length() - 1); @@ -210,7 +209,7 @@ bool IniFile::Section::Delete(const std::string& key) const IniFile::Section* IniFile::GetSection(const std::string& sectionName) const { - for (const auto& sect : sections) + for (const Section& sect : sections) if (!strcasecmp(sect.name.c_str(), sectionName.c_str())) return (&(sect)); return 0; @@ -218,7 +217,7 @@ const IniFile::Section* IniFile::GetSection(const std::string& sectionName) cons IniFile::Section* IniFile::GetSection(const std::string& sectionName) { - for (auto& sect : sections) + for (Section& sect : sections) if (!strcasecmp(sect.name.c_str(), sectionName.c_str())) return (&(sect)); return 0; @@ -240,7 +239,7 @@ bool IniFile::DeleteSection(const std::string& sectionName) Section* s = GetSection(sectionName); if (!s) return false; - for (std::vector<Section>::iterator iter = sections.begin(); iter != sections.end(); ++iter) + for (auto iter = sections.begin(); iter != sections.end(); ++iter) { if (&(*iter) == s) { @@ -399,21 +398,21 @@ bool IniFile::Save(const std::string& filename) return false; } - for (auto& section : sections) + for (const Section& section : sections) { if (section.keys_order.size() != 0 || section.lines.size() != 0) out << "[" << section.name << "]" << std::endl; if (section.keys_order.size() == 0) { - for (auto s : section.lines) + for (const std::string& s : section.lines) out << s << std::endl; } else { - for (auto kvit = section.keys_order.begin(); kvit != section.keys_order.end(); ++kvit) + for (const std::string& kvit : section.keys_order) { - auto pair = section.values.find(*kvit); + auto pair = section.values.find(kvit); out << pair->first << " = " << pair->second << std::endl; } } |
