Qt 4.8
qscriptbreakpointdata.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 
43 
44 #include <QtCore/qdatastream.h>
45 #include <QtCore/qstring.h>
46 #include <QtCore/qvariant.h>
47 
49 
62 {
63 public:
66 
67  void init(int ln);
68 
72  bool enabled;
73  bool singleShot;
77  int hitCount;
78 };
79 
81 {
82 }
83 
85 {
86 }
87 
89 {
90  scriptId = -1;
91  lineNumber = ln;
92  enabled = true;
93  singleShot = false;
94  ignoreCount = 0;
95  hitCount = 0;
96 }
97 
102  : d_ptr(new QScriptBreakpointDataPrivate)
103 {
104  d_ptr->init(/*lineNumber=*/-1);
105 }
106 
112 {
113  d_ptr->init(lineNumber);
115 }
116 
122 {
123  d_ptr->init(lineNumber);
125 }
126 
132 {
133  Q_ASSERT(other.d_ptr != 0);
134  *d_ptr = *other.d_ptr;
135 }
136 
141 {
142 }
143 
148 {
149  Q_ASSERT(d_ptr != 0);
150  Q_ASSERT(other.d_ptr != 0);
151  *d_ptr = *other.d_ptr;
152  return *this;
153 }
154 
156 {
157  Q_D(const QScriptBreakpointData);
158  return d->scriptId;
159 }
160 
162 {
164  d->scriptId = id;
165 }
166 
168 {
169  Q_D(const QScriptBreakpointData);
170  return d->fileName;
171 }
172 
174 {
176  d->fileName = fileName;
177 }
178 
183 {
184  Q_D(const QScriptBreakpointData);
185  return d->lineNumber;
186 }
187 
192 {
194  d->lineNumber = lineNumber;
195 }
196 
201 {
202  Q_D(const QScriptBreakpointData);
203  return d->enabled;
204 }
205 
210 {
212  d->enabled = enabled;
213 }
214 
219 {
220  Q_D(const QScriptBreakpointData);
221  return d->singleShot;
222 }
223 
228 {
230  d->singleShot = singleShot;
231 }
232 
237 {
238  Q_D(const QScriptBreakpointData);
239  return d->ignoreCount;
240 }
241 
246 {
248  d->ignoreCount = count;
249 }
250 
257 {
259  if (d->ignoreCount == 0) {
260  ++d->hitCount;
261  return true;
262  }
263  --d->ignoreCount;
264  return false;
265 }
266 
272 {
273  Q_D(const QScriptBreakpointData);
274  return d->hitCount;
275 }
276 
281 {
282  Q_D(const QScriptBreakpointData);
283  return d->condition;
284 }
285 
290 {
292  d->condition = condition;
293 }
294 
299 {
300  Q_D(const QScriptBreakpointData);
301  return d->data;
302 }
303 
308 {
310  d->data = data;
311 }
312 
314 {
315  Q_D(const QScriptBreakpointData);
316  return (((d->scriptId != -1) || !d->fileName.isEmpty())
317  && (d->lineNumber != -1));
318 }
319 
325 {
326  Q_D(const QScriptBreakpointData);
327  const QScriptBreakpointDataPrivate *od = other.d_func();
328  if (d == od)
329  return true;
330  if (!d || !od)
331  return false;
332  return ((d->scriptId == od->scriptId)
333  && (d->fileName == od->fileName)
334  && (d->lineNumber == od->lineNumber)
335  && (d->enabled == od->enabled)
336  && (d->singleShot == od->singleShot)
337  && (d->condition == od->condition)
338  && (d->ignoreCount == od->ignoreCount)
339  && (d->data == od->data)
340  && (d->hitCount == od->hitCount));
341 }
342 
348 {
349  return !(*this == other);
350 }
351 
362 {
363  const QScriptBreakpointDataPrivate *d = data.d_ptr.data();
364  out << d->scriptId;
365  out << d->fileName;
366  out << d->lineNumber;
367  out << d->enabled;
368  out << d->singleShot;
369  out << d->ignoreCount;
370  out << d->condition;
371  out << d->data;
372  out << d->hitCount;
373  return out;
374 }
375 
387 {
389  in >> d->scriptId;
390  in >> d->fileName;
391  in >> d->lineNumber;
392  in >> d->enabled;
393  in >> d->singleShot;
394  in >> d->ignoreCount;
395  in >> d->condition;
396  in >> d->data;
397  in >> d->hitCount;
398  return in;
399 }
400 
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
friend Q_AUTOTEST_EXPORT QDataStream & operator>>(QDataStream &, QScriptBreakpointData &)
Reads a QScriptBreakpointData from the specified stream into the given data.
bool isSingleShot() const
Returns true if the breakpoint is single-shot, false otherwise.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
~QScriptBreakpointData()
Destroys this QScriptBreakpointData.
T * data() const
Returns the value of the pointer referenced by this object.
QVariant data() const
Returns custom data associated with the breakpoint.
void setFileName(const QString &fileName)
int ignoreCount() const
Returns the ignore count of the breakpoint.
bool operator==(const QScriptBreakpointData &other) const
Returns true if this QScriptBreakpointData is equal to the other data, otherwise returns false...
void setLineNumber(int lineNumber)
Sets the breakpoint line number to lineNumber.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
QScriptBreakpointData & operator=(const QScriptBreakpointData &other)
Assigns other to this QScriptBreakpointData.
void setSingleShot(bool singleShot)
Sets the singleShot state of the breakpoint.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setIgnoreCount(int count)
Sets the ignore count of the breakpoint.
QScopedPointer< QScriptBreakpointDataPrivate > d_ptr
void setEnabled(bool enabled)
Sets the enabled state of the breakpoint.
friend Q_AUTOTEST_EXPORT QDataStream & operator<<(QDataStream &, const QScriptBreakpointData &)
Writes the given data to the specified stream.
__int64 qint64
Definition: qglobal.h:942
void setCondition(const QString &condition)
Sets the condition of the breakpoint.
void setData(const QVariant &data)
Sets custom data associated with the breakpoint.
The QScriptBreakpointData class contains data associated with a breakpoint.
bool operator!=(const QScriptBreakpointData &other) const
Returns true if this QScriptBreakpointData is not equal to the other data, otherwise returns false...
bool isEnabled() const
Returns true if the breakpoint is enabled, false otherwise.
QString condition() const
Returns the condition of the breakpoint.
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
int hitCount() const
Returns the hit count of the breakpoint (the number of times the breakpoint has been triggered)...
QScriptBreakpointData()
Constructs an empty QScriptBreakpointData.
bool hit()
If the ignore count is 0, this function increments the hit count and returns true.
int lineNumber() const
Returns the breakpoint line number.
#define enabled