Fixing the autotest for other platforms, hopefully...
[qt-netbsd.git] / src / scripttools / debugging / qscriptdebuggervalueproperty.cpp
blob093bfd97241dc50d1f07cb28d6b1aeff30515680
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtSCriptTools module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
42 #include "qscriptdebuggervalueproperty_p.h"
43 #include "qscriptdebuggervalue_p.h"
45 #include <QtCore/qatomic.h>
46 #include <QtCore/qdatastream.h>
47 #include <QtCore/qstring.h>
49 QT_BEGIN_NAMESPACE
51 /*!
52 \internal
53 \class QScriptDebuggerValueProperty
56 class QScriptDebuggerValuePropertyPrivate
58 public:
59 QScriptDebuggerValuePropertyPrivate();
60 ~QScriptDebuggerValuePropertyPrivate();
62 QString name;
63 QScriptDebuggerValue value;
64 QString valueAsString;
65 QScriptValue::PropertyFlags flags;
67 QBasicAtomicInt ref;
70 QScriptDebuggerValuePropertyPrivate::QScriptDebuggerValuePropertyPrivate()
72 ref = 0;
75 QScriptDebuggerValuePropertyPrivate::~QScriptDebuggerValuePropertyPrivate()
79 /*!
80 Constructs an invalid QScriptDebuggerValueProperty.
82 QScriptDebuggerValueProperty::QScriptDebuggerValueProperty()
83 : d_ptr(0)
87 /*!
88 Constructs a QScriptDebuggerValueProperty with the given \a name,
89 \a value and \a flags.
91 QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QString &name,
92 const QScriptDebuggerValue &value,
93 const QString &valueAsString,
94 QScriptValue::PropertyFlags flags)
95 : d_ptr(new QScriptDebuggerValuePropertyPrivate)
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();
105 Constructs a QScriptDebuggerValueProperty that is a copy of the \a other property.
107 QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebuggerValueProperty &other)
108 : d_ptr(other.d_ptr)
110 if (d_ptr)
111 d_ptr->ref.ref();
115 Destroys this QScriptDebuggerValueProperty.
117 QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty()
119 if (d_ptr && !d_ptr->ref.deref()) {
120 delete d_ptr;
121 d_ptr = 0;
126 Assigns the \a other property to this QScriptDebuggerValueProperty.
128 QScriptDebuggerValueProperty &QScriptDebuggerValueProperty::operator=(const QScriptDebuggerValueProperty &other)
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;
141 Returns the name of this QScriptDebuggerValueProperty.
143 QString QScriptDebuggerValueProperty::name() const
145 Q_D(const QScriptDebuggerValueProperty);
146 if (!d)
147 return QString();
148 return d->name;
152 Returns the value of this QScriptDebuggerValueProperty.
154 QScriptDebuggerValue QScriptDebuggerValueProperty::value() const
156 Q_D(const QScriptDebuggerValueProperty);
157 if (!d)
158 return QScriptDebuggerValue();
159 return d->value;
162 QString QScriptDebuggerValueProperty::valueAsString() const
164 Q_D(const QScriptDebuggerValueProperty);
165 if (!d)
166 return QString();
167 return d->valueAsString;
171 Returns the flags of this QScriptDebuggerValueProperty.
173 QScriptValue::PropertyFlags QScriptDebuggerValueProperty::flags() const
175 Q_D(const QScriptDebuggerValueProperty);
176 if (!d)
177 return 0;
178 return d->flags;
182 Returns true if this QScriptDebuggerValueProperty is valid, otherwise
183 returns false.
185 bool QScriptDebuggerValueProperty::isValid() const
187 Q_D(const QScriptDebuggerValueProperty);
188 return (d != 0);
192 \fn QDataStream &operator<<(QDataStream &stream, const QScriptDebuggerValueProperty &property)
193 \relates QScriptDebuggerValueProperty
195 Writes the given \a property to the specified \a stream.
197 QDataStream &operator<<(QDataStream &out, const QScriptDebuggerValueProperty &property)
199 out << property.name();
200 out << property.value();
201 out << property.valueAsString();
202 out << (quint32)property.flags();
203 return out;
207 \fn QDataStream &operator>>(QDataStream &stream, QScriptDebuggerValueProperty &property)
208 \relates QScriptDebuggerValueProperty
210 Reads a QScriptDebuggerValueProperty from the specified \a stream into the
211 given \a property.
213 QDataStream &operator>>(QDataStream &in, QScriptDebuggerValueProperty &property)
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;
228 QT_END_NAMESPACE