diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-03-23 16:38:39 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-03-24 14:30:16 +0000 |
commit | 9bd988eb1b4327225809d4e449af7f8b3105dd87 (patch) | |
tree | 4ce28e2882830176c8aef722548f213ce7beb72f /generator | |
parent | 8d99ee1f6af693ad45dcd03fcae6a86f8f86302a (diff) |
TypeDatabase: Refactor API version checking
The repeated construction of a QRegExp in the version checking
loop shows up in the profiler.
Change the API to accept a QString, reducing conversions and
remove obsolete API.
Port the version checking code to use QRegularExpression and
QVersionNumber and store the regexps in a vector.
Change-Id: Id3e509e065d73699f49109df1f184edbefb8a09a
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'generator')
-rw-r--r-- | generator/main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/generator/main.cpp b/generator/main.cpp index ac8f77f..874540e 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -341,6 +341,12 @@ static inline void errorPrint(const QString& s) << "\nCommand line: " << qPrintable(arguments.join(QLatin1Char(' '))) << '\n'; } +static QString msgInvalidVersion(const QString &package, const QString &version) +{ + return QLatin1String("Invalid version \"") + version + + QLatin1String("\" specified for package ") + package + QLatin1Char('.'); +} + int main(int argc, char *argv[]) { QElapsedTimer timer; @@ -439,7 +445,10 @@ int main(int argc, char *argv[]) // avoid constFirst to stay Qt 5.5 compatible package = parts.count() == 1 ? QLatin1String("*") : parts.first(); version = parts.last(); - extractor.setApiVersion(package, version.toUtf8()); + if (!extractor.setApiVersion(package, version)) { + errorPrint(msgInvalidVersion(package, version)); + return EXIT_FAILURE; + } } } |