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

Public Functions

 NamedNodeMapClass (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 187 of file qdeclarativexmlhttprequest.cpp.

Constructors and Destructors

◆ NamedNodeMapClass()

NamedNodeMapClass::NamedNodeMapClass ( QScriptEngine engine)
inline

Definition at line 190 of file qdeclarativexmlhttprequest.cpp.

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

Functions

◆ property()

QScriptValue NamedNodeMapClass::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 883 of file qdeclarativexmlhttprequest.cpp.

884 {
886  return Node::create(engine(), map.list->at(id));
887 }
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 * > * list
static QScriptValue create(QScriptEngine *, NodeImpl *)

◆ queryProperty()

NamedNodeMapClass::QueryFlags NamedNodeMapClass::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 854 of file qdeclarativexmlhttprequest.cpp.

855 {
856  if (!(flags & HandlesReadAccess))
857  return 0;
858 
860  Q_ASSERT(!map.isNull());
861 
862  bool ok = false;
863  QString nameString = name.toString();
864  uint index = nameString.toUInt(&ok);
865  if (ok) {
866  if ((uint)map.list->count() <= index)
867  return 0;
868 
869  *id = index;
870  return HandlesReadAccess;
871  } else {
872  for (int ii = 0; ii < map.list->count(); ++ii) {
873  if (map.list->at(ii) && map.list->at(ii)->name == nameString) {
874  *id = ii;
875  return HandlesReadAccess;
876  }
877  }
878  }
879 
880  return 0;
881 }
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
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
unsigned int uint
Definition: qglobal.h:996
QList< NodeImpl * > * list
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: