Qt 4.8
qsourcelocation.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdebug_p.h"
43 
44 #include "qsourcelocation.h"
45 
46 
48 
73 QSourceLocation::QSourceLocation() : m_line(-1), m_column(-1)
74 {
75 }
76 
81  : m_line(other.m_line), m_column(other.m_column), m_uri(other.m_uri)
82 {
83 }
84 
89  : m_line(l), m_column(c), m_uri(u)
90 {
91 }
92 
97 {
98 }
99 
110 {
111  return m_line == other.m_line
112  && m_column == other.m_column
113  && m_uri == other.m_uri;
114 }
115 
121 {
122  return operator==(other);
123 }
124 
129 {
130  if(this != &other)
131  {
132  m_line = other.m_line;
133  m_column = other.m_column;
134  m_uri = other.m_uri;
135  }
136 
137  return *this;
138 }
139 
146 {
147  return m_column;
148 }
149 
155 {
156  Q_ASSERT_X(newColumn != 0, Q_FUNC_INFO,
157  "0 is an invalid column number. The first column number is 1.");
158  m_column = newColumn;
159 }
160 
166 {
167  return m_line;
168 }
169 
175 {
176  m_line = newLine;
177 }
178 
185 {
186  return m_uri;
187 }
188 
192 void QSourceLocation::setUri(const QUrl &newUri)
193 {
194  m_uri = newUri;
195 }
196 
206 #ifndef QT_NO_DEBUG_STREAM
207 QDebug operator<<(QDebug debug, const QSourceLocation &sourceLocation)
208 {
209  debug << "QSourceLocation("
210  << sourceLocation.uri()
211  << ", line:"
212  << sourceLocation.line()
213  << ", column:"
214  << sourceLocation.column()
215  << ')';
216  return debug;
217 }
218 #endif
219 
228 {
229  return !m_uri.isValid();
230 }
231 
240 {
241  /* Not the world's best hash function exactly. */
242  return qHash(location.uri().toString()) + location.line() + location.column();
243 }
244 
246 
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
qint64 line() const
Returns the current line number.
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QDebug operator<<(QDebug debug, const QSourceLocation &sourceLocation)
Prints sourceLocation to the debug stream debug.
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
bool operator==(const QSourceLocation &other) const
Returns true if this QSourceLocation is identical to other.
~QSourceLocation()
Destructor.
void setUri(const QUrl &newUri)
Sets the URI to newUri.
void setLine(qint64 newLine)
Sets the line number to newLine.
quint16 u
Contains macros for debugging.
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
QSourceLocation & operator=(const QSourceLocation &other)
Assigns this QSourceLocation instance to other.
uint qHash(const QSourceLocation &location)
QUrl uri() const
Returns the resource that this QSourceLocation refers to.
bool isNull() const
Returns true if this QSourceLocation doesn&#39;t identify anything.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setColumn(qint64 newColumn)
Sets the column number to newColumn.
QSourceLocation()
Construct a QSourceLocation that doesn&#39;t identify anything at all.
The QSourceLocation class identifies a location in a resource by URI, line, and column.
unsigned int uint
Definition: qglobal.h:996
__int64 qint64
Definition: qglobal.h:942
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
qint64 column() const
Returns the current column number.
QFactoryLoader * l
bool operator!=(const QSourceLocation &other) const
Returns the opposite of applying operator==() for this QXmlName and other.
#define Q_FUNC_INFO
Definition: qglobal.h:1871