[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtSCriptTools module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 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 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 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 | }
|
---|
| 140 |
|
---|
| 141 | /*!
|
---|
| 142 | Assigns \a other to this QScriptBreakpointData.
|
---|
| 143 | */
|
---|
| 144 | QScriptBreakpointData &QScriptBreakpointData::operator=(const QScriptBreakpointData &other)
|
---|
| 145 | {
|
---|
| 146 | Q_ASSERT(d_ptr != 0);
|
---|
| 147 | Q_ASSERT(other.d_ptr != 0);
|
---|
| 148 | *d_ptr = *other.d_ptr;
|
---|
| 149 | return *this;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | qint64 QScriptBreakpointData::scriptId() const
|
---|
| 153 | {
|
---|
| 154 | Q_D(const QScriptBreakpointData);
|
---|
| 155 | return d->scriptId;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | void QScriptBreakpointData::setScriptId(qint64 id)
|
---|
| 159 | {
|
---|
| 160 | Q_D(QScriptBreakpointData);
|
---|
| 161 | d->scriptId = id;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | QString QScriptBreakpointData::fileName() const
|
---|
| 165 | {
|
---|
| 166 | Q_D(const QScriptBreakpointData);
|
---|
| 167 | return d->fileName;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | void QScriptBreakpointData::setFileName(const QString &fileName)
|
---|
| 171 | {
|
---|
| 172 | Q_D(QScriptBreakpointData);
|
---|
| 173 | d->fileName = fileName;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | /*!
|
---|
| 177 | Returns the breakpoint line number.
|
---|
| 178 | */
|
---|
| 179 | int QScriptBreakpointData::lineNumber() const
|
---|
| 180 | {
|
---|
| 181 | Q_D(const QScriptBreakpointData);
|
---|
| 182 | return d->lineNumber;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | /*!
|
---|
| 186 | Sets the breakpoint line number to \a lineNumber.
|
---|
| 187 | */
|
---|
| 188 | void QScriptBreakpointData::setLineNumber(int lineNumber)
|
---|
| 189 | {
|
---|
| 190 | Q_D(QScriptBreakpointData);
|
---|
| 191 | d->lineNumber = lineNumber;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | /*!
|
---|
| 195 | Returns true if the breakpoint is enabled, false otherwise.
|
---|
| 196 | */
|
---|
| 197 | bool QScriptBreakpointData::isEnabled() const
|
---|
| 198 | {
|
---|
| 199 | Q_D(const QScriptBreakpointData);
|
---|
| 200 | return d->enabled;
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | /*!
|
---|
| 204 | Sets the \a enabled state of the breakpoint.
|
---|
| 205 | */
|
---|
| 206 | void QScriptBreakpointData::setEnabled(bool enabled)
|
---|
| 207 | {
|
---|
| 208 | Q_D(QScriptBreakpointData);
|
---|
| 209 | d->enabled = enabled;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | /*!
|
---|
| 213 | Returns true if the breakpoint is single-shot, false otherwise.
|
---|
| 214 | */
|
---|
| 215 | bool QScriptBreakpointData::isSingleShot() const
|
---|
| 216 | {
|
---|
| 217 | Q_D(const QScriptBreakpointData);
|
---|
| 218 | return d->singleShot;
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | /*!
|
---|
| 222 | Sets the \a singleShot state of the breakpoint.
|
---|
| 223 | */
|
---|
| 224 | void QScriptBreakpointData::setSingleShot(bool singleShot)
|
---|
| 225 | {
|
---|
| 226 | Q_D(QScriptBreakpointData);
|
---|
| 227 | d->singleShot = singleShot;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | /*!
|
---|
| 231 | Returns the ignore count of the breakpoint.
|
---|
| 232 | */
|
---|
| 233 | int QScriptBreakpointData::ignoreCount() const
|
---|
| 234 | {
|
---|
| 235 | Q_D(const QScriptBreakpointData);
|
---|
| 236 | return d->ignoreCount;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | /*!
|
---|
| 240 | Sets the ignore \a count of the breakpoint.
|
---|
| 241 | */
|
---|
| 242 | void QScriptBreakpointData::setIgnoreCount(int count)
|
---|
| 243 | {
|
---|
| 244 | Q_D(QScriptBreakpointData);
|
---|
| 245 | d->ignoreCount = count;
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | /*!
|
---|
| 249 | If the ignore count is 0, this function increments the hit count and
|
---|
| 250 | returns true. Otherwise, it decrements the ignore count and returns
|
---|
| 251 | false.
|
---|
| 252 | */
|
---|
| 253 | bool QScriptBreakpointData::hit()
|
---|
| 254 | {
|
---|
| 255 | Q_D(QScriptBreakpointData);
|
---|
| 256 | if (d->ignoreCount == 0) {
|
---|
| 257 | ++d->hitCount;
|
---|
| 258 | return true;
|
---|
| 259 | }
|
---|
| 260 | --d->ignoreCount;
|
---|
| 261 | return false;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | /*!
|
---|
| 265 | Returns the hit count of the breakpoint (the number of times the
|
---|
| 266 | breakpoint has been triggered).
|
---|
| 267 | */
|
---|
| 268 | int QScriptBreakpointData::hitCount() const
|
---|
| 269 | {
|
---|
| 270 | Q_D(const QScriptBreakpointData);
|
---|
| 271 | return d->hitCount;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | /*!
|
---|
| 275 | Returns the condition of the breakpoint.
|
---|
| 276 | */
|
---|
| 277 | QString QScriptBreakpointData::condition() const
|
---|
| 278 | {
|
---|
| 279 | Q_D(const QScriptBreakpointData);
|
---|
| 280 | return d->condition;
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 | /*!
|
---|
| 284 | Sets the \a condition of the breakpoint.
|
---|
| 285 | */
|
---|
| 286 | void QScriptBreakpointData::setCondition(const QString &condition)
|
---|
| 287 | {
|
---|
| 288 | Q_D(QScriptBreakpointData);
|
---|
| 289 | d->condition = condition;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | /*!
|
---|
| 293 | Returns custom data associated with the breakpoint.
|
---|
| 294 | */
|
---|
| 295 | QVariant QScriptBreakpointData::data() const
|
---|
| 296 | {
|
---|
| 297 | Q_D(const QScriptBreakpointData);
|
---|
| 298 | return d->data;
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | /*!
|
---|
| 302 | Sets custom \a data associated with the breakpoint.
|
---|
| 303 | */
|
---|
| 304 | void QScriptBreakpointData::setData(const QVariant &data)
|
---|
| 305 | {
|
---|
| 306 | Q_D(QScriptBreakpointData);
|
---|
| 307 | d->data = data;
|
---|
| 308 | }
|
---|
| 309 |
|
---|
| 310 | bool QScriptBreakpointData::isValid() const
|
---|
| 311 | {
|
---|
| 312 | Q_D(const QScriptBreakpointData);
|
---|
| 313 | return (((d->scriptId != -1) || !d->fileName.isEmpty())
|
---|
| 314 | && (d->lineNumber != -1));
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | /*!
|
---|
| 318 | Returns true if this QScriptBreakpointData is equal to the \a other
|
---|
| 319 | data, otherwise returns false.
|
---|
| 320 | */
|
---|
| 321 | bool QScriptBreakpointData::operator==(const QScriptBreakpointData &other) const
|
---|
| 322 | {
|
---|
| 323 | Q_D(const QScriptBreakpointData);
|
---|
| 324 | const QScriptBreakpointDataPrivate *od = other.d_func();
|
---|
| 325 | if (d == od)
|
---|
| 326 | return true;
|
---|
| 327 | if (!d || !od)
|
---|
| 328 | return false;
|
---|
| 329 | return ((d->scriptId == od->scriptId)
|
---|
| 330 | && (d->fileName == od->fileName)
|
---|
| 331 | && (d->lineNumber == od->lineNumber)
|
---|
| 332 | && (d->enabled == od->enabled)
|
---|
| 333 | && (d->singleShot == od->singleShot)
|
---|
| 334 | && (d->condition == od->condition)
|
---|
| 335 | && (d->ignoreCount == od->ignoreCount)
|
---|
| 336 | && (d->data == od->data)
|
---|
| 337 | && (d->hitCount == od->hitCount));
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | /*!
|
---|
| 341 | Returns true if this QScriptBreakpointData is not equal to the \a
|
---|
| 342 | other data, otherwise returns false.
|
---|
| 343 | */
|
---|
| 344 | bool QScriptBreakpointData::operator!=(const QScriptBreakpointData &other) const
|
---|
| 345 | {
|
---|
| 346 | return !(*this == other);
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | /*!
|
---|
| 350 | \fn QDataStream &operator<<(QDataStream &stream, const QScriptBreakpointData &data)
|
---|
| 351 | \relates QScriptBreakpointData
|
---|
| 352 |
|
---|
| 353 | Writes the given \a data to the specified \a stream.
|
---|
| 354 | */
|
---|
| 355 | QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data)
|
---|
| 356 | {
|
---|
[561] | 357 | const QScriptBreakpointDataPrivate *d = data.d_ptr.data();
|
---|
[2] | 358 | out << d->scriptId;
|
---|
| 359 | out << d->fileName;
|
---|
| 360 | out << d->lineNumber;
|
---|
| 361 | out << d->enabled;
|
---|
| 362 | out << d->singleShot;
|
---|
| 363 | out << d->ignoreCount;
|
---|
| 364 | out << d->condition;
|
---|
| 365 | out << d->data;
|
---|
| 366 | out << d->hitCount;
|
---|
| 367 | return out;
|
---|
| 368 | }
|
---|
| 369 |
|
---|
| 370 | /*!
|
---|
| 371 | \fn QDataStream &operator>>(QDataStream &stream, QScriptBreakpointData &data)
|
---|
| 372 | \relates QScriptBreakpointData
|
---|
| 373 |
|
---|
| 374 | Reads a QScriptBreakpointData from the specified \a stream into the
|
---|
| 375 | given \a data.
|
---|
| 376 | */
|
---|
| 377 | QDataStream &operator>>(QDataStream &in, QScriptBreakpointData &data)
|
---|
| 378 | {
|
---|
[561] | 379 | QScriptBreakpointDataPrivate *d = data.d_ptr.data();
|
---|
[2] | 380 | in >> d->scriptId;
|
---|
| 381 | in >> d->fileName;
|
---|
| 382 | in >> d->lineNumber;
|
---|
| 383 | in >> d->enabled;
|
---|
| 384 | in >> d->singleShot;
|
---|
| 385 | in >> d->ignoreCount;
|
---|
| 386 | in >> d->condition;
|
---|
| 387 | in >> d->data;
|
---|
| 388 | in >> d->hitCount;
|
---|
| 389 | return in;
|
---|
| 390 | }
|
---|
| 391 |
|
---|
| 392 | QT_END_NAMESPACE
|
---|