Qt 4.8
Public Functions | Protected Functions | Protected Variables | List of all members
QScriptClassPropertyIterator Class Referenceabstract

The QScriptClassPropertyIterator class provides an iterator interface for custom Qt Script objects. More...

#include <qscriptclasspropertyiterator.h>

Public Functions

virtual QScriptValue::PropertyFlags flags () const
 Returns the flags of the last property that was jumped over using next() or previous(). More...
 
virtual bool hasNext () const =0
 Returns true if there is at least one item ahead of the iterator (i. More...
 
virtual bool hasPrevious () const =0
 Returns true if there is at least one item behind the iterator (i. More...
 
virtual uint id () const
 Returns the id of the last property that was jumped over using next() or previous(). More...
 
virtual QScriptString name () const =0
 Returns the name of the last property that was jumped over using next() or previous(). More...
 
virtual void next ()=0
 Advances the iterator by one position. More...
 
QScriptValue object () const
 Returns the Qt Script object this iterator is traversing. More...
 
virtual void previous ()=0
 Moves the iterator back by one position. More...
 
virtual void toBack ()=0
 Moves the iterator to the back of the QScriptValue (after the last property). More...
 
virtual void toFront ()=0
 Moves the iterator to the front of the QScriptValue (before the first property). More...
 
virtual ~QScriptClassPropertyIterator ()
 Destroys the iterator. More...
 

Protected Functions

 QScriptClassPropertyIterator (const QScriptValue &object)
 Constructs an iterator for traversing object. More...
 
 QScriptClassPropertyIterator (const QScriptValue &object, QScriptClassPropertyIteratorPrivate &dd)
 

Protected Variables

QScopedPointer< QScriptClassPropertyIteratorPrivated_ptr
 

Detailed Description

The QScriptClassPropertyIterator class provides an iterator interface for custom Qt Script objects.

Since
4.4

This class is only relevant if you have subclassed QScriptClass and want to provide enumeration of your custom properties (e.g. when objects of your class are used with QScriptValueIterator, or with the for-in statement in scripts).

The object() function returns the Qt Script object the iterator is traversing.

toFront(), hasNext() and next() provide forward iteration.

toBack(), hasPrevious() and previous() provide backward iteration.

name(), id() and flags() return information about the last property that was jumped over using next() or previous().

See also
QScriptClass::newIterator(), QScriptValueIterator

Definition at line 39 of file qscriptclasspropertyiterator.h.

Constructors and Destructors

◆ QScriptClassPropertyIterator() [1/2]

QScriptClassPropertyIterator::QScriptClassPropertyIterator ( const QScriptValue object)
protected

Constructs an iterator for traversing object.

Subclasses should ensure that the iterator is set to the front of the sequence of properties (before the first property).

Definition at line 77 of file qscriptclasspropertyiterator.cpp.

79 {
80  d_ptr->q_ptr = this;
81  d_ptr->object = object;
82 }
QScriptValue object() const
Returns the Qt Script object this iterator is traversing.
QScopedPointer< QScriptClassPropertyIteratorPrivate > d_ptr

◆ ~QScriptClassPropertyIterator()

QScriptClassPropertyIterator::~QScriptClassPropertyIterator ( )
virtual

Destroys the iterator.

Definition at line 98 of file qscriptclasspropertyiterator.cpp.

99 {
100 }

◆ QScriptClassPropertyIterator() [2/2]

QScriptClassPropertyIterator::QScriptClassPropertyIterator ( const QScriptValue object,
QScriptClassPropertyIteratorPrivate dd 
)
protected
Warning
This function is not part of the public interface.

Definition at line 87 of file qscriptclasspropertyiterator.cpp.

89  : d_ptr(&dd)
90 {
91  d_ptr->q_ptr = this;
92  d_ptr->object = object;
93 }
QScriptValue object() const
Returns the Qt Script object this iterator is traversing.
QScopedPointer< QScriptClassPropertyIteratorPrivate > d_ptr

Functions

◆ flags()

QScriptValue::PropertyFlags QScriptClassPropertyIterator::flags ( ) const
virtual

Returns the flags of the last property that was jumped over using next() or previous().

The default implementation calls the propertyFlags() function of object() with argument name().

Definition at line 226 of file qscriptclasspropertyiterator.cpp.

227 {
228  return object().propertyFlags(name());
229 }
QScriptValue::PropertyFlags propertyFlags(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the flags of the property with the given name, using the given mode to resolve the property...
QScriptValue object() const
Returns the Qt Script object this iterator is traversing.
virtual QScriptString name() const =0
Returns the name of the last property that was jumped over using next() or previous().

◆ hasNext()

bool QScriptClassPropertyIterator::hasNext ( ) const
pure virtual

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(), hasPrevious()

Referenced by QScript::ClassObjectDelegate::getOwnPropertyNames().

◆ hasPrevious()

bool QScriptClassPropertyIterator::hasPrevious ( ) const
pure virtual

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(), hasNext()

◆ id()

uint QScriptClassPropertyIterator::id ( ) const
virtual

Returns the id of the last property that was jumped over using next() or previous().

The default implementation returns 0.

See also
name()

Definition at line 214 of file qscriptclasspropertyiterator.cpp.

215 {
216  return 0;
217 }

◆ name()

QScriptString QScriptClassPropertyIterator::name ( ) const
pure virtual

Returns the name of the last property that was jumped over using next() or previous().

See also
id()

Referenced by flags(), and QScript::ClassObjectDelegate::getOwnPropertyNames().

◆ next()

void QScriptClassPropertyIterator::next ( )
pure virtual

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(), name()

Referenced by QScript::ClassObjectDelegate::getOwnPropertyNames().

◆ object()

QScriptValue QScriptClassPropertyIterator::object ( ) const

Returns the Qt Script object this iterator is traversing.

Definition at line 105 of file qscriptclasspropertyiterator.cpp.

Referenced by flags(), and QScriptClassPropertyIterator().

106 {
108  return d->object;
109 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptClassPropertyIterator class provides an iterator interface for custom Qt Script objects...

◆ previous()

void QScriptClassPropertyIterator::previous ( )
pure virtual

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(), name()

◆ toBack()

void QScriptClassPropertyIterator::toBack ( )
pure virtual

Moves the iterator to the back of the QScriptValue (after the last property).

See also
toFront(), previous()

◆ toFront()

void QScriptClassPropertyIterator::toFront ( )
pure virtual

Moves the iterator to the front of the QScriptValue (before the first property).

See also
toBack(), next()

Properties

◆ d_ptr

QScopedPointer<QScriptClassPropertyIteratorPrivate> QScriptClassPropertyIterator::d_ptr
protected

Definition at line 64 of file qscriptclasspropertyiterator.h.

Referenced by QScriptClassPropertyIterator().


The documentation for this class was generated from the following files: