summaryrefslogtreecommitdiffstats
path: root/qmake/project.h
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@nokia.com>2012-04-16 11:07:02 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-17 03:26:32 +0200
commitee4d723ecc24e6be33b4c30f9693b7fdce79c767 (patch)
treeefcfe4c8a97b818200eb5cb59053c38deedb8c0b /qmake/project.h
parent65425be8fef69733fb1613e1487f3f6b4fb2d472 (diff)
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>
Diffstat (limited to 'qmake/project.h')
-rw-r--r--qmake/project.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/qmake/project.h b/qmake/project.h
index 979f1480bd..ccdc1b63f1 100644
--- a/qmake/project.h
+++ b/qmake/project.h
@@ -156,6 +156,7 @@ public:
bool isEmpty(const QString &v); // With compat mapping, but no magic variables
QStringList &values(const QString &v); // With compat mapping and magic variables
QString first(const QString &v); // ditto
+ int intValue(const QString &v, int defaultValue = 0); // ditto
QHash<QString, QStringList> &variables(); // No compat mapping and magic, obviously
bool isRecursive() const { return recursive; }
@@ -189,6 +190,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 QHash<QString, QStringList> &QMakeProject::variables()
{ return vars; }