Qt 4.8
qxmlname.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 /*
43  * QXmlName is conceptually identical to QPatternist::QName. The
44  * difference is that the latter is elegant, powerful and fast.
45  *
46  * However, it is too powerful and too open and not at all designed
47  * for being public. QXmlName, in contrast, is only a public marker,
48  * that for instance uses a qint64 instead of qint32, such that we in
49  * the future can use that, if needed.
50  */
51 
52 #include "qnamepool_p.h"
53 #include "qxmlname.h"
54 #include "qxmlnamepool.h"
55 #include "qxpathhelper_p.h"
56 #include "private/qxmlutils_p.h"
57 
59 
189  const QString &localName,
190  const QString &namespaceURI,
191  const QString &prefix)
192 {
193  Q_ASSERT_X(prefix.isEmpty() || QXmlUtils::isNCName(prefix), Q_FUNC_INFO,
194  "The prefix is invalid, maybe the arguments were mixed up?");
196  "The local name is invalid, maybe the arguments were mixed up?");
197 
198  m_qNameCode = namePool.d->allocateQName(namespaceURI, localName, prefix).code();
199 }
200 
224 bool QXmlName::isNull() const
225 {
226  return m_qNameCode == InvalidCode;
227 }
228 
240 {
241 }
242 
297 bool QXmlName::operator==(const QXmlName &other) const
298 {
300 }
301 
315 bool QXmlName::operator!=(const QXmlName &other) const
316 {
317  return !operator==(other);
318 }
319 
341 {
343 }
344 
355 {
356  if(isNull())
357  return QString();
358  else
359  return namePool.d->stringForNamespace(namespaceURI());
360 }
361 
370 QString QXmlName::prefix(const QXmlNamePool &namePool) const
371 {
372  if(isNull())
373  return QString();
374  else
375  return namePool.d->stringForPrefix(prefix());
376 }
377 
388 {
389  if(isNull())
390  return QString();
391  else
392  return namePool.d->stringForLocalName(localName());
393 }
394 
424 {
425  return namePool.d->toClarkName(*this);
426 }
427 
432 {
433  m_qNameCode = other.m_qNameCode;
434  return *this;
435 }
436 
445 bool QXmlName::isNCName(const QString &candidate)
446 {
447  return QXmlUtils::isNCName(candidate);
448 }
449 
482  const QXmlNamePool &namePool)
483 {
484  return namePool.d->fromClarkName(clarkName);
485 }
486 
532 
const QString & stringForLocalName(const QXmlName::LocalNameCode code) const
Definition: qnamepool_p.h:168
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
LocalNameCode localName() const
Definition: qnamepool_p.h:483
PrefixCode prefix() const
Definition: qnamepool_p.h:488
The QString class provides a Unicode character string.
Definition: qstring.h:83
QXmlName fromClarkName(const QString &clarkName)
Definition: qnamepool.cpp:389
bool operator!=(const QXmlName &other) const
Returns true if this QXmlName is not equal to other; otherwise false.
Definition: qxmlname.cpp:315
The QXmlNamePool class is a table of shared strings referenced by instances of QXmlName.
Definition: qxmlnamepool.h:69
QString namespaceUri(const QXmlNamePool &query) const
Returns the namespace URI.
Definition: qxmlname.cpp:354
const QString & stringForPrefix(const QXmlName::PrefixCode code) const
Definition: qnamepool_p.h:174
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool operator==(const QXmlName &other) const
Returns true if this QXmlName is equal to other; otherwise false.
Definition: qxmlname.cpp:297
const char * name
QXmlName & operator=(const QXmlName &other)
Assigns other to this and returns this.
Definition: qxmlname.cpp:431
unsigned int uint
Definition: qglobal.h:996
QString toClarkName(const QXmlNamePool &query) const
Returns this QXmlName formatted as a Clark Name.
Definition: qxmlname.cpp:423
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QXmlName()
Constructs an uninitialized QXmlName.
Definition: qxmlname.cpp:239
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
QString toClarkName(const QXmlName &name) const
Definition: qnamepool.cpp:367
static bool isNCName(const QString &candidate)
Returns true if candidate is an NCName.
Definition: qxmlname.cpp:445
static QXmlName fromClarkName(const QString &clarkName, const QXmlNamePool &namePool)
Converts clarkName into a QXmlName, inserts into namePool, and returns it.
Definition: qxmlname.cpp:481
const QString & stringForNamespace(const QXmlName::NamespaceCode code) const
Definition: qnamepool_p.h:180
QXmlName allocateQName(const QString &uri, const QString &localName, const QString &prefix=QString())
Definition: qnamepool.cpp:251
Code code() const
Returns the internal code that contains the id codes for the local name, prefix and namespace URI...
Definition: qnamepool_p.h:528
Code m_qNameCode
Definition: qxmlname.h:131
static bool isNCName(const QStringRef &ncName)
Determines whether c is a valid instance of production [4]NCName in the XML 1.0 Namespaces specificat...
Definition: qxmlutils.cpp:377
friend Q_XMLPATTERNS_EXPORT uint qHash(const QXmlName &)
Definition: qxmlname.cpp:340
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224
#define Q_FUNC_INFO
Definition: qglobal.h:1871