qscriptclass.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtScript module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
00010 ** GNU Lesser General Public License Usage
00011 ** This file may be used under the terms of the GNU Lesser
00012 ** General Public License version 2.1 as published by the Free Software
00013 ** Foundation and appearing in the file LICENSE.LGPL included in the
00014 ** packaging of this file.  Please review the following information to
00015 ** ensure the GNU Lesser General Public License version 2.1 requirements
00016 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00017 **
00018 ** If you have questions regarding the use of this file, please contact
00019 ** Nokia at qt-info@nokia.com.
00020 ** $QT_END_LICENSE$
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef QSCRIPTCLASS_H
00025 #define QSCRIPTCLASS_H
00026 
00027 #include <QtCore/qstring.h>
00028 
00029 #include <QtCore/qvariant.h>
00030 #include <QtCore/qscopedpointer.h>
00031 #include <QtScript/qscriptvalue.h>
00032 
00033 QT_BEGIN_HEADER
00034 
00035 QT_BEGIN_NAMESPACE
00036 
00037 QT_MODULE(Script)
00038 
00039 class QScriptString;
00040 class QScriptClassPropertyIterator;
00041 
00042 class QScriptClassPrivate;
00043 class Q_SCRIPT_EXPORT QScriptClass
00044 {
00045 public:
00046     enum QueryFlag {
00047         HandlesReadAccess = 0x01,
00048         HandlesWriteAccess = 0x02
00049     };
00050     Q_DECLARE_FLAGS(QueryFlags, QueryFlag)
00051 
00052     enum Extension {
00053         Callable,
00054         HasInstance
00055     };
00056 
00057     QScriptClass(QScriptEngine *engine);
00058     virtual ~QScriptClass();
00059 
00060     QScriptEngine *engine() const;
00061 
00062     virtual QueryFlags queryProperty(const QScriptValue &object,
00063                                      const QScriptString &name,
00064                                      QueryFlags flags, uint *id);
00065 
00066     virtual QScriptValue property(const QScriptValue &object,
00067                                   const QScriptString &name, uint id);
00068 
00069     virtual void setProperty(QScriptValue &object, const QScriptString &name,
00070                              uint id, const QScriptValue &value);
00071 
00072     virtual QScriptValue::PropertyFlags propertyFlags(
00073         const QScriptValue &object, const QScriptString &name, uint id);
00074 
00075     virtual QScriptClassPropertyIterator *newIterator(const QScriptValue &object);
00076 
00077     virtual QScriptValue prototype() const;
00078 
00079     virtual QString name() const;
00080 
00081     virtual bool supportsExtension(Extension extension) const;
00082     virtual QVariant extension(Extension extension,
00083                                const QVariant &argument = QVariant());
00084 
00085 protected:
00086     QScriptClass(QScriptEngine *engine, QScriptClassPrivate &dd);
00087     QScopedPointer<QScriptClassPrivate> d_ptr;
00088 
00089 private:
00090     Q_DECLARE_PRIVATE(QScriptClass)
00091     Q_DISABLE_COPY(QScriptClass)
00092 };
00093 
00094 Q_DECLARE_OPERATORS_FOR_FLAGS(QScriptClass::QueryFlags)
00095 
00096 QT_END_NAMESPACE
00097 
00098 QT_END_HEADER
00099 
00100 #endif