From 79f99d1f81eece5bea5aa7369b4331db5a6ef5b0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 16 Apr 2012 11:07:02 +0200 Subject: qmake: QMakeProject::intValue added For variables that are supposed to contain a single int, this method returns the numeric value. Only the first value of the variable is taken into account. Change-Id: Ifa11ba5ac044e0a4703a387a9bcf02043e4681d8 Reviewed-by: Oswald Buddenhagen (cherry picked from commit ee4d723ecc24e6be33b4c30f9693b7fdce79c767) --- qmake/project.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qmake/project.h b/qmake/project.h index d458dd9..4e18fd0 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -156,6 +156,7 @@ public: QStringList &values(const QString &v); // With compat mapping and magic variables QString first(const QString &v); // ditto QMap &variables(); // No compat mapping and magic, obviously + int intValue(const QString &v, int defaultValue = 0); // ditto bool isRecursive() const { return recursive; } @@ -188,6 +189,18 @@ inline QString QMakeProject::first(const QString &v) return vals.first(); } +inline int QMakeProject::intValue(const QString &v, int defaultValue) +{ + const QString str = first(v); + if (!str.isEmpty()) { + bool ok; + int i = str.toInt(&ok); + if (ok) + return i; + } + return defaultValue; +} + inline QMap &QMakeProject::variables() { return vars; } -- cgit v0.12