Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QScriptValueIterator class provides a Java-style iterator for QScriptValue. More...
Public Member Functions | |
QScriptValueIterator (QScriptValue value) | |
| |
virtual void | CreateProxy () |
new QScriptValue.PropertyFlag | Flags () |
| |
new bool | HasNext () |
| |
new bool | HasPrevious () |
| |
new string | Name () |
| |
new void | Next () |
| |
new void | Previous () |
| |
new void | Remove () |
| |
new QScriptString | ScriptName () |
| |
new void | ToBack () |
| |
new void | ToFront () |
| |
new void | Dispose () |
Protected Member Functions | |
QScriptValueIterator (System.Type dummy) | |
Protected Attributes | |
SmokeInvocation | interceptor |
Properties | |
new QScriptValue | Value [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
The QScriptValueIterator class provides a Java-style iterator for QScriptValue.
The QScriptValueIterator constructor takes a QScriptValue as argument. After construction, the iterator is located at the very beginning of the sequence of properties. Here's how to iterate over all the properties of a QScriptValue:
QScriptValue object;
...
QScriptValueIterator it(object);
while (it.hasNext()) {
it.next();
qDebug() << it.name() << ": " << it.value().toString();
}
The next() advances the iterator. The name(), value() and flags() functions return the name, value and flags of the last item that was jumped over.
If you want to remove properties as you iterate over the QScriptValue, use remove(). If you want to modify the value of a property, use setValue().
Note that QScriptValueIterator only iterates over the QScriptValue's own properties; i.e. it does not follow the prototype chain. You can use a loop like this to follow the prototype chain:
QScriptValue obj = ...; // the object to iterate over
while (obj.isObject()) {
QScriptValueIterator it(obj);
while (it.hasNext()) {
it.next();
qDebug() << it.name();
}
obj = obj.prototype();
}
Note that QScriptValueIterator will not automatically skip over properties that have the QScriptValue::SkipInEnumeration flag set; that flag only affects iteration in script code. If you want, you can skip over such properties with code like the following:
while (it.hasNext()) {
it.next();
if (it.flags() & QScriptValue::SkipInEnumeration)
continue;
qDebug() << "found enumerated property:" << it.name();
}
See also QScriptValue::property().
|
protected |
QtScript.QScriptValueIterator.QScriptValueIterator | ( | QScriptValue | value | ) |
Constructs an iterator for traversing object. The iterator is set to be at the front of the sequence of properties (before the first property).
|
virtual |
new void QtScript.QScriptValueIterator.Dispose | ( | ) |
new QScriptValue.PropertyFlag QtScript.QScriptValueIterator.Flags | ( | ) |
Returns the flags of the last property that was jumped over using next() or previous().
See also value().
new bool QtScript.QScriptValueIterator.HasNext | ( | ) |
Returns true if there is at least one item ahead of the iterator (i.e. the iterator is not at the back of the property sequence); otherwise returns false.
See also next() and hasPrevious().
new bool QtScript.QScriptValueIterator.HasPrevious | ( | ) |
Returns true if there is at least one item behind the iterator (i.e. the iterator is not at the front of the property sequence); otherwise returns false.
See also previous() and hasNext().
new string QtScript.QScriptValueIterator.Name | ( | ) |
Returns the name of the last property that was jumped over using next() or previous().
See also value() and flags().
new void QtScript.QScriptValueIterator.Next | ( | ) |
Advances the iterator by one position.
Calling this function on an iterator located at the back of the container leads to undefined results.
See also hasNext(), previous(), and name().
new void QtScript.QScriptValueIterator.Previous | ( | ) |
Moves the iterator back by one position.
Calling this function on an iterator located at the front of the container leads to undefined results.
See also hasPrevious(), next(), and name().
new void QtScript.QScriptValueIterator.Remove | ( | ) |
Removes the last property that was jumped over using next() or previous().
See also setValue().
new QScriptString QtScript.QScriptValueIterator.ScriptName | ( | ) |
Returns the name of the last property that was jumped over using next() or previous().
This function was introduced in Qt 4.4.
new void QtScript.QScriptValueIterator.ToBack | ( | ) |
Moves the iterator to the back of the QScriptValue (after the last property).
See also toFront() and previous().
new void QtScript.QScriptValueIterator.ToFront | ( | ) |
Moves the iterator to the front of the QScriptValue (before the first property).
See also toBack() and next().
|
protected |
|
getset |
|
getset |
Returns the value of the last property that was jumped over using next() or previous().
Sets the value of the last property that was jumped over using next() or previous().