1/****************************************************************************
2**
3** Copyright (C) 2018 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qscriptvalueproperty_p.h"
41
42#include <QtCore/qshareddata.h>
43#include <QtCore/qstring.h>
44
45QT_BEGIN_NAMESPACE
46
47class QScriptValuePropertyPrivate : public QSharedData
48{
49public:
50 QScriptValuePropertyPrivate();
51 ~QScriptValuePropertyPrivate();
52
53 QString name;
54 QScriptValue value;
55 QScriptValue::PropertyFlags flags;
56};
57
58QScriptValuePropertyPrivate::QScriptValuePropertyPrivate()
59{
60}
61
62QScriptValuePropertyPrivate::~QScriptValuePropertyPrivate()
63{
64}
65
66/*!
67 Constructs an invalid QScriptValueProperty.
68*/
69QScriptValueProperty::QScriptValueProperty()
70 : d_ptr(0)
71{
72}
73
74/*!
75 Constructs a QScriptValueProperty with the given \a name,
76 \a value and \a flags.
77*/
78QScriptValueProperty::QScriptValueProperty(const QString &name,
79 const QScriptValue &value,
80 QScriptValue::PropertyFlags flags)
81 : d_ptr(new QScriptValuePropertyPrivate)
82{
83 d_ptr->name = name;
84 d_ptr->value = value;
85 d_ptr->flags = flags;
86 d_ptr->ref.ref();
87}
88
89/*!
90 Constructs a QScriptValueProperty that is a copy of the \a other property.
91*/
92QScriptValueProperty::QScriptValueProperty(const QScriptValueProperty &other)
93 : d_ptr(other.d_ptr.data())
94{
95 if (d_ptr)
96 d_ptr->ref.ref();
97}
98
99/*!
100 Destroys this QScriptValueProperty.
101*/
102QScriptValueProperty::~QScriptValueProperty()
103{
104}
105
106/*!
107 Assigns the \a other property to this QScriptValueProperty.
108*/
109QScriptValueProperty &QScriptValueProperty::operator=(const QScriptValueProperty &other)
110{
111 d_ptr.assign(other: other.d_ptr.data());
112 return *this;
113}
114
115/*!
116 Returns the name of this QScriptValueProperty.
117*/
118QString QScriptValueProperty::name() const
119{
120 Q_D(const QScriptValueProperty);
121 if (!d)
122 return QString();
123 return d->name;
124}
125
126/*!
127 Returns the value of this QScriptValueProperty.
128*/
129QScriptValue QScriptValueProperty::value() const
130{
131 Q_D(const QScriptValueProperty);
132 if (!d)
133 return QScriptValue();
134 return d->value;
135}
136
137/*!
138 Returns the flags of this QScriptValueProperty.
139*/
140QScriptValue::PropertyFlags QScriptValueProperty::flags() const
141{
142 Q_D(const QScriptValueProperty);
143 if (!d)
144 return {};
145 return d->flags;
146}
147
148/*!
149 Returns true if this QScriptValueProperty is valid, otherwise
150 returns false.
151*/
152bool QScriptValueProperty::isValid() const
153{
154 Q_D(const QScriptValueProperty);
155 return (d != 0);
156}
157
158QT_END_NAMESPACE
159

source code of qtscript/src/scripttools/debugging/qscriptvalueproperty.cpp