Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / v8 / qjsvalue.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtScript module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.LGPL included in the
13 ** packaging of this file.  Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** If you have questions regarding the use of this file, please contact
18 ** us via http://www.qt-project.org/.
19 **
20 ** $QT_END_LICENSE$
21 **
22 ****************************************************************************/
23
24 #ifndef QJSVALUE_H
25 #define QJSVALUE_H
26
27 #include <QtCore/qstring.h>
28
29 #include <QtCore/qlist.h>
30 #include <QtCore/qsharedpointer.h>
31 #include <QtCore/qshareddata.h>
32
33 QT_BEGIN_HEADER
34
35 QT_BEGIN_NAMESPACE
36
37
38 class QJSValue;
39 class QJSEngine;
40 class QVariant;
41 class QObject;
42 struct QMetaObject;
43 class QDateTime;
44 class QRegExp;
45
46 typedef QList<QJSValue> QJSValueList;
47
48 class QJSValuePrivate;
49 struct QScriptValuePrivatePointerDeleter;
50 template <class T> class QScriptPassPointer;
51
52 class Q_DECLARATIVE_EXPORT QJSValue
53 {
54 public:
55 #ifdef QT_DEPRECATED
56     enum PropertyFlag {
57         ReadOnly            = 0x00000001,
58         Undeletable         = 0x00000002,
59         SkipInEnumeration   = 0x00000004
60     };
61     Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
62 #endif
63
64     enum SpecialValue {
65         NullValue,
66         UndefinedValue
67     };
68
69 public:
70     QJSValue();
71     ~QJSValue();
72     QJSValue(const QJSValue &other);
73
74     QJSValue(SpecialValue value);
75     QJSValue(bool value);
76     QJSValue(int value);
77     QJSValue(uint value);
78     QJSValue(double value);
79     QJSValue(const QString &value);
80     QJSValue(const QLatin1String &value);
81 #ifndef QT_NO_CAST_FROM_ASCII
82     QT_ASCII_CAST_WARN_CONSTRUCTOR QJSValue(const char *str);
83 #endif
84
85     QJSValue &operator=(const QJSValue &other);
86
87     bool isBool() const;
88     bool isNumber() const;
89     bool isNull() const;
90     bool isString() const;
91     bool isUndefined() const;
92     bool isVariant() const;
93     bool isQObject() const;
94     bool isObject() const;
95     bool isDate() const;
96     bool isRegExp() const;
97     bool isArray() const;
98     bool isError() const;
99
100     QString toString() const;
101     double toNumber() const;
102     qint32 toInt() const;
103     quint32 toUInt() const;
104     bool toBool() const;
105     QVariant toVariant() const;
106     QObject *toQObject() const;
107     QDateTime toDateTime() const;
108
109     bool equals(const QJSValue &other) const;
110     bool strictlyEquals(const QJSValue &other) const;
111
112     QJSValue prototype() const;
113     void setPrototype(const QJSValue &prototype);
114
115     QJSValue property(const QString &name) const;
116     void setProperty(const QString &name, const QJSValue &value);
117
118     bool hasProperty(const QString &name) const;
119     bool hasOwnProperty(const QString &name) const;
120
121     QJSValue property(quint32 arrayIndex) const;
122     void setProperty(quint32 arrayIndex, const QJSValue &value);
123
124     bool deleteProperty(const QString &name);
125
126     bool isCallable() const;
127     QJSValue call(const QJSValueList &args);
128     QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
129     QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
130
131 #ifdef QT_DEPRECATED
132     QT_DEPRECATED QJSValue(QJSEngine *engine, SpecialValue val);
133     QT_DEPRECATED QJSValue(QJSEngine *engine, bool val);
134     QT_DEPRECATED QJSValue(QJSEngine *engine, int val);
135     QT_DEPRECATED QJSValue(QJSEngine *engine, uint val);
136     QT_DEPRECATED QJSValue(QJSEngine *engine, double val);
137     QT_DEPRECATED QJSValue(QJSEngine *engine, const QString &val);
138
139     QT_DEPRECATED QJSEngine *engine() const;
140
141     QT_DEPRECATED bool isValid() const;
142     QT_DEPRECATED bool isFunction() const;
143     QT_DEPRECATED double toInteger() const;
144     QT_DEPRECATED qint32 toInt32() const;
145     QT_DEPRECATED quint32 toUInt32() const;
146     QT_DEPRECATED quint16 toUInt16() const;
147     QT_DEPRECATED QJSValue toObject() const;
148     QT_DEPRECATED QRegExp toRegExp() const;
149
150     QT_DEPRECATED bool instanceOf(const QJSValue &other) const;
151
152     QT_DEPRECATED QJSValue::PropertyFlags propertyFlags(const QString &name) const;
153
154     QT_DEPRECATED QJSValue call(const QJSValue &thisObject = QJSValue(),
155                       const QJSValueList &args = QJSValueList());
156     QT_DEPRECATED QJSValue construct(const QJSValueList &args = QJSValueList());
157 #endif
158
159 private:
160     // force compile error, prevent QJSValue(bool) to be called
161     QJSValue(void *);
162 #ifdef QT_DEPRECATED
163     // force compile error, prevent QJSValue(QScriptEngine*, bool) to be called
164     QJSValue(QJSEngine *, void *);
165     QJSValue(QJSEngine *, const char *);
166 #endif
167
168     QJSValue(QJSValuePrivate*);
169     QJSValue(QScriptPassPointer<QJSValuePrivate>);
170
171 private:
172     QExplicitlySharedDataPointer<QJSValuePrivate> d_ptr;
173
174     Q_DECLARE_PRIVATE(QJSValue)
175 };
176
177 #ifdef QT_DEPRECATED
178 Q_DECLARE_OPERATORS_FOR_FLAGS(QJSValue::PropertyFlags)
179 #endif
180
181 QT_END_NAMESPACE
182
183 QT_END_HEADER
184
185 #endif