[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 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.
|
---|
| 23 | **
|
---|
[561] | 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.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | //
|
---|
| 43 | // W A R N I N G
|
---|
| 44 | // -------------
|
---|
| 45 | //
|
---|
| 46 | // This file is not part of the Qt API. It exists purely as an
|
---|
| 47 | // implementation detail. This header file may change from version to
|
---|
| 48 | // version without notice, or even be removed.
|
---|
| 49 | //
|
---|
| 50 | // We mean it.
|
---|
| 51 |
|
---|
| 52 | #ifndef Patternist_Item_H
|
---|
| 53 | #define Patternist_Item_H
|
---|
| 54 |
|
---|
| 55 | #include <QtXmlPatterns/private/qcppcastinghelper_p.h>
|
---|
| 56 | #include <QtXmlPatterns/private/qitemtype_p.h>
|
---|
| 57 | #include <QtXmlPatterns/private/qsingletoniterator_p.h>
|
---|
| 58 | #include <QtXmlPatterns/QAbstractXmlNodeModel>
|
---|
| 59 |
|
---|
| 60 | #include <QUrl>
|
---|
| 61 | #include <QVariant>
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
| 64 | * @file
|
---|
| 65 | * @short Due to strong interdependencies, this file contains the definitions for
|
---|
| 66 | * the classes Item, QXmlNodeModelIndex, QAbstractXmlNodeModel and AtomicValue. The implementations are
|
---|
| 67 | * in their respective source files.
|
---|
| 68 | */
|
---|
| 69 |
|
---|
| 70 | /**
|
---|
| 71 | * @class QSharedData
|
---|
| 72 | * @short Qt's base class for reference counting.
|
---|
| 73 | */
|
---|
| 74 |
|
---|
| 75 | QT_BEGIN_HEADER
|
---|
| 76 |
|
---|
| 77 | QT_BEGIN_NAMESPACE
|
---|
| 78 |
|
---|
| 79 | template<typename T> class QList;
|
---|
| 80 | template<typename T> class QVector;
|
---|
| 81 | template<typename T> class QAbstractXmlForwardIterator;
|
---|
| 82 |
|
---|
| 83 | class QSourceLocation;
|
---|
| 84 | class QAbstractXmlReceiver;
|
---|
| 85 |
|
---|
| 86 | namespace QPatternist
|
---|
| 87 | {
|
---|
| 88 | class DynamicContext;
|
---|
| 89 | class Item;
|
---|
| 90 | class ItemType;
|
---|
| 91 | class QObjectNodeModel;
|
---|
| 92 | template<typename T> class EmptyIterator;
|
---|
| 93 | template<typename T, typename ListType> class ListIterator;
|
---|
| 94 |
|
---|
| 95 | /**
|
---|
| 96 | * @short Base class for all classes representing atomic values.
|
---|
| 97 | *
|
---|
| 98 | * Instantiating AtomicValues sub classes from a value of somekind,
|
---|
| 99 | * for a certain type is done in three different ways:
|
---|
| 100 | *
|
---|
| 101 | * - The static factory fromLexical which available in most classes. This
|
---|
| 102 | * function attempts to create a value from a QString that is considered
|
---|
| 103 | * a lexical representation of the value. Thus, this function performs validation, takes
|
---|
| 104 | * care of whitespace facets, and everything else related to instantiating a value from
|
---|
| 105 | * a lexical representation.
|
---|
| 106 | * - The static factory function fromValue. This function exists for
|
---|
| 107 | * values where a C++ type exists which corresponds to the type's value space.
|
---|
| 108 | * - By using instances available in CommonValues. This is the preferred method
|
---|
| 109 | * since it uses existing singleton instances and thus saves memory. CommonValues
|
---|
| 110 | * should be used whenever possible, it can be thought as a collection of constant values.
|
---|
| 111 | *
|
---|
| 112 | * For types that does not distinguish the value space and lexical space, such as <tt>xs:string</tt>,
|
---|
| 113 | * only the fromValue() function exist, and fromLexical() is omitted.
|
---|
| 114 | *
|
---|
| 115 | * @ingroup Patternist_xdm
|
---|
[561] | 116 | * @author Frans Englich <[email protected]>
|
---|
[2] | 117 | */
|
---|
| 118 | class AtomicValue : public QSharedData
|
---|
| 119 | , public CppCastingHelper<AtomicValue>
|
---|
| 120 | {
|
---|
| 121 | public:
|
---|
| 122 | virtual ~AtomicValue();
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | * A smart pointer wrapping AtomicValue instances.
|
---|
| 126 | */
|
---|
| 127 | typedef QExplicitlySharedDataPointer<AtomicValue> Ptr;
|
---|
| 128 |
|
---|
| 129 | /**
|
---|
[561] | 130 | * A list if smart pointers wrapping AtomicValue instances.
|
---|
| 131 | */
|
---|
| 132 | typedef QList<AtomicValue::Ptr> List;
|
---|
| 133 |
|
---|
| 134 | /**
|
---|
[2] | 135 | * Determines whether this atomic value has an error. This is used
|
---|
| 136 | * for implementing casting.
|
---|
| 137 | *
|
---|
| 138 | * @returns always @c false
|
---|
| 139 | */
|
---|
| 140 | virtual bool hasError() const;
|
---|
| 141 |
|
---|
| 142 | /**
|
---|
| 143 | * Always fails by issuing the type error ReportContext::FORG0006. Sub-classes
|
---|
| 144 | * whose represented type do allow EBV to be extracted from, must thus
|
---|
| 145 | * re-implement this function.
|
---|
| 146 | */
|
---|
| 147 | virtual bool evaluateEBV(const QExplicitlySharedDataPointer<DynamicContext> &context) const;
|
---|
| 148 |
|
---|
| 149 | virtual QString stringValue() const = 0;
|
---|
| 150 | virtual ItemType::Ptr type() const = 0;
|
---|
| 151 |
|
---|
| 152 | /**
|
---|
| 153 | * Converts @p value to a QVariant.
|
---|
| 154 | */
|
---|
| 155 | static QVariant toQt(const AtomicValue *const value);
|
---|
| |
---|