4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtScript module of the Qt Toolkit. |
7 ** This file is part of the QtScript module of the Qt Toolkit. |
8 ** |
8 ** |
9 ** $QT_BEGIN_LICENSE:LGPL$ |
9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$ |
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
10 ** GNU Lesser General Public License Usage |
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
11 ** This file may be used under the terms of the GNU Lesser |
18 ** General Public License version 2.1 as published by the Free Software |
12 ** General Public License version 2.1 as published by the Free Software |
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
13 ** Foundation and appearing in the file LICENSE.LGPL included in the |
20 ** packaging of this file. Please review the following information to |
14 ** packaging of this file. Please review the following information to |
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
15 ** ensure the GNU Lesser General Public License version 2.1 requirements |
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
16 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
23 ** |
17 ** |
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
18 ** If you have questions regarding the use of this file, please contact |
29 ** Nokia at qt-info@nokia.com. |
19 ** Nokia at qt-info@nokia.com. |
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
20 ** $QT_END_LICENSE$ |
39 ** |
21 ** |
40 ****************************************************************************/ |
22 ****************************************************************************/ |
41 |
23 |
42 #include "config.h" // compile on Windows |
24 #include "config.h" // compile on Windows |
66 environment, then subsequently use the relevant QScriptString as |
48 environment, then subsequently use the relevant QScriptString as |
67 argument to e.g. QScriptValue::property(). |
49 argument to e.g. QScriptValue::property(). |
68 |
50 |
69 Call the toString() function to obtain the string that a |
51 Call the toString() function to obtain the string that a |
70 QScriptString represents. |
52 QScriptString represents. |
|
53 |
|
54 Call the toArrayIndex() function to convert a QScriptString to an |
|
55 array index. This is useful when using QScriptClass to implement |
|
56 array-like objects. |
71 */ |
57 */ |
72 |
58 |
73 /*! |
59 /*! |
74 Constructs an invalid QScriptString. |
60 Constructs an invalid QScriptString. |
75 */ |
61 */ |
162 { |
148 { |
163 return !operator==(other); |
149 return !operator==(other); |
164 } |
150 } |
165 |
151 |
166 /*! |
152 /*! |
|
153 \since 4.6 |
|
154 |
|
155 Attempts to convert this QScriptString to a QtScript array index, |
|
156 and returns the result. |
|
157 |
|
158 If a conversion error occurs, *\a{ok} is set to false; otherwise |
|
159 *\a{ok} is set to true. |
|
160 */ |
|
161 quint32 QScriptString::toArrayIndex(bool *ok) const |
|
162 { |
|
163 Q_D(const QScriptString); |
|
164 if (!d) { |
|
165 if (ok) |
|
166 *ok = false; |
|
167 return -1; |
|
168 } |
|
169 bool tmp; |
|
170 bool *okok = ok ? ok : &tmp; |
|
171 quint32 result = d->identifier.toArrayIndex(okok); |
|
172 if (!*okok) |
|
173 result = -1; |
|
174 return result; |
|
175 } |
|
176 |
|
177 /*! |
167 Returns the string that this QScriptString represents, or a |
178 Returns the string that this QScriptString represents, or a |
168 null string if this QScriptString is not valid. |
179 null string if this QScriptString is not valid. |
169 |
180 |
170 \sa isValid() |
181 \sa isValid() |
171 */ |
182 */ |