1/****************************************************************************
2**
3** Copyright (C) 2018 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtSCriptTools 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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qscriptdebuggervalueproperty_p.h"
41#include "qscriptdebuggervalue_p.h"
42#include "qscriptdebuggerobjectsnapshotdelta_p.h"
43
44#include <QtCore/qshareddata.h>
45#include <QtCore/qdatastream.h>
46#include <QtCore/qstring.h>
47
48QT_BEGIN_NAMESPACE
49
50/*!
51 \internal
52 \class QScriptDebuggerValueProperty
53*/
54
55class QScriptDebuggerValuePropertyPrivate : public QSharedData
56{
57public:
58 QScriptDebuggerValuePropertyPrivate();
59 ~QScriptDebuggerValuePropertyPrivate();
60
61 QString name;
62 QScriptDebuggerValue value;
63 QString valueAsString;
64 QScriptValue::PropertyFlags flags;
65};
66
67QScriptDebuggerValuePropertyPrivate::QScriptDebuggerValuePropertyPrivate()
68{
69}
70
71QScriptDebuggerValuePropertyPrivate::~QScriptDebuggerValuePropertyPrivate()
72{
73}
74
75/*!
76 Constructs an invalid QScriptDebuggerValueProperty.
77*/
78QScriptDebuggerValueProperty::QScriptDebuggerValueProperty()
79 : d_ptr(0)
80{
81}
82
83/*!
84 Constructs a QScriptDebuggerValueProperty with the given \a name,
85 \a value and \a flags.
86*/
87QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QString &name,
88 const QScriptDebuggerValue &value,
89 const QString &valueAsString,
90 QScriptValue::PropertyFlags flags)
91 : d_ptr(new QScriptDebuggerValuePropertyPrivate)
92{
93 d_ptr->name = name;
94 d_ptr->value = value;
95 d_ptr->valueAsString = valueAsString;
96 d_ptr->flags = flags;
97 d_ptr->ref.ref();
98}
99
100/*!
101 Constructs a QScriptDebuggerValueProperty that is a copy of the \a other property.
102*/
103QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebuggerValueProperty &other)
104 : d_ptr(other.d_ptr.data())
105{
106 if (d_ptr)
107 d_ptr->ref.ref();
108}
109
110/*!
111 Destroys this QScriptDebuggerValueProperty.
112*/
113QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty()
114{
115}
116
117/*!
118 Assigns the \a other property to this QScriptDebuggerValueProperty.
119*/
120QScriptDebuggerValueProperty &QScriptDebuggerValueProperty::operator=(const QScriptDebuggerValueProperty &other)
121{
122 d_ptr.assign(other: other.d_ptr.data());
123 return *this;
124}
125
126/*!
127 Returns the name of this QScriptDebuggerValueProperty.
128*/
129QString QScriptDebuggerValueProperty::name() const
130{
131 Q_D(const QScriptDebuggerValueProperty);
132 if (!d)
133 return QString();
134 return d->name;
135}
136
137/*!
138 Returns the value of this QScriptDebuggerValueProperty.
139*/
140QScriptDebuggerValue QScriptDebuggerValueProperty::value() const
141{
142 Q_D(const QScriptDebuggerValueProperty);
143 if (!d)
144 return QScriptDebuggerValue();
145 return d->value;
146}
147
148QString QScriptDebuggerValueProperty::valueAsString() const
149{
150 Q_D(const QScriptDebuggerValueProperty);
151 if (!d)
152 return QString();
153 return d->valueAsString;
154}
155
156/*!
157 Returns the flags of this QScriptDebuggerValueProperty.
158*/
159QScriptValue::PropertyFlags QScriptDebuggerValueProperty::flags() const
160{
161 Q_D(const QScriptDebuggerValueProperty);
162 if (!d)
163 return {};
164 return d->flags;
165}
166
167/*!
168 Returns true if this QScriptDebuggerValueProperty is valid, otherwise
169 returns false.
170*/
171bool QScriptDebuggerValueProperty::isValid() const
172{
173 Q_D(const QScriptDebuggerValueProperty);
174 return (d != 0);
175}
176
177/*!
178 \relates QScriptDebuggerValueProperty
179
180 Writes the given \a property to the specified \a stream.
181*/
182QDataStream &operator<<(QDataStream &out, const QScriptDebuggerValueProperty &property)
183{
184 out << property.name();
185 out << property.value();
186 out << property.valueAsString();
187 out << (quint32)property.flags();
188 return out;
189}
190
191/*!
192 \relates QScriptDebuggerValueProperty
193
194 Reads a QScriptDebuggerValueProperty from the specified \a stream into the
195 given \a property.
196*/
197QDataStream &operator>>(QDataStream &in, QScriptDebuggerValueProperty &property)
198{
199 QString name;
200 QScriptDebuggerValue value;
201 QString valueAsString;
202 quint32 flags;
203 in >> name;
204 in >> value;
205 in >> valueAsString;
206 in >> flags;
207 property = QScriptDebuggerValueProperty(
208 name, value, valueAsString, QScriptValue::PropertyFlags(flags));
209 return in;
210}
211
212QDataStream &operator<<(QDataStream &out, const QScriptDebuggerObjectSnapshotDelta &delta)
213{
214 out << delta.removedProperties;
215 out << delta.changedProperties;
216 out << delta.addedProperties;
217 return out;
218}
219
220QDataStream &operator>>(QDataStream &in, QScriptDebuggerObjectSnapshotDelta &delta)
221{
222 in >> delta.removedProperties;
223 in >> delta.changedProperties;
224 in >> delta.addedProperties;
225 return in;
226}
227
228QT_END_NAMESPACE
229

source code of qtscript/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp