Qt 4.8
Public Types | Public Functions | Static Public Functions | Protected Functions | Private Functions | Properties | List of all members
QPatternist::QNameTest Class Reference

A name test that is of the type prefix:ncName. More...

#include <qqnametest_p.h>

Inheritance diagram for QPatternist::QNameTest:
QPatternist::AbstractNodeTest QPatternist::AnyNodeType QPatternist::ItemType QSharedData

Public Types

typedef QHash< QString, QNameTest::PtrHash
 
- 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 Functions

virtual QString displayName (const NamePool::Ptr &np) const
 
virtual bool itemMatches (const Item &item) const
 
virtual bool operator== (const ItemType &other) const
 
virtual PatternPriority patternPriority () const
 
- Public Functions inherited from QPatternist::AbstractNodeTest
 AbstractNodeTest (const ItemType::Ptr &primaryType)
 
virtual ItemType::Ptr atomizedType () 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
 
virtual QXmlNodeModelIndex::NodeKind nodeKind () const
 
- Public Functions inherited from QPatternist::ItemType
 ItemType ()
 
virtual Category itemTypeCategory () const
 
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...
 

Static Public Functions

static ItemType::Ptr create (const ItemType::Ptr &primaryType, const QXmlName qName)
 

Protected Functions

virtual InstanceOf instanceOf () const
 
- Protected Functions inherited from QPatternist::AnyNodeType
 AnyNodeType ()
 

Private Functions

 QNameTest (const ItemType::Ptr &primaryType, const QXmlName qName)
 

Properties

const QXmlName m_qName
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Variables inherited from QPatternist::AbstractNodeTest
const ItemType::Ptr m_primaryType
 

Detailed Description

A name test that is of the type prefix:ncName.

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

Definition at line 71 of file qqnametest_p.h.

Typedefs

◆ Hash

Definition at line 74 of file qqnametest_p.h.

Constructors and Destructors

◆ QNameTest()

QNameTest::QNameTest ( const ItemType::Ptr primaryType,
const QXmlName  qName 
)
private

Definition at line 54 of file qqnametest.cpp.

Referenced by create().

55  : AbstractNodeTest(primaryType)
56  , m_qName(qName)
57 {
58  Q_ASSERT(!qName.isNull());
59 }
const QXmlName m_qName
Definition: qqnametest_p.h:95
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
AbstractNodeTest(const ItemType::Ptr &primaryType)
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224

Functions

◆ create()

ItemType::Ptr QNameTest::create ( const ItemType::Ptr primaryType,
const QXmlName  qName 
)
static

Definition at line 61 of file qqnametest.cpp.

Referenced by QPatternist::yyparse().

62 {
63  Q_ASSERT(!qName.isNull());
64  Q_ASSERT(primaryType);
65 
66  return ItemType::Ptr(new QNameTest(primaryType, qName));
67 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QNameTest(const ItemType::Ptr &primaryType, const QXmlName qName)
Definition: qqnametest.cpp:54
QExplicitlySharedDataPointer< ItemType > Ptr
Definition: qitemtype_p.h:88
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224

◆ displayName()

QString QNameTest::displayName ( const NamePool::Ptr np) const
virtual
Returns
a string representing the type. Used for diagnostic purposes. For a type whose name is a QName, a lexical representation should be returned with the prefix being a conventional one. Examples of a display names are "item()" and "xs:nonPositiveInteger".

Reimplemented from QPatternist::AnyNodeType.

Definition at line 76 of file qqnametest.cpp.

77 {
78  QString displayOther(m_primaryType->displayName(np));
79 
80  return displayOther.insert(displayOther.size() - 1, np->displayName(m_qName));
81 }
QString displayName(const QXmlName qName) const
Definition: qnamepool.cpp:347
const QXmlName m_qName
Definition: qqnametest_p.h:95
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QString displayName(const NamePool::Ptr &np) const =0
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671

◆ instanceOf()

ItemType::InstanceOf QNameTest::instanceOf ( ) const
protectedvirtual

Determines what class this ItemType is an instance of. This is in needed in some implementations of operator operator==(). By default, Other is returned.

Reimplemented from QPatternist::ItemType.

Definition at line 83 of file qqnametest.cpp.

◆ itemMatches()

bool QNameTest::itemMatches ( const Item item) const
virtual
Note
This function assumes that item is a QXmlNodeModelIndex.

Reimplemented from QPatternist::AnyNodeType.

Definition at line 69 of file qqnametest.cpp.

70 {
71  Q_ASSERT(item.isNode());
72  return m_primaryType->itemMatches(item) &&
73  item.asNode().name() == m_qName;
74 }
const QXmlName m_qName
Definition: qqnametest_p.h:95
virtual bool itemMatches(const Item &item) const =0
bool isNode() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:349
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QXmlName name() const
Definition: qitem_p.h:446
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379

◆ operator==()

bool QNameTest::operator== ( const ItemType other) const
virtual

Determines whether this ItemType is equal to other.

Many types are represented by singleton instances. For example, there exists only one instance of IntegerType. This operator==() takes advantage of that and uses equalness of object addresses for determining semantic equalness. This function is as a result fast.

However, it's overridden in some cases, such as for name tests, where it's not guaranteed that there exists two types.

Returns
true if this ItemType is equal to other, otherwise false.

Reimplemented from QPatternist::ItemType.

Definition at line 88 of file qqnametest.cpp.

89 {
90  return other.instanceOf() == ClassQNameTest &&
91  static_cast<const QNameTest &>(other).m_qName == m_qName;
92 }
const QXmlName m_qName
Definition: qqnametest_p.h:95
virtual InstanceOf instanceOf() const
Definition: qitemtype.cpp:98
A name test that is of the type prefix:ncName.
Definition: qqnametest_p.h:71

◆ patternPriority()

PatternPriority QNameTest::patternPriority ( ) const
virtual

Reimplemented from QPatternist::AnyNodeType.

Definition at line 94 of file qqnametest.cpp.

95 {
96  return 0;
97 }

Properties

◆ m_qName

const QXmlName QPatternist::QNameTest::m_qName
private

Definition at line 95 of file qqnametest_p.h.

Referenced by displayName(), itemMatches(), and operator==().


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