summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptstring.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-11-05 04:17:49 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-11-05 04:17:49 (GMT)
commitc4bc9a635bf0fd42e80e570909e204ae24b303b2 (patch)
treef31b37dc4aec0de9aba28b7f0a734336fd0812dc /src/script/api/qscriptstring.cpp
parent3babe49011d363aaaabafb70bfb0626217ec8959 (diff)
parentd39ec85b7e5d8702c2888cdad4ccdae72531c199 (diff)
downloadQt-c4bc9a635bf0fd42e80e570909e204ae24b303b2.zip
Qt-c4bc9a635bf0fd42e80e570909e204ae24b303b2.tar.gz
Qt-c4bc9a635bf0fd42e80e570909e204ae24b303b2.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/script/api/qscriptstring.cpp')
-rw-r--r--src/script/api/qscriptstring.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp
index 1ede51c..10fccd0 100644
--- a/src/script/api/qscriptstring.cpp
+++ b/src/script/api/qscriptstring.cpp
@@ -68,6 +68,10 @@ QT_BEGIN_NAMESPACE
Call the toString() function to obtain the string that a
QScriptString represents.
+
+ Call the toArrayIndex() function to convert a QScriptString to an
+ array index. This is useful when using QScriptClass to implement
+ array-like objects.
*/
/*!
@@ -164,6 +168,31 @@ bool QScriptString::operator!=(const QScriptString &other) const
}
/*!
+ \since 4.6
+
+ Attempts to convert this QScriptString to a QtScript array index,
+ and returns the result.
+
+ If a conversion error occurs, *\a{ok} is set to false; otherwise
+ *\a{ok} is set to true.
+*/
+quint32 QScriptString::toArrayIndex(bool *ok) const
+{
+ Q_D(const QScriptString);
+ if (!d) {
+ if (ok)
+ *ok = false;
+ return -1;
+ }
+ bool tmp;
+ bool *okok = ok ? ok : &tmp;
+ quint32 result = d->identifier.toArrayIndex(okok);
+ if (!*okok)
+ result = -1;
+ return result;
+}
+
+/*!
Returns the string that this QScriptString represents, or a
null string if this QScriptString is not valid.