Qt 4.8
Public Functions | List of all members
NodeListClass Class Reference
Inheritance diagram for NodeListClass:
QScriptClass

Public Functions

 NodeListClass (QScriptEngine *engine)
 
virtual QScriptValue property (const QScriptValue &object, const QScriptString &name, uint id)
 Returns the value of the property with the given name of the given object. More...
 
virtual QueryFlags queryProperty (const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id)
 Queries this script class for how access to the property with the given name of the given object should be handled. More...
 
- Public Functions inherited from QScriptClass
QScriptEngineengine () const
 Returns the engine that this QScriptClass is associated with. More...
 
virtual QVariant extension (Extension extension, const QVariant &argument=QVariant())
 This virtual function can be reimplemented in a QScriptClass subclass to provide support for extensions. More...
 
virtual QString name () const
 Returns the name of the script class. More...
 
virtual QScriptClassPropertyIteratornewIterator (const QScriptValue &object)
 Returns an iterator for traversing custom properties of the given object. More...
 
virtual QScriptValue::PropertyFlags propertyFlags (const QScriptValue &object, const QScriptString &name, uint id)
 Returns the flags of the property with the given name of the given object. More...
 
virtual QScriptValue prototype () const
 Returns the object to be used as the prototype of new instances of this class (created with QScriptEngine::newObject()). More...
 
 QScriptClass (QScriptEngine *engine)
 Constructs a QScriptClass object to be used in the given engine. More...
 
virtual void setProperty (QScriptValue &object, const QScriptString &name, uint id, const QScriptValue &value)
 Sets the property with the given name of the given object to the given value. More...
 
virtual bool supportsExtension (Extension extension) const
 Returns true if the QScriptClass supports the given extension; otherwise, false is returned. More...
 
virtual ~QScriptClass ()
 Destroys the QScriptClass object. More...
 

Additional Inherited Members

- Public Types inherited from QScriptClass
enum  Extension { Callable, HasInstance }
 This enum specifies the possible extensions to a QScriptClass. More...
 
enum  QueryFlag { HandlesReadAccess = 0x01, HandlesWriteAccess = 0x02 }
 This enum describes flags that are used to query a QScriptClass regarding how access to a property should be handled. More...
 
- Protected Functions inherited from QScriptClass
 QScriptClass (QScriptEngine *engine, QScriptClassPrivate &dd)
 
- Protected Variables inherited from QScriptClass
QScopedPointer< QScriptClassPrivated_ptr
 

Detailed Description

Definition at line 216 of file qdeclarativexmlhttprequest.cpp.

Constructors and Destructors

◆ NodeListClass()

NodeListClass::NodeListClass ( QScriptEngine engine)
inline

Definition at line 219 of file qdeclarativexmlhttprequest.cpp.

219 : QScriptClass(engine) {}
QScriptClass(QScriptEngine *engine)
Constructs a QScriptClass object to be used in the given engine.

Functions

◆ property()

QScriptValue NodeListClass::property ( const QScriptValue object,
const QScriptString name,
uint  id 
)
virtual

Returns the value of the property with the given name of the given object.

The id argument is only useful if you assigned a value to it in queryProperty().

The default implementation does nothing and returns an invalid QScriptValue.

See also
setProperty(), propertyFlags()

Reimplemented from QScriptClass.

Definition at line 907 of file qdeclarativexmlhttprequest.cpp.

908 {
909  NodeList list = qscriptvalue_cast<NodeList>(object.data());
910  return Node::create(engine(), list.d->children.at(id));
911 }
T qscriptvalue_cast(const QScriptValue &)
QScriptEngine * engine() const
Returns the engine that this QScriptClass is associated with.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< NodeImpl * > children
static QScriptValue create(QScriptEngine *, NodeImpl *)

◆ queryProperty()

NodeListClass::QueryFlags NodeListClass::queryProperty ( const QScriptValue object,
const QScriptString name,
QueryFlags  flags,
uint id 
)
virtual

Queries this script class for how access to the property with the given name of the given object should be handled.

The given flags specify the aspects of interest. This function should return a subset of flags to indicate which aspects of property access should be further handled by the script class.

For example, if the flags contain HandlesReadAccess, and you would like your class to handle the reading of the property (through the property() function), the returned flags should include HandlesReadAccess. If the returned flags do not contain HandlesReadAccess, the property will be handled as a normal script object property.

You can optionally use the id argument to store a value that will subsequently be passed on to functions such as property() and setProperty().

The default implementation of this function returns 0.

Note: This function is only called if the given property isn't already a normal property of the object. For example, say you advertise that you want to handle read access to property foo, but not write access; if foo is then assigned a value, it will become a normal script object property, and subsequently you will no longer be queried regarding read access to foo.

See also
property()

Reimplemented from QScriptClass.

Definition at line 889 of file qdeclarativexmlhttprequest.cpp.

890 {
891  if (!(flags & HandlesReadAccess))
892  return 0;
893 
894  bool ok = false;
895  uint index = name.toString().toUInt(&ok);
896  if (!ok)
897  return 0;
898 
899  NodeList list = qscriptvalue_cast<NodeList>(object.data());
900  if (list.isNull() || (uint)list.d->children.count() <= index)
901  return 0; // ### I think we're meant to raise an exception
902 
903  *id = index;
904  return HandlesReadAccess;
905 }
T qscriptvalue_cast(const QScriptValue &)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
unsigned int uint
Definition: qglobal.h:996
QList< NodeImpl * > children
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
Definition: qstring.cpp:6120
quint16 index
QString toString() const
Returns the string that this QScriptString represents, or a null string if this QScriptString is not ...

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