Qt 4.8
|
The QScriptValueIterator class provides a Java-style iterator for QScriptValue. More...
#include <qscriptvalueiterator.h>
Public Functions | |
QScriptValue::PropertyFlags | flags () const |
Returns the flags of the last property that was jumped over using next() or previous(). More... | |
bool | hasNext () const |
Returns true if there is at least one item ahead of the iterator (i.e. More... | |
bool | hasPrevious () const |
Returns true if there is at least one item behind the iterator (i.e. More... | |
QString | name () const |
Returns the name of the last property that was jumped over using next() or previous(). More... | |
void | next () |
Advances the iterator by one position. More... | |
QScriptValueIterator & | operator= (QScriptValue &value) |
Makes the iterator operate on object. More... | |
void | previous () |
Moves the iterator back by one position. More... | |
QScriptValueIterator (const QScriptValue &value) | |
Constructs an iterator for traversing object. More... | |
void | remove () |
Removes the last property that was jumped over using next() or previous(). More... | |
QScriptString | scriptName () const |
Returns the name of the last property that was jumped over using next() or previous(). More... | |
void | setValue (const QScriptValue &value) |
Sets the value of the last property that was jumped over using next() or previous(). More... | |
void | toBack () |
Moves the iterator to the back of the QScriptValue (after the last property). More... | |
void | toFront () |
Moves the iterator to the front of the QScriptValue (before the first property). More... | |
QScriptValue | value () const |
Returns the value of the last property that was jumped over using next() or previous(). More... | |
~QScriptValueIterator () | |
Destroys the iterator. More... | |
Properties | |
QScopedPointer< QScriptValueIteratorPrivate > | d_ptr |
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:
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:
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:
Definition at line 41 of file qscriptvalueiterator.h.
QScriptValueIterator::QScriptValueIterator | ( | const QScriptValue & | object | ) |
Constructs an iterator for traversing object.
The iterator is set to be at the front of the sequence of properties (before the first property).
Definition at line 142 of file qscriptvalueiterator.cpp.
QScriptValueIterator::~QScriptValueIterator | ( | ) |
QScriptValue::PropertyFlags QScriptValueIterator::flags | ( | ) | const |
Returns the flags of the last property that was jumped over using next() or previous().
Definition at line 328 of file qscriptvalueiterator.cpp.
Referenced by QScriptObjectSnapshot::capture(), QScriptDebuggerCommandExecutor::execute(), expandObject(), and QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass().
bool QScriptValueIterator::hasNext | ( | ) | const |
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.
Definition at line 165 of file qscriptvalueiterator.cpp.
Referenced by FlatListModel::addValue(), QScriptObjectSnapshot::capture(), QDeclarativeComponentPrivate::createObject(), QScriptDebuggerCommandExecutor::execute(), expandObject(), QDeclarativeGlobalScriptClass::explicitSetProperty(), QJSDebuggerAgentPrivate::getLocals(), QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), NestedListModel::set(), and ModelNode::setObjectValue().
bool QScriptValueIterator::hasPrevious | ( | ) | const |
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.
Definition at line 201 of file qscriptvalueiterator.cpp.
QString QScriptValueIterator::name | ( | ) | const |
Returns the name of the last property that was jumped over using next() or previous().
Definition at line 265 of file qscriptvalueiterator.cpp.
Referenced by FlatListModel::addValue(), QScriptObjectSnapshot::capture(), QDeclarativeComponentPrivate::createObject(), QScriptDebuggerCommandExecutor::execute(), expandObject(), QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), NestedListModel::set(), and ModelNode::setObjectValue().
void 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.
Definition at line 183 of file qscriptvalueiterator.cpp.
Referenced by FlatListModel::addValue(), QScriptObjectSnapshot::capture(), QDeclarativeComponentPrivate::createObject(), QScriptDebuggerCommandExecutor::execute(), expandObject(), QDeclarativeGlobalScriptClass::explicitSetProperty(), QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), NestedListModel::set(), and ModelNode::setObjectValue().
QScriptValueIterator & QScriptValueIterator::operator= | ( | QScriptValue & | object | ) |
Makes the iterator operate on object.
The iterator is set to be at the front of the sequence of properties (before the first property).
Definition at line 358 of file qscriptvalueiterator.cpp.
void 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.
Definition at line 219 of file qscriptvalueiterator.cpp.
void QScriptValueIterator::remove | ( | ) |
Removes the last property that was jumped over using next() or previous().
Definition at line 343 of file qscriptvalueiterator.cpp.
QScriptString QScriptValueIterator::scriptName | ( | ) | const |
Returns the name of the last property that was jumped over using next() or previous().
Definition at line 282 of file qscriptvalueiterator.cpp.
Referenced by QDeclarativeGlobalScriptClass::explicitSetProperty(), and QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass().
void QScriptValueIterator::setValue | ( | const QScriptValue & | value | ) |
Sets the value of the last property that was jumped over using next() or previous().
Definition at line 312 of file qscriptvalueiterator.cpp.
void QScriptValueIterator::toBack | ( | ) |
Moves the iterator to the back of the QScriptValue (after the last property).
Definition at line 250 of file qscriptvalueiterator.cpp.
void QScriptValueIterator::toFront | ( | ) |
Moves the iterator to the front of the QScriptValue (before the first property).
Definition at line 235 of file qscriptvalueiterator.cpp.
QScriptValue QScriptValueIterator::value | ( | ) | const |
Returns the value of the last property that was jumped over using next() or previous().
Definition at line 296 of file qscriptvalueiterator.cpp.
Referenced by FlatListModel::addValue(), QScriptObjectSnapshot::capture(), QDeclarativeComponentPrivate::createObject(), QScriptDebuggerCommandExecutor::execute(), expandObject(), QDeclarativeGlobalScriptClass::explicitSetProperty(), QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(), QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(), and ModelNode::setObjectValue().
|
private |
Definition at line 69 of file qscriptvalueiterator.h.
Referenced by operator=(), and QScriptValueIterator().