| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 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 qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "qscriptdebuggervalueproperty_p.h"
|
|---|
| 43 | #include "qscriptdebuggervalue_p.h"
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qatomic.h>
|
|---|
| 46 | #include <QtCore/qdatastream.h>
|
|---|
| 47 | #include <QtCore/qstring.h>
|
|---|
| 48 |
|
|---|
| 49 | QT_BEGIN_NAMESPACE
|
|---|
| 50 |
|
|---|
| 51 | /*!
|
|---|
| 52 | \internal
|
|---|
| 53 | \class QScriptDebuggerValueProperty
|
|---|
| 54 | */
|
|---|
| 55 |
|
|---|
| 56 | class QScriptDebuggerValuePropertyPrivate
|
|---|
| 57 | {
|
|---|
| 58 | public:
|
|---|
| 59 | QScriptDebuggerValuePropertyPrivate();
|
|---|
| 60 | ~QScriptDebuggerValuePropertyPrivate();
|
|---|
| 61 |
|
|---|
| 62 | QString name;
|
|---|
| 63 | QScriptDebuggerValue value;
|
|---|
| 64 | QString valueAsString;
|
|---|
| 65 | QScriptValue::PropertyFlags flags;
|
|---|
| 66 |
|
|---|
| 67 | QBasicAtomicInt ref;
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 | QScriptDebuggerValuePropertyPrivate::QScriptDebuggerValuePropertyPrivate()
|
|---|
| 71 | {
|
|---|
| 72 | ref = 0;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | QScriptDebuggerValuePropertyPrivate::~QScriptDebuggerValuePropertyPrivate()
|
|---|
| 76 | {
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | /*!
|
|---|
| 80 | Constructs an invalid QScriptDebuggerValueProperty.
|
|---|
| 81 | */
|
|---|
| 82 | QScriptDebuggerValueProperty::QScriptDebuggerValueProperty()
|
|---|
| 83 | : d_ptr(0)
|
|---|
| 84 | {
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /*!
|
|---|
| 88 | Constructs a QScriptDebuggerValueProperty with the given \a name,
|
|---|
| 89 | \a value and \a flags.
|
|---|
| 90 | */
|
|---|
| 91 | QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QString &name,
|
|---|
| 92 | const QScriptDebuggerValue &value,
|
|---|
| 93 | const QString &valueAsString,
|
|---|
| 94 | QScriptValue::PropertyFlags flags)
|
|---|
| 95 | : d_ptr(new QScriptDebuggerValuePropertyPrivate)
|
|---|
| 96 | {
|
|---|
| 97 | d_ptr->name = name;
|
|---|
| 98 | d_ptr->value = value;
|
|---|
| 99 | d_ptr->valueAsString = valueAsString;
|
|---|
| 100 | d_ptr->flags = flags;
|
|---|
| 101 | d_ptr->ref.ref();
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | /*!
|
|---|
| 105 | Constructs a QScriptDebuggerValueProperty that is a copy of the \a other property.
|
|---|
| 106 | */
|
|---|
| 107 | QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebuggerValueProperty &other)
|
|---|
| 108 | : d_ptr(other.d_ptr)
|
|---|
| 109 | {
|
|---|
| 110 | if (d_ptr)
|
|---|
| 111 | d_ptr->ref.ref();
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | /*!
|
|---|
| 115 | Destroys this QScriptDebuggerValueProperty.
|
|---|
| 116 | */
|
|---|
| 117 | QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty()
|
|---|
| 118 | {
|
|---|
| 119 | if (d_ptr && !d_ptr->ref.deref()) {
|
|---|
| 120 | delete d_ptr;
|
|---|
| 121 | d_ptr = 0;
|
|---|
| 122 | }
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /*!
|
|---|
| 126 | Assigns the \a other property to this QScriptDebuggerValueProperty.
|
|---|
| 127 | */
|
|---|
| 128 | QScriptDebuggerValueProperty &QScriptDebuggerValueProperty::operator=(const QScriptDebuggerValueProperty &other)
|
|---|
| 129 | {
|
|---|
| 130 | if (d_ptr == other.d_ptr)
|
|---|
| 131 | return *this;
|
|---|
| 132 | if (d_ptr && !d_ptr->ref.deref())
|
|---|
| 133 | delete d_ptr;
|
|---|
| 134 | d_ptr = other.d_ptr;
|
|---|
| 135 | if (d_ptr)
|
|---|
| 136 | d_ptr->ref.ref();
|
|---|
| 137 | return *this;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | /*!
|
|---|
| 141 | Returns the name of this QScriptDebuggerValueProperty.
|
|---|
| 142 | */
|
|---|
| 143 | QString QScriptDebuggerValueProperty::name() const
|
|---|
| 144 | {
|
|---|
| 145 | Q_D(const QScriptDebuggerValueProperty);
|
|---|
| 146 | if (!d)
|
|---|
| 147 | return QString();
|
|---|
| 148 | return d->name;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | /*!
|
|---|
| 152 | Returns the value of this QScriptDebuggerValueProperty.
|
|---|
| 153 | */
|
|---|
| 154 | QScriptDebuggerValue QScriptDebuggerValueProperty::value() const
|
|---|
| 155 | {
|
|---|
| 156 | Q_D(const QScriptDebuggerValueProperty);
|
|---|
| 157 | if (!d)
|
|---|
| 158 | return QScriptDebuggerValue();
|
|---|
| 159 | return d->value;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | QString QScriptDebuggerValueProperty::valueAsString() const
|
|---|
| 163 | {
|
|---|
| 164 | Q_D(const QScriptDebuggerValueProperty);
|
|---|
| 165 | if (!d)
|
|---|
| 166 | return QString();
|
|---|
| 167 | return d->valueAsString;
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | /*!
|
|---|
| 171 | Returns the flags of this QScriptDebuggerValueProperty.
|
|---|
| 172 | */
|
|---|
| 173 | QScriptValue::PropertyFlags QScriptDebuggerValueProperty::flags() const
|
|---|
| 174 | {
|
|---|
| 175 | Q_D(const QScriptDebuggerValueProperty);
|
|---|
| 176 | if (!d)
|
|---|
| 177 | return 0;
|
|---|
| 178 | return d->flags;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | /*!
|
|---|
| 182 | Returns true if this QScriptDebuggerValueProperty is valid, otherwise
|
|---|
| 183 | returns false.
|
|---|
| 184 | */
|
|---|
| 185 | bool QScriptDebuggerValueProperty::isValid() const
|
|---|
| 186 | {
|
|---|
| 187 | Q_D(const QScriptDebuggerValueProperty);
|
|---|
| 188 | return (d != 0);
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | /*!
|
|---|
| 192 | \fn QDataStream &operator<<(QDataStream &stream, const QScriptDebuggerValueProperty &property)
|
|---|
| 193 | \relates QScriptDebuggerValueProperty
|
|---|
| 194 |
|
|---|
| 195 | Writes the given \a property to the specified \a stream.
|
|---|
| 196 | */
|
|---|
| 197 | QDataStream &operator<<(QDataStream &out, const QScriptDebuggerValueProperty &property)
|
|---|
| 198 | {
|
|---|
| 199 | out << property.name();
|
|---|
| 200 | out << property.value();
|
|---|
| 201 | out << property.valueAsString();
|
|---|
| 202 | out << (quint32)property.flags();
|
|---|
| 203 | return out;
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | /*!
|
|---|
| 207 | \fn QDataStream &operator>>(QDataStream &stream, QScriptDebuggerValueProperty &property)
|
|---|
| 208 | \relates QScriptDebuggerValueProperty
|
|---|
| 209 |
|
|---|
| 210 | Reads a QScriptDebuggerValueProperty from the specified \a stream into the
|
|---|
| 211 | given \a property.
|
|---|
| 212 | */
|
|---|
| 213 | QDataStream &operator>>(QDataStream &in, QScriptDebuggerValueProperty &property)
|
|---|
| 214 | {
|
|---|
| 215 | QString name;
|
|---|
| 216 | QScriptDebuggerValue value;
|
|---|
| 217 | QString valueAsString;
|
|---|
| 218 | quint32 flags;
|
|---|
| 219 | in >> name;
|
|---|
| 220 | in >> value;
|
|---|
| 221 | in >> valueAsString;
|
|---|
| 222 | in >> flags;
|
|---|
| 223 | property = QScriptDebuggerValueProperty(
|
|---|
| 224 | name, value, valueAsString, QScriptValue::PropertyFlags(flags));
|
|---|
| 225 | return in;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | QT_END_NAMESPACE
|
|---|