Qt 4.8
qscriptdebuggerevent.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 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 #include "qscriptdebuggerevent_p.h"
43 #include "qscriptdebuggervalue_p.h"
44 
45 #include <QtCore/qhash.h>
46 #include <QtCore/qdatastream.h>
47 
49 
51 
53 {
54 public:
57 
60 };
61 
64 {
65 }
66 
68 {
69 }
70 
72  : d_ptr(new QScriptDebuggerEventPrivate)
73 {
74  d_ptr->type = None;
75 }
76 
79 {
80  d_ptr->type = type;
81 }
82 
84  int lineNumber, int columnNumber)
86 {
87  d_ptr->type = type;
91 }
92 
95 {
96  *d_ptr = *other.d_ptr;
97 }
98 
100 {
101 }
102 
104 {
105  *d_ptr = *other.d_ptr;
106  return *this;
107 }
108 
110 {
111  Q_D(const QScriptDebuggerEvent);
112  return d->type;
113 }
114 
116  const QVariant &defaultValue) const
117 {
118  Q_D(const QScriptDebuggerEvent);
119  return d->attributes.value(attribute, defaultValue);
120 }
121 
123  const QVariant &value)
124 {
126  if (!value.isValid())
127  d->attributes.remove(attribute);
128  else
129  d->attributes[attribute] = value;
130 }
131 
133 {
134  Q_D(const QScriptDebuggerEvent);
135  return d->attributes;
136 }
137 
139 {
140  Q_D(const QScriptDebuggerEvent);
141  return d->attributes.value(ScriptID, -1).toLongLong();
142 }
143 
145 {
147  d->attributes[ScriptID] = id;
148 }
149 
151 {
152  Q_D(const QScriptDebuggerEvent);
153  return d->attributes.value(FileName).toString();
154 }
155 
157 {
159  d->attributes[FileName] = fileName;
160 }
161 
163 {
164  Q_D(const QScriptDebuggerEvent);
165  return d->attributes.value(LineNumber, -1).toInt();
166 }
167 
169 {
171  d->attributes[LineNumber] = lineNumber;
172 }
173 
175 {
176  Q_D(const QScriptDebuggerEvent);
177  return d->attributes.value(ColumnNumber, -1).toInt();
178 }
179 
181 {
183  d->attributes[ColumnNumber] = columnNumber;
184 }
185 
187 {
188  Q_D(const QScriptDebuggerEvent);
189  return d->attributes.value(BreakpointID, -1).toInt();
190 }
191 
193 {
195  d->attributes[BreakpointID] = id;
196 }
197 
199 {
200  Q_D(const QScriptDebuggerEvent);
201  return d->attributes.value(Message).toString();
202 }
203 
205 {
207  d->attributes[Message] = message;
208 }
209 
211 {
212  Q_D(const QScriptDebuggerEvent);
213  return qvariant_cast<QScriptDebuggerValue>(d->attributes[Value]);
214 }
215 
217 {
219  d->attributes[Value] = QVariant::fromValue(value);
220 }
221 
223 {
225  d->attributes[IsNestedEvaluate] = nested;
226 }
227 
229 {
230  Q_D(const QScriptDebuggerEvent);
231  return d->attributes.value(IsNestedEvaluate).toBool();
232 }
233 
235 {
237  d->attributes[HasExceptionHandler] = hasHandler;
238 }
239 
241 {
242  Q_D(const QScriptDebuggerEvent);
243  return d->attributes.value(HasExceptionHandler).toBool();
244 }
245 
251 {
252  Q_D(const QScriptDebuggerEvent);
253  const QScriptDebuggerEventPrivate *od = other.d_func();
254  if (d == od)
255  return true;
256  if (!d || !od)
257  return false;
258  return ((d->type == od->type)
259  && (d->attributes == od->attributes));
260 }
261 
267 {
268  return !(*this == other);
269 }
270 
281 {
282  const QScriptDebuggerEventPrivate *d = event.d_ptr.data();
283  out << (quint32)d->type;
284  out << (qint32)d->attributes.size();
286  for (it = d->attributes.constBegin(); it != d->attributes.constEnd(); ++it) {
287  out << (quint32)it.key();
288  out << it.value();
289  }
290  return out;
291 }
292 
304 {
305  QScriptDebuggerEventPrivate *d = event.d_ptr.data();
306 
307  quint32 type;
308  in >> type;
309  d->type = QScriptDebuggerEvent::Type(type);
310 
311  qint32 attribCount;
312  in >> attribCount;
314  for (qint32 i = 0; i < attribCount; ++i) {
315  quint32 key;
316  in >> key;
317  QVariant value;
318  in >> value;
319  attribs[QScriptDebuggerEvent::Attribute(key)] = value;
320  }
321  d->attributes = attribs;
322 
323  return in;
324 }
325 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QScriptDebuggerEvent & operator=(const QScriptDebuggerEvent &other)
QScopedPointer< QScriptDebuggerEventPrivate > d_ptr
void setColumnNumber(int columnNumber)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int qint32
Definition: qglobal.h:937
EventRef event
#define it(className, varName)
QHash< QScriptDebuggerEvent::Attribute, QVariant > attributes
bool operator==(const QScriptDebuggerEvent &other) const
Returns true if this QScriptDebuggerEvent is equal to the other event, otherwise returns false...
void setLineNumber(int lineNumber)
QHash< Attribute, QVariant > attributes() const
void setNestedEvaluate(bool nested)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QScriptDebuggerEvent::Type type
QVariant attribute(Attribute attribute, const QVariant &defaultValue=QVariant()) const
#define Q_D(Class)
Definition: qglobal.h:2482
QScriptDebuggerValue scriptValue() const
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool operator!=(const QScriptDebuggerEvent &other) const
Returns true if this QScriptDebuggerEvent is not equal to the other event, otherwise returns false...
__int64 qint64
Definition: qglobal.h:942
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
#define None
void setScriptValue(const QScriptDebuggerValue &value)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
The QScriptDebuggerValue class represents a script value.
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
friend Q_AUTOTEST_EXPORT QDataStream & operator>>(QDataStream &, QScriptDebuggerEvent &)
Reads a QScriptDebuggerEvent from the specified stream into the given event.
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
void setAttribute(Attribute attribute, const QVariant &value)
int key
unsigned int quint32
Definition: qglobal.h:938
void setHasExceptionHandler(bool hasHandler)
friend Q_AUTOTEST_EXPORT QDataStream & operator<<(QDataStream &, const QScriptDebuggerEvent &)
Writes the given event to the specified stream.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
void setMessage(const QString &message)
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
void setFileName(const QString &fileName)