From 761b3d79746ab91219d6478a021ba3a1c56f05c8 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 31 Aug 2017 16:03:52 +0200 Subject: Autogen: Add functions to read/write a list of lists --- Source/cmQtAutoGeneratorInitializer.cxx | 16 ++++++++++++++ Source/cmQtAutoGenerators.cxx | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index d04e5b7..0333a55 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -207,6 +207,22 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key, key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str()); } +static void AddDefinitionEscaped( + cmMakefile* makefile, const char* key, + const std::vector>& lists) +{ + std::vector seplist; + for (const std::vector& list : lists) { + std::string blist = "{"; + blist += cmJoin(list, ";"); + blist += "}"; + seplist.push_back(std::move(blist)); + } + makefile->AddDefinition(key, cmOutputConverter::EscapeForCMake( + cmJoin(seplist, cmQtAutoGen::listSep)) + .c_str()); +} + static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName, cmQtAutoGen::GeneratorType genType) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 7774a00..3369f65 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -75,6 +75,43 @@ static void InfoGet(cmMakefile* makefile, const char* key, cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list); } +static std::vector InfoGetList(cmMakefile* makefile, + const char* key) +{ + std::vector list; + cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list); + return list; +} + +static std::vector> InfoGetLists(cmMakefile* makefile, + const char* key) +{ + std::vector> lists; + { + const std::string value = makefile->GetSafeDefinition(key); + std::string::size_type pos = 0; + while (pos < value.size()) { + std::string::size_type next = value.find(cmQtAutoGen::listSep, pos); + std::string::size_type length = + (next != std::string::npos) ? next - pos : value.size() - pos; + // Remove enclosing braces + if (length >= 2) { + std::string::const_iterator itBeg = value.begin() + (pos + 1); + std::string::const_iterator itEnd = itBeg + (length - 2); + { + std::string subValue(itBeg, itEnd); + std::vector list; + cmSystemTools::ExpandListArgument(subValue, list); + lists.push_back(std::move(list)); + } + } + pos += length; + pos += cmQtAutoGen::listSep.size(); + } + } + return lists; +} + static void InfoGetConfig(cmMakefile* makefile, const char* key, const std::string& config, std::string& value) { -- cgit v0.12