Qt 4.8
Public Functions | Protected Functions | Friends | List of all members
QPatternist::BuiltinNodeType< kind > Class Template Reference

Instances of this class represents types that are sub-classes of node(), such as processing-instruction(). More...

#include <qbuiltinnodetype_p.h>

Inheritance diagram for QPatternist::BuiltinNodeType< kind >:
QPatternist::AnyNodeType QPatternist::ItemType QSharedData

Public Functions

virtual ItemType::Ptr atomizedType () const
 
virtual QString displayName (const NamePool::Ptr &np) const
 
virtual bool itemMatches (const Item &item) const
 
QXmlNodeModelIndex::NodeKind nodeKind () const
 
PatternPriority patternPriority () const
 
virtual ItemType::Ptr xdtSuperType () const
 
virtual bool xdtTypeMatches (const ItemType::Ptr &other) const
 Returns true if other matches this type. That is, if other is equal to this type or a subtype of this type. More...
 
- Public Functions inherited from QPatternist::AnyNodeType
virtual bool isAtomicType () const
 
virtual bool isNodeType () const
 
- Public Functions inherited from QPatternist::ItemType
virtual InstanceOf instanceOf () const
 
 ItemType ()
 
virtual Category itemTypeCategory () const
 
bool operator!= (const ItemType &other) const
 
virtual bool operator== (const ItemType &other) const
 
virtual const ItemTypeoperator| (const ItemType &other) const
 
virtual ~ItemType ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Protected Functions

 BuiltinNodeType ()
 
- Protected Functions inherited from QPatternist::AnyNodeType
 AnyNodeType ()
 

Friends

class BuiltinTypes
 

Additional Inherited Members

- Public Types inherited from QPatternist::AnyNodeType
typedef QExplicitlySharedDataPointer< AnyNodeTypePtr
 
- Public Types inherited from QPatternist::ItemType
enum  Category { NodeNameTest = 1, Other = 2 }
 
enum  InstanceOf { ClassLocalNameTest, ClassNamespaceNameTest, ClassQNameTest, ClassOther }
 
typedef QList< ItemType::PtrList
 
typedef QExplicitlySharedDataPointer< ItemTypePtr
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

template<const QXmlNodeModelIndex::NodeKind kind>
class QPatternist::BuiltinNodeType< kind >

Instances of this class represents types that are sub-classes of node(), such as processing-instruction().

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 74 of file qbuiltinnodetype_p.h.

Constructors and Destructors

◆ BuiltinNodeType()

template<const QXmlNodeModelIndex::NodeKind kind>
QPatternist::BuiltinNodeType< kind >::BuiltinNodeType ( )
protected

This constructor does nothing, but exists in order to make it impossible to instantiate this class from anywhere but from BuiltinTypes.

Definition at line 49 of file qbuiltinnodetype.cpp.

50 {
51 }

Functions

◆ atomizedType()

template<const QXmlNodeModelIndex::NodeKind kind>
ItemType::Ptr QPatternist::BuiltinNodeType< kind >::atomizedType ( ) const
virtual
See also
XQuery 1.0 and XPath 2.0 Data Model, G.15 dm:typed-value Accessor

Reimplemented from QPatternist::AnyNodeType.

Definition at line 74 of file qbuiltinnodetype.cpp.

75 {
76  switch(kind)
77  {
78  /* Fallthrough all these. */
85  /* Fallthrough. */
88  default:
89  {
90  Q_ASSERT_X(false, Q_FUNC_INFO,
91  "Encountered invalid XPath Data Model node type.");
93  }
94  }
95 }
static const AtomicType::Ptr xsString
static const AtomicType::Ptr xsUntypedAtomic
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ displayName()

template<const QXmlNodeModelIndex::NodeKind kind>
QString QPatternist::BuiltinNodeType< kind >::displayName ( const NamePool::Ptr np) const
virtual
Returns
for example "text()", depending on what the constructor was passed

Reimplemented from QPatternist::AnyNodeType.

Definition at line 98 of file qbuiltinnodetype.cpp.

99 {
100  switch(kind)
101  {
103  return QLatin1String("element()");
105  return QLatin1String("document()");
107  return QLatin1String("attribute()");
109  return QLatin1String("text()");
111  return QLatin1String("processing-instruction()");
113  return QLatin1String("comment()");
114  default:
115  {
116  Q_ASSERT_X(false, Q_FUNC_INFO,
117  "Encountered invalid XPath Data Model node type.");
118  return QString();
119  }
120  }
121 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ itemMatches()

template<const QXmlNodeModelIndex::NodeKind kind>
bool QPatternist::BuiltinNodeType< kind >::itemMatches ( const Item item) const
virtual
Parameters
itemthe item that is to be matched. This is guaranteed by the caller to never be null.

Reimplemented from QPatternist::AnyNodeType.

Definition at line 65 of file qbuiltinnodetype.cpp.

66 {
67  Q_ASSERT(item);
68 
69  return item.isNode() &&
70  item.asNode().kind() == kind;
71 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ nodeKind()

template<const QXmlNodeModelIndex::NodeKind kind>
QXmlNodeModelIndex::NodeKind QPatternist::BuiltinNodeType< kind >::nodeKind ( ) const
virtual
Returns
the node kind this node ItemType tests for. If it matches any node, zero is returned.

Reimplemented from QPatternist::AnyNodeType.

Definition at line 130 of file qbuiltinnodetype.cpp.

131 {
132  return kind;
133 }

◆ patternPriority()

template<const QXmlNodeModelIndex::NodeKind kind>
PatternPriority QPatternist::BuiltinNodeType< kind >::patternPriority ( ) const
virtual

Reimplemented from QPatternist::AnyNodeType.

Definition at line 136 of file qbuiltinnodetype.cpp.

137 {
138  /* See XSL Transformations (XSLT) Version 2.0, 6.4 Conflict Resolution for
139  * Template Rules */
140  switch(kind)
141  {
143  /* Fallthrough. */
145  /* Fallthrough. */
147  /* "If the pattern is any other NodeTest, optionally preceded by a
148  * PatternAxis, then the priority is 0.5."
149  * Fallthrough. */
151  /* Fallthrough. */
153  /* Fallthrough. */
155  /* "If the pattern has the form /, then the priority is -0.5.". */
156  return -0.5;
157  default:
158  {
159  Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown node type");
160  return 0;
161  }
162  }
163 
164 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ xdtSuperType()

template<const QXmlNodeModelIndex::NodeKind kind>
ItemType::Ptr QPatternist::BuiltinNodeType< kind >::xdtSuperType ( ) const
virtual

Determines the type's parent type in the XPath Data Model hierarchy. For example, for the type xs:anyAtomicType, the super type in the XPath Data Model is item(), not xs:anySimpleType. SchemaType::xdtSuperType navigates the schema hierarchy.

See also
SchemaType::wxsSuperType()
Returns
the type's super type.

Reimplemented from QPatternist::AnyNodeType.

Definition at line 124 of file qbuiltinnodetype.cpp.

125 {
126  return BuiltinTypes::node;
127 }
static const AnyNodeType::Ptr node

◆ xdtTypeMatches()

template<const QXmlNodeModelIndex::NodeKind kind>
bool QPatternist::BuiltinNodeType< kind >::xdtTypeMatches ( const ItemType::Ptr other) const
virtual

Returns true if other matches this type. That is, if other is equal to this type or a subtype of this type.

For instance this statements evaluates to true:

but this evaluates to false:

Parameters
otherthe other ItemType that is to be matched. This is guaranteed by the caller to never be null.

Reimplemented from QPatternist::AnyNodeType.

Definition at line 54 of file qbuiltinnodetype.cpp.

55 {
56  if(!other->isNodeType())
57  return false;
58 
59  return *static_cast<const BuiltinNodeType *>(other.data()) == *this
60  ? true
61  : xdtTypeMatches(other->xdtSuperType());
62 }
virtual bool xdtTypeMatches(const ItemType::Ptr &other) const
Returns true if other matches this type. That is, if other is equal to this type or a subtype of this...

Friends and Related Functions

◆ BuiltinTypes

template<const QXmlNodeModelIndex::NodeKind kind>
friend class BuiltinTypes
friend

Definition at line 93 of file qbuiltinnodetype_p.h.


The documentation for this class was generated from the following files: