summaryrefslogtreecommitdiff
path: root/Source/cmQtAutoGen.cxx
diff options
context:
space:
mode:
authorArtur Ryt <artur.ryt@gmail.com>2019-02-14 20:39:24 +0100
committerArtur Ryt <artur.ryt@gmail.com>2019-02-15 23:40:30 +0100
commit706b93fa558c5a2e0e45a7068b5039d1f40fbc90 (patch)
tree6f0e1695ac30f5e4d18eb12ac45094456ca401a4 /Source/cmQtAutoGen.cxx
parent8c4de819449bbb1710b1cc2440357757e5cb757c (diff)
downloadcmake-706b93fa558c5a2e0e45a7068b5039d1f40fbc90.tar.gz
Modernize: C-arrays and loops over them
It replaces C arrays with deduced std::initializer_lists or std::array what makes enables for-loop over them.
Diffstat (limited to 'Source/cmQtAutoGen.cxx')
-rw-r--r--Source/cmQtAutoGen.cxx20
1 files changed, 14 insertions, 6 deletions
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index 653caf75bc..f4371382da 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -7,7 +7,7 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <iterator>
+#include <array>
#include <sstream>
#include <utility>
@@ -137,13 +137,21 @@ std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
std::string cmQtAutoGen::Quoted(std::string const& text)
{
- static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
- "\b", "\\b", "\f", "\\f", "\n", "\\n",
- "\r", "\\r", "\t", "\\t", "\v", "\\v" };
+ const std::array<std::pair<const char*, const char*>, 9> replaces = {
+ { { "\\", "\\\\" },
+ { "\"", "\\\"" },
+ { "\a", "\\a" },
+ { "\b", "\\b" },
+ { "\f", "\\f" },
+ { "\n", "\\n" },
+ { "\r", "\\r" },
+ { "\t", "\\t" },
+ { "\v", "\\v" } }
+ };
std::string res = text;
- for (const char* const* it = cm::cbegin(rep); it != cm::cend(rep); it += 2) {
- cmSystemTools::ReplaceString(res, *it, *(it + 1));
+ for (auto const& pair : replaces) {
+ cmSystemTools::ReplaceString(res, pair.first, pair.second);
}
res = '"' + res;
res += '"';