diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2018-11-13 10:47:15 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2018-11-14 18:21:03 (GMT) |
commit | 01d5e5c460a2a9cb3962990f8ef278389254f30a (patch) | |
tree | a130a1403ad86bdc0525984d055a65495826a481 /Source/cmQtAutoGenInitializer.h | |
parent | 117272412e9dee1a1595718590a48e4c6750df59 (diff) | |
download | CMake-01d5e5c460a2a9cb3962990f8ef278389254f30a.zip CMake-01d5e5c460a2a9cb3962990f8ef278389254f30a.tar.gz CMake-01d5e5c460a2a9cb3962990f8ef278389254f30a.tar.bz2 |
Autogen: Add and use cmQtAutoGenInitializer::InfoWriter class
The new ``cmQtAutoGenInitializer::InfoWriter`` class provides an
interface to write strings/vectors/sets/maps in CMake format
into a file. Its use replaces various `cmJoin` calls that
failed to address escaping of semicolons in list elements.
Closes #18554
Diffstat (limited to 'Source/cmQtAutoGenInitializer.h')
-rw-r--r-- | Source/cmQtAutoGenInitializer.h | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 53ad571..903ec85 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -4,9 +4,11 @@ #define cmQtAutoGenInitializer_h #include "cmConfigure.h" // IWYU pragma: keep +#include "cmGeneratedFileStream.h" #include "cmQtAutoGen.h" #include <map> +#include <ostream> #include <set> #include <string> #include <vector> @@ -44,6 +46,39 @@ public: std::vector<std::string> Resources; }; + /// @brief Writes a CMake info file + class InfoWriter + { + public: + /// @brief Open the given file + InfoWriter(std::string const& filename); + + /// @return True if the file is open + operator bool() const { return static_cast<bool>(Ofs_); } + + void Write(const char* text) { Ofs_ << text; } + void Write(const char* key, std::string const& value); + void WriteUInt(const char* key, unsigned int value); + + template <class C> + void WriteStrings(const char* key, C const& container); + void WriteConfig(const char* key, + std::map<std::string, std::string> const& map); + template <class C> + void WriteConfigStrings(const char* key, + std::map<std::string, C> const& map); + void WriteNestedLists(const char* key, + std::vector<std::vector<std::string>> const& lists); + + private: + template <class IT> + static std::string ListJoin(IT it_begin, IT it_end); + static std::string ConfigKey(const char* key, std::string const& config); + + private: + cmGeneratedFileStream Ofs_; + }; + public: static IntegerVersion GetQtVersion(cmGeneratorTarget const* target); @@ -129,10 +164,10 @@ private: std::string Executable; std::string PredefsCmd; std::set<std::string> Skip; - std::string Includes; - std::map<std::string, std::string> ConfigIncludes; - std::string Defines; - std::map<std::string, std::string> ConfigDefines; + std::vector<std::string> Includes; + std::map<std::string, std::vector<std::string>> ConfigIncludes; + std::set<std::string> Defines; + std::map<std::string, std::set<std::string>> ConfigDefines; std::string MocsCompilation; } Moc; @@ -143,8 +178,8 @@ private: std::string Executable; std::set<std::string> Skip; std::vector<std::string> SearchPaths; - std::string Options; - std::map<std::string, std::string> ConfigOptions; + std::vector<std::string> Options; + std::map<std::string, std::vector<std::string>> ConfigOptions; std::vector<std::string> FileFiles; std::vector<std::vector<std::string>> FileOptions; } Uic; |