summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmQtAutoGenerators.cxx38
-rw-r--r--Source/cmQtAutoGenerators.h27
2 files changed, 39 insertions, 26 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 4e3ec96..7774a00 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -224,10 +224,10 @@ cmQtAutoGenerators::cmQtAutoGenerators()
}
// Moc macro filters
- this->MocMacroFilters.push_back(
- MocMacroFilter("Q_OBJECT", "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]"));
- this->MocMacroFilters.push_back(
- MocMacroFilter("Q_GADGET", "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]"));
+ this->MocMacroFilters.emplace_back(
+ "Q_OBJECT", "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]");
+ this->MocMacroFilters.emplace_back(
+ "Q_GADGET", "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]");
// Precompile regular expressions
this->MocRegExpInclude.compile(
@@ -275,15 +275,15 @@ bool cmQtAutoGenerators::MocDependFilterPush(const std::string& key,
bool success = false;
if (!key.empty()) {
if (!regExp.empty()) {
- MocDependFilter filter;
- filter.key = key;
- if (filter.regExp.compile(regExp)) {
- this->MocDependFilters.push_back(filter);
+ KeyRegExp filter;
+ filter.Key = key;
+ if (filter.RegExp.compile(regExp)) {
+ this->MocDependFilters.push_back(std::move(filter));
success = true;
} else {
this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Compiling "
- "regular expression failed.\nKey: " +
- Quoted(key) + "\nExp.: " + Quoted(regExp));
+ "regular expression failed.\n Key: " +
+ Quoted(key) + "\n RegExp.: " + Quoted(regExp));
}
} else {
this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Regular "
@@ -739,14 +739,14 @@ bool cmQtAutoGenerators::RunAutogen()
bool cmQtAutoGenerators::MocRequired(const std::string& contentText,
std::string* macroName)
{
- for (MocMacroFilter& filter : this->MocMacroFilters) {
+ for (KeyRegExp& filter : this->MocMacroFilters) {
// Run a simple find string operation before the expensive
// regular expression check
- if (contentText.find(filter.first) != std::string::npos) {
- if (filter.second.find(contentText)) {
+ if (contentText.find(filter.Key) != std::string::npos) {
+ if (filter.RegExp.find(contentText)) {
// Return macro name on demand
if (macroName != nullptr) {
- *macroName = filter.first;
+ *macroName = filter.Key;
}
return true;
}
@@ -759,16 +759,16 @@ void cmQtAutoGenerators::MocFindDepends(
const std::string& absFilename, const std::string& contentText,
std::map<std::string, std::set<std::string>>& mocDepends)
{
- for (MocDependFilter& filter : this->MocDependFilters) {
+ for (KeyRegExp& filter : this->MocDependFilters) {
// Run a simple find string operation before the expensive
// regular expression check
- if (contentText.find(filter.key) != std::string::npos) {
+ if (contentText.find(filter.Key) != std::string::npos) {
// Run regular expression check loop
const std::string sourcePath = SubDirPrefix(absFilename);
const char* contentChars = contentText.c_str();
- while (filter.regExp.find(contentChars)) {
+ while (filter.RegExp.find(contentChars)) {
// Evaluate match
- const std::string match = filter.regExp.match(1);
+ const std::string match = filter.RegExp.match(1);
if (!match.empty()) {
// Find the dependency file
std::string incFile;
@@ -784,7 +784,7 @@ void cmQtAutoGenerators::MocFindDepends(
Quoted(match));
}
}
- contentChars += filter.regExp.end();
+ contentChars += filter.RegExp.end();
}
}
}
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 2084a81..ff31884 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -25,13 +25,26 @@ public:
private:
// -- Types
- /// @brief Used to extract additional dependencies from content text
- struct MocDependFilter
+ /// @brief Search key plus regular expression pair
+ struct KeyRegExp
{
- std::string key;
- cmsys::RegularExpression regExp;
+ KeyRegExp() = default;
+
+ KeyRegExp(const char* key, const char* regExp)
+ : Key(key)
+ , RegExp(regExp)
+ {
+ }
+
+ KeyRegExp(const std::string& key, const std::string& regExp)
+ : Key(key)
+ , RegExp(regExp)
+ {
+ }
+
+ std::string Key;
+ cmsys::RegularExpression RegExp;
};
- typedef std::pair<std::string, cmsys::RegularExpression> MocMacroFilter;
// -- Configuration
bool MocDependFilterPush(const std::string& key, const std::string& regExp);
@@ -200,8 +213,8 @@ private:
std::vector<std::string> MocDefinitions;
std::vector<std::string> MocOptions;
std::vector<std::string> MocPredefsCmd;
- std::vector<MocDependFilter> MocDependFilters;
- std::vector<MocMacroFilter> MocMacroFilters;
+ std::vector<KeyRegExp> MocDependFilters;
+ std::vector<KeyRegExp> MocMacroFilters;
cmsys::RegularExpression MocRegExpInclude;
// -- Uic
bool UicSettingsChanged;