summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@nokia.com>2012-04-16 09:07:02 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-17 18:11:49 (GMT)
commit79f99d1f81eece5bea5aa7369b4331db5a6ef5b0 (patch)
tree6555f294b3dfa61f9940655551b2140b8ee07205
parentbc11f8a07ea2a82a773f04589956412043a2625f (diff)
downloadQt-79f99d1f81eece5bea5aa7369b4331db5a6ef5b0.zip
Qt-79f99d1f81eece5bea5aa7369b4331db5a6ef5b0.tar.gz
Qt-79f99d1f81eece5bea5aa7369b4331db5a6ef5b0.tar.bz2
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 <oswald.buddenhagen@nokia.com> (cherry picked from commit ee4d723ecc24e6be33b4c30f9693b7fdce79c767)
-rw-r--r--qmake/project.h13
1 files changed, 13 insertions, 0 deletions
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<QString, QStringList> &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<QString, QStringList> &QMakeProject::variables()
{ return vars; }