Change copyrights from Nokia to Digia
[profile/ivi/qtdeclarative.git] / src / qml / qml / v8 / qjsvalue.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QJSVALUE_H
43 #define QJSVALUE_H
44
45 #include <QtQml/qtqmlglobal.h>
46 #include <QtCore/qstring.h>
47 #include <QtCore/qlist.h>
48 #include <QtCore/qsharedpointer.h>
49 #include <QtCore/qshareddata.h>
50
51 QT_BEGIN_HEADER
52
53 QT_BEGIN_NAMESPACE
54
55
56 class QJSValue;
57 class QJSEngine;
58 class QVariant;
59 class QObject;
60 struct QMetaObject;
61 class QDateTime;
62
63 typedef QList<QJSValue> QJSValueList;
64
65 class QJSValuePrivate;
66 struct QScriptValuePrivatePointerDeleter;
67 template <class T> class QScriptPassPointer;
68
69 class Q_QML_EXPORT QJSValue
70 {
71 public:
72     enum SpecialValue {
73         NullValue,
74         UndefinedValue
75     };
76
77 public:
78     QJSValue(SpecialValue value = UndefinedValue);
79     ~QJSValue();
80     QJSValue(const QJSValue &other);
81
82     QJSValue(bool value);
83     QJSValue(int value);
84     QJSValue(uint value);
85     QJSValue(double value);
86     QJSValue(const QString &value);
87     QJSValue(const QLatin1String &value);
88 #ifndef QT_NO_CAST_FROM_ASCII
89     QT_ASCII_CAST_WARN QJSValue(const char *str);
90 #endif
91
92     QJSValue &operator=(const QJSValue &other);
93
94     bool isBool() const;
95     bool isNumber() const;
96     bool isNull() const;
97     bool isString() const;
98     bool isUndefined() const;
99     bool isVariant() const;
100     bool isQObject() const;
101     bool isObject() const;
102     bool isDate() const;
103     bool isRegExp() const;
104     bool isArray() const;
105     bool isError() const;
106
107     QString toString() const;
108     double toNumber() const;
109     qint32 toInt() const;
110     quint32 toUInt() const;
111     bool toBool() const;
112     QVariant toVariant() const;
113     QObject *toQObject() const;
114     QDateTime toDateTime() const;
115
116     bool equals(const QJSValue &other) const;
117     bool strictlyEquals(const QJSValue &other) const;
118
119     QJSValue prototype() const;
120     void setPrototype(const QJSValue &prototype);
121
122     QJSValue property(const QString &name) const;
123     void setProperty(const QString &name, const QJSValue &value);
124
125     bool hasProperty(const QString &name) const;
126     bool hasOwnProperty(const QString &name) const;
127
128     QJSValue property(quint32 arrayIndex) const;
129     void setProperty(quint32 arrayIndex, const QJSValue &value);
130
131     bool deleteProperty(const QString &name);
132
133     bool isCallable() const;
134     QJSValue call(const QJSValueList &args = QJSValueList());
135     QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
136     QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
137
138 #ifdef QT_DEPRECATED
139     QT_DEPRECATED QJSEngine *engine() const;
140 #endif
141
142 private:
143     // force compile error, prevent QJSValue(bool) to be called
144
145     QJSValue(void *) Q_DECL_EQ_DELETE;
146
147     QJSValue(QJSValuePrivate*);
148     QJSValue(QScriptPassPointer<QJSValuePrivate>);
149
150 private:
151     QExplicitlySharedDataPointer<QJSValuePrivate> d_ptr;
152
153     Q_DECLARE_PRIVATE(QJSValue)
154 };
155
156 QT_END_NAMESPACE
157
158 QT_END_HEADER
159
160 #endif