summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenInitializer.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-06 08:32:07 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-07 16:01:32 (GMT)
commitd02a99d9d3aa8d8f33efbd3255c78d6b87a99a22 (patch)
tree2c3bb9c58b6a83b36a1e529d2b3412d1681dd495 /Source/cmQtAutoGenInitializer.cxx
parentbbf4a5771f8113ce5b88968c4dd3def2fbcd9354 (diff)
downloadCMake-d02a99d9d3aa8d8f33efbd3255c78d6b87a99a22.zip
CMake-d02a99d9d3aa8d8f33efbd3255c78d6b87a99a22.tar.gz
CMake-d02a99d9d3aa8d8f33efbd3255c78d6b87a99a22.tar.bz2
Autogen: Modernize code to use cm::string_view for the info writer
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenInitializer.cxx33
1 files changed, 14 insertions, 19 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index da6094d..7e72fd6 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -156,30 +156,27 @@ std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin,
return res;
}
-std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey(
- const char* key, std::string const& config)
+inline std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey(
+ cm::string_view key, std::string const& config)
{
- std::string ckey = key;
- ckey += '_';
- ckey += config;
- return ckey;
+ return cmStrCat(key, "_", config);
}
-void cmQtAutoGenInitializer::InfoWriter::Write(const char* key,
+void cmQtAutoGenInitializer::InfoWriter::Write(cm::string_view key,
std::string const& value)
{
Ofs_ << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value)
<< ")\n";
};
-void cmQtAutoGenInitializer::InfoWriter::WriteUInt(const char* key,
+void cmQtAutoGenInitializer::InfoWriter::WriteUInt(cm::string_view key,
unsigned int value)
{
Ofs_ << "set(" << key << " " << value << ")\n";
};
template <class C>
-void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key,
+void cmQtAutoGenInitializer::InfoWriter::WriteStrings(cm::string_view key,
C const& container)
{
Ofs_ << "set(" << key << " \""
@@ -187,31 +184,29 @@ void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key,
}
void cmQtAutoGenInitializer::InfoWriter::WriteConfig(
- const char* key, std::map<std::string, std::string> const& map)
+ cm::string_view key, std::map<std::string, std::string> const& map)
{
for (auto const& item : map) {
- Write(ConfigKey(key, item.first).c_str(), item.second);
+ Write(ConfigKey(key, item.first), item.second);
}
};
template <class C>
void cmQtAutoGenInitializer::InfoWriter::WriteConfigStrings(
- const char* key, std::map<std::string, C> const& map)
+ cm::string_view key, std::map<std::string, C> const& map)
{
for (auto const& item : map) {
- WriteStrings(ConfigKey(key, item.first).c_str(), item.second);
+ WriteStrings(ConfigKey(key, item.first), item.second);
}
}
void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists(
- const char* key, std::vector<std::vector<std::string>> const& lists)
+ cm::string_view key, std::vector<std::vector<std::string>> const& lists)
{
std::vector<std::string> seplist;
- for (const std::vector<std::string>& list : lists) {
- std::string blist = "{";
- blist += ListJoin(list.begin(), list.end());
- blist += "}";
- seplist.push_back(std::move(blist));
+ seplist.reserve(lists.size());
+ for (std::vector<std::string> const& list : lists) {
+ seplist.push_back(cmStrCat("{", ListJoin(list.begin(), list.end()), "}"));
}
Write(key, cmJoin(seplist, cmQtAutoGen::ListSep));
};