1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtSCriptTools module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qscriptbreakpointdata_p.h"
|
---|
43 |
|
---|
44 | #include <QtCore/qdatastream.h>
|
---|
45 | #include <QtCore/qstring.h>
|
---|
46 | #include <QtCore/qvariant.h>
|
---|
47 |
|
---|
48 | QT_BEGIN_NAMESPACE
|
---|
49 |
|
---|
50 | /*!
|
---|
51 | \since 4.5
|
---|
52 | \class QScriptBreakpointData
|
---|
53 | \internal
|
---|
54 |
|
---|
55 | \brief The QScriptBreakpointData class contains data associated with a breakpoint.
|
---|
56 | */
|
---|
57 |
|
---|
58 | class QScriptBreakpointDataPrivate
|
---|
59 | {
|
---|
60 | public:
|
---|
61 | QScriptBreakpointDataPrivate();
|
---|
62 | ~QScriptBreakpointDataPrivate();
|
---|
63 |
|
---|
64 | void init(int ln);
|
---|
65 |
|
---|
66 | qint64 scriptId;
|
---|
67 | QString fileName;
|
---|
68 | int lineNumber;
|
---|
69 | bool enabled;
|
---|
70 | bool singleShot;
|
---|
71 | int ignoreCount;
|
---|
72 | QString condition;
|
---|
73 | QVariant data;
|
---|
74 | int hitCount;
|
---|
75 | };
|
---|
76 |
|
---|
77 | QScriptBreakpointDataPrivate::QScriptBreakpointDataPrivate()
|
---|
78 | {
|
---|
79 | }
|
---|
80 |
|
---|
81 | QScriptBreakpointDataPrivate::~QScriptBreakpointDataPrivate()
|
---|
82 | {
|
---|
83 | }
|
---|
84 |
|
---|
85 | void QScriptBreakpointDataPrivate::init(int ln)
|
---|
86 | {
|
---|
87 | scriptId = -1;
|
---|
88 | lineNumber = ln;
|
---|
89 | enabled = true;
|
---|
90 | singleShot = false;
|
---|
91 | ignoreCount = 0;
|
---|
92 | hitCount = 0;
|
---|
93 | }
|
---|
94 |
|
---|
95 | /*!
|
---|
96 | Constructs an empty QScriptBreakpointData.
|
---|
97 | */
|
---|
98 | QScriptBreakpointData::QScriptBreakpointData()
|
---|
99 | : d_ptr(new QScriptBreakpointDataPrivate)
|
---|
100 | {
|
---|
101 | d_ptr->init(/*lineNumber=*/-1);
|
---|
102 | }
|
---|
103 |
|
---|
104 | /*!
|
---|
105 | Constructs a QScriptBreakpointData with the given \a lineNumber.
|
---|
106 | */
|
---|
107 | QScriptBreakpointData::QScriptBreakpointData(qint64 scriptId, int lineNumber)
|
---|
108 | : d_ptr(new QScriptBreakpointDataPrivate)
|
---|
109 | {
|
---|
110 | d_ptr->init(lineNumber);
|
---|
111 | d_ptr->scriptId = scriptId;
|
---|
112 | }
|
---|
113 |
|
---|
114 | /*!
|
---|
115 | Constructs a QScriptBreakpointData with the given \a lineNumber.
|
---|
116 | */
|
---|
117 | QScriptBreakpointData::QScriptBreakpointData(const QString &fileName, int lineNumber)
|
---|
118 | : d_ptr(new QScriptBreakpointDataPrivate)
|
---|
119 | {
|
---|
120 | d_ptr->init(lineNumber);
|
---|
121 | d_ptr->fileName = fileName;
|
---|
122 | }
|
---|
123 |
|
---|
124 | /*!
|
---|
125 | Constructs a QScriptBreakpointData that is a copy of \a other.
|
---|
126 | */
|
---|
127 | QScriptBreakpointData::QScriptBreakpointData(const QScriptBreakpointData &other)
|
---|
128 | : d_ptr(new QScriptBreakpointDataPrivate)
|
---|
129 | {
|
---|
130 | Q_ASSERT(other.d_ptr != 0);
|
---|
131 | *d_ptr = *other.d_ptr;
|
---|
132 | }
|
---|
133 |
|
---|
134 | /*!
|
---|
135 | Destroys this QScriptBreakpointData.
|
---|
136 | */
|
---|
137 | QScriptBreakpointData::~QScriptBreakpointData()
|
---|
138 | {
|
---|
139 | delete d_ptr;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /*!
|
---|
143 | Assigns \a other to this QScriptBreakpointData.
|
---|
144 | */
|
---|
145 | QScriptBreakpointData &QScriptBreakpointData::operator=(const QScriptBreakpointData &other)
|
---|
146 | {
|
---|
147 | Q_ASSERT(d_ptr != 0);
|
---|
148 | Q_ASSERT(other.d_ptr != 0);
|
---|
149 | *d_ptr = *other.d_ptr;
|
---|
150 | return *this;
|
---|
151 | }
|
---|
152 |
|
---|
153 | qint64 QScriptBreakpointData::scriptId() const
|
---|
154 | {
|
---|
155 | Q_D(const QScriptBreakpointData);
|
---|
156 | return d->scriptId;
|
---|
157 | }
|
---|
158 |
|
---|
159 | void QScriptBreakpointData::setScriptId(qint64 id)
|
---|
160 | {
|
---|
161 | Q_D(QScriptBreakpointData);
|
---|
162 | d->scriptId = id;
|
---|
163 | }
|
---|
164 |
|
---|
165 | QString QScriptBreakpointData::fileName() const
|
---|
166 | {
|
---|
167 | Q_D(const QScriptBreakpointData);
|
---|
168 | return d->fileName;
|
---|
169 | }
|
---|
170 |
|
---|
171 | void QScriptBreakpointData::setFileName(const QString &fileName)
|
---|
172 | {
|
---|
173 | Q_D(QScriptBreakpointData);
|
---|
174 | d->fileName = fileName;
|
---|
175 | }
|
---|
176 |
|
---|
177 | /*!
|
---|
178 | Returns the breakpoint line number.
|
---|
179 | */
|
---|
180 | int QScriptBreakpointData::lineNumber() const
|
---|
181 | {
|
---|
182 | Q_D(const QScriptBreakpointData);
|
---|
183 | return d->lineNumber;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /*!
|
---|
187 | Sets the breakpoint line number to \a lineNumber.
|
---|
188 | */
|
---|
189 | void QScriptBreakpointData::setLineNumber(int lineNumber)
|
---|
190 | {
|
---|
191 | Q_D(QScriptBreakpointData);
|
---|
192 | d->lineNumber = lineNumber;
|
---|
193 | }
|
---|
194 |
|
---|
195 | /*!
|
---|
196 | Returns true if the breakpoint is enabled, false otherwise.
|
---|
197 | */
|
---|
198 | bool QScriptBreakpointData::isEnabled() const
|
---|
199 | {
|
---|
200 | Q_D(const QScriptBreakpointData);
|
---|
201 | return d->enabled;
|
---|
202 | }
|
---|
203 |
|
---|
204 | /*!
|
---|
205 | Sets the \a enabled state of the breakpoint.
|
---|
206 | */
|
---|
207 | void QScriptBreakpointData::setEnabled(bool enabled)
|
---|
208 | {
|
---|
209 | Q_D(QScriptBreakpointData);
|
---|
210 | d->enabled = enabled;
|
---|
211 | }
|
---|
212 |
|
---|
213 | /*!
|
---|
214 | Returns true if the breakpoint is single-shot, false otherwise.
|
---|
215 | */
|
---|
216 | bool QScriptBreakpointData::isSingleShot() const
|
---|
217 | {
|
---|
218 | Q_D(const QScriptBreakpointData);
|
---|
219 | return d->singleShot;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /*!
|
---|
223 | Sets the \a singleShot state of the breakpoint.
|
---|
224 | */
|
---|
225 | void QScriptBreakpointData::setSingleShot(bool singleShot)
|
---|
226 | {
|
---|
227 | Q_D(QScriptBreakpointData);
|
---|
228 | d->singleShot = singleShot;
|
---|
229 | }
|
---|
230 |
|
---|
231 | /*!
|
---|
232 | Returns the ignore count of the breakpoint.
|
---|
233 | */
|
---|
234 | int QScriptBreakpointData::ignoreCount() const
|
---|
235 | {
|
---|
236 | Q_D(const QScriptBreakpointData);
|
---|
237 | return d->ignoreCount;
|
---|
238 | }
|
---|
239 |
|
---|
240 | /*!
|
---|
241 | Sets the ignore \a count of the breakpoint.
|
---|
242 | */
|
---|
243 | void QScriptBreakpointData::setIgnoreCount(int count)
|
---|
244 | {
|
---|
245 | Q_D(QScriptBreakpointData);
|
---|
246 | d->ignoreCount = count;
|
---|
247 | }
|
---|
248 |
|
---|
249 | /*!
|
---|
250 | If the ignore count is 0, this function increments the hit count and
|
---|
251 | returns true. Otherwise, it decrements the ignore count and returns
|
---|
252 | false.
|
---|
253 | */
|
---|
254 | bool QScriptBreakpointData::hit()
|
---|
255 | {
|
---|
256 | Q_D(QScriptBreakpointData);
|
---|
257 | if (d->ignoreCount == 0) {
|
---|
258 | ++d->hitCount;
|
---|
259 | return true;
|
---|
260 | }
|
---|
261 | --d->ignoreCount;
|
---|
262 | return false;
|
---|
263 | }
|
---|
264 |
|
---|
265 | /*!
|
---|
266 | Returns the hit count of the breakpoint (the number of times the
|
---|
267 | breakpoint has been triggered).
|
---|
268 | */
|
---|
269 | int QScriptBreakpointData::hitCount() const
|
---|
270 | {
|
---|
271 | Q_D(const QScriptBreakpointData);
|
---|
272 | return d->hitCount;
|
---|
273 | }
|
---|
274 |
|
---|
275 | /*!
|
---|
276 | Returns the condition of the breakpoint.
|
---|
277 | */
|
---|
278 | QString QScriptBreakpointData::condition() const
|
---|
279 | {
|
---|
280 | Q_D(const QScriptBreakpointData);
|
---|
281 | return d->condition;
|
---|
282 | }
|
---|
283 |
|
---|
284 | /*!
|
---|
285 | Sets the \a condition of the breakpoint.
|
---|
286 | */
|
---|
287 | void QScriptBreakpointData::setCondition(const QString &condition)
|
---|
288 | {
|
---|
289 | Q_D(QScriptBreakpointData);
|
---|
290 | d->condition = condition;
|
---|
291 | }
|
---|
292 |
|
---|
293 | /*!
|
---|
294 | Returns custom data associated with the breakpoint.
|
---|
295 | */
|
---|
296 | QVariant QScriptBreakpointData::data() const
|
---|
297 | {
|
---|
298 | Q_D(const QScriptBreakpointData);
|
---|
299 | return d->data;
|
---|
300 | }
|
---|
301 |
|
---|
302 | /*!
|
---|
303 | Sets custom \a data associated with the breakpoint.
|
---|
304 | */
|
---|
305 | void QScriptBreakpointData::setData(const QVariant &data)
|
---|
306 | {
|
---|
307 | Q_D(QScriptBreakpointData);
|
---|
308 | d->data = data;
|
---|
309 | }
|
---|
310 |
|
---|
311 | bool QScriptBreakpointData::isValid() const
|
---|
312 | {
|
---|
313 | Q_D(const QScriptBreakpointData);
|
---|
314 | return (((d->scriptId != -1) || !d->fileName.isEmpty())
|
---|
315 | && (d->lineNumber != -1));
|
---|
316 | }
|
---|
317 |
|
---|
318 | /*!
|
---|
319 | Returns true if this QScriptBreakpointData is equal to the \a other
|
---|
320 | data, otherwise returns false.
|
---|
321 | */
|
---|
322 | bool QScriptBreakpointData::operator==(const QScriptBreakpointData &other) const
|
---|
323 | {
|
---|
324 | Q_D(const QScriptBreakpointData);
|
---|
325 | const QScriptBreakpointDataPrivate *od = other.d_func();
|
---|
326 | if (d == od)
|
---|
327 | return true;
|
---|
328 | if (!d || !od)
|
---|
329 | return false;
|
---|
330 | return ((d->scriptId == od->scriptId)
|
---|
331 | && (d->fileName == od->fileName)
|
---|
332 | && (d->lineNumber == od->lineNumber)
|
---|
333 | && (d->enabled == od->enabled)
|
---|
334 | && (d->singleShot == od->singleShot)
|
---|
335 | && (d->condition == od->condition)
|
---|
336 | && (d->ignoreCount == od->ignoreCount)
|
---|
337 | && (d->data == od->data)
|
---|
338 | && (d->hitCount == od->hitCount));
|
---|
339 | }
|
---|
340 |
|
---|
341 | /*!
|
---|
342 | Returns true if this QScriptBreakpointData is not equal to the \a
|
---|
343 | other data, otherwise returns false.
|
---|
344 | */
|
---|
345 | bool QScriptBreakpointData::operator!=(const QScriptBreakpointData &other) const
|
---|
346 | {
|
---|
347 | return !(*this == other);
|
---|
348 | }
|
---|
349 |
|
---|
350 | /*!
|
---|
351 | \fn QDataStream &operator<<(QDataStream &stream, const QScriptBreakpointData &data)
|
---|
352 | \relates QScriptBreakpointData
|
---|
353 |
|
---|
354 | Writes the given \a data to the specified \a stream.
|
---|
355 | */
|
---|
356 | QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data)
|
---|
357 | {
|
---|
358 | const QScriptBreakpointDataPrivate *d = data.d_ptr;
|
---|
359 | out << d->scriptId;
|
---|
360 | out << d->fileName;
|
---|
361 | out << d->lineNumber;
|
---|
362 | out << d->enabled;
|
---|
363 | out << d->singleShot;
|
---|
364 | out << d->ignoreCount;
|
---|
365 | out << d->condition;
|
---|
366 | out << d->data;
|
---|
367 | out << d->hitCount;
|
---|
368 | return out;
|
---|
369 | }
|
---|
370 |
|
---|
371 | /*!
|
---|
372 | \fn QDataStream &operator>>(QDataStream &stream, QScriptBreakpointData &data)
|
---|
373 | \relates QScriptBreakpointData
|
---|
374 |
|
---|
375 | Reads a QScriptBreakpointData from the specified \a stream into the
|
---|
376 | given \a data.
|
---|
377 | */
|
---|
378 | QDataStream &operator>>(QDataStream &in, QScriptBreakpointData &data)
|
---|
379 | {
|
---|
380 | QScriptBreakpointDataPrivate *d = data.d_ptr;
|
---|
381 | in >> d->scriptId;
|
---|
382 | in >> d->fileName;
|
---|
383 | in >> d->lineNumber;
|
---|
384 | in >> d->enabled;
|
---|
385 | in >> d->singleShot;
|
---|
386 | in >> d->ignoreCount;
|
---|
387 | in >> d->condition;
|
---|
388 | in >> d->data;
|
---|
389 | in >> d->hitCount;
|
---|
390 | return in;
|
---|
391 | }
|
---|
392 |
|
---|
393 | QT_END_NAMESPACE
|
---|