• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library General Public
6     License as published by the Free Software Foundation; either
7     version 2 of the License, or (at your option) any later version.
8 
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Library General Public License for more details.
13 
14     You should have received a copy of the GNU Library General Public License
15     along with this library; see the file COPYING.LIB.  If not, write to
16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     Boston, MA 02110-1301, USA.
18 */
19 
20 #include "config.h"
21 
22 #include "qscriptstring.h"
23 
24 #include "qscriptstring_p.h"
25 #include <QtCore/qhash.h>
26 
27 /*!
28   Constructs an invalid QScriptString.
29 */
QScriptString()30 QScriptString::QScriptString()
31     : d_ptr(new QScriptStringPrivate())
32 {
33 }
34 /*!
35   Constructs an QScriptString from internal representation
36   \internal
37 */
QScriptString(QScriptStringPrivate * d)38 QScriptString::QScriptString(QScriptStringPrivate* d)
39     : d_ptr(d)
40 {
41 }
42 
43 /*!
44   Constructs a new QScriptString that is a copy of \a other.
45 */
QScriptString(const QScriptString & other)46 QScriptString::QScriptString(const QScriptString& other)
47 {
48     d_ptr = other.d_ptr;
49 }
50 
51 /*!
52   Destroys this QScriptString.
53 */
~QScriptString()54 QScriptString::~QScriptString()
55 {
56 }
57 
58 /*!
59   Assigns the \a other value to this QScriptString.
60 */
operator =(const QScriptString & other)61 QScriptString& QScriptString::operator=(const QScriptString& other)
62 {
63     d_ptr = other.d_ptr;
64     return *this;
65 }
66 
67 /*!
68   Returns true if this QScriptString is valid; otherwise
69   returns false.
70 */
isValid() const71 bool QScriptString::isValid() const
72 {
73     return d_ptr->isValid();
74 }
75 
76 /*!
77   Returns true if this QScriptString is equal to \a other;
78   otherwise returns false.
79 */
operator ==(const QScriptString & other) const80 bool QScriptString::operator==(const QScriptString& other) const
81 {
82     return d_ptr == other.d_ptr || *d_ptr == *(other.d_ptr);
83 }
84 
85 /*!
86   Returns true if this QScriptString is not equal to \a other;
87   otherwise returns false.
88 */
operator !=(const QScriptString & other) const89 bool QScriptString::operator!=(const QScriptString& other) const
90 {
91     return d_ptr != other.d_ptr || *d_ptr != *(other.d_ptr);
92 }
93 
94 /*!
95   Attempts to convert this QScriptString to a QtScript array index,
96   and returns the result.
97 
98   If a conversion error occurs, *\a{ok} is set to false; otherwise
99   *\a{ok} is set to true.
100 */
toArrayIndex(bool * ok) const101 quint32 QScriptString::toArrayIndex(bool* ok) const
102 {
103     return d_ptr->toArrayIndex(ok);
104 }
105 
106 /*!
107   Returns the string that this QScriptString represents, or a
108   null string if this QScriptString is not valid.
109 
110   \sa isValid()
111 */
toString() const112 QString QScriptString::toString() const
113 {
114     return d_ptr->toString();
115 }
116 
117 /*!
118   Returns the string that this QScriptString represents, or a
119   null string if this QScriptString is not valid.
120 
121   \sa toString()
122 */
operator QString() const123 QScriptString::operator QString() const
124 {
125     return d_ptr->toString();
126 }
127 
qHash(const QScriptString & key)128 uint qHash(const QScriptString& key)
129 {
130     return qHash(QScriptStringPrivate::get(key)->id());
131 }
132