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

A name test that is of the type *:local-name. More...

#include <qlocalnametest_p.h>

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

Public Types

typedef QHash< QString, ItemType::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::LocalNameCode localName)
 

Protected Functions

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

Private Functions

 LocalNameTest (const ItemType::Ptr &primaryType, const QXmlName::LocalNameCode &ncName)
 

Properties

const QXmlName::LocalNameCode m_ncName
 

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 *:local-name.

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

Definition at line 71 of file qlocalnametest_p.h.

Typedefs

◆ Hash

Definition at line 74 of file qlocalnametest_p.h.

Constructors and Destructors

◆ LocalNameTest()

LocalNameTest::LocalNameTest ( const ItemType::Ptr primaryType,
const QXmlName::LocalNameCode ncName 
)
private

Definition at line 55 of file qlocalnametest.cpp.

Referenced by create().

56  : AbstractNodeTest(primaryType),
57  m_ncName(ncName)
58 {
59 }
AbstractNodeTest(const ItemType::Ptr &primaryType)
const QXmlName::LocalNameCode m_ncName

Functions

◆ create()

ItemType::Ptr LocalNameTest::create ( const ItemType::Ptr primaryType,
const QXmlName::LocalNameCode  localName 
)
static

Definition at line 61 of file qlocalnametest.cpp.

Referenced by QPatternist::yyparse().

62 {
63  Q_ASSERT(primaryType);
64 
65  return ItemType::Ptr(new LocalNameTest(primaryType, localName));
66 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QExplicitlySharedDataPointer< ItemType > Ptr
Definition: qitemtype_p.h:88
LocalNameTest(const ItemType::Ptr &primaryType, const QXmlName::LocalNameCode &ncName)

◆ displayName()

QString LocalNameTest::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 75 of file qlocalnametest.cpp.

76 {
77  QString displayOther(m_primaryType->displayName(np));
78 
79  return displayOther.insert(displayOther.size() - 1,
81 }
const QString & stringForLocalName(const QXmlName::LocalNameCode code) const
Definition: qnamepool_p.h:168
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QString displayName(const NamePool::Ptr &np) const =0
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671
const QXmlName::LocalNameCode m_ncName

◆ instanceOf()

ItemType::InstanceOf LocalNameTest::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 qlocalnametest.cpp.

◆ itemMatches()

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

Reimplemented from QPatternist::AnyNodeType.

Definition at line 68 of file qlocalnametest.cpp.

69 {
70  Q_ASSERT(item.isNode());
71  return m_primaryType->itemMatches(item) &&
72  item.asNode().name().localName() == m_ncName;
73 }
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
QString localName(const QXmlNamePool &query) const
Returns the local name.
Definition: qxmlname.cpp:387
QXmlName name() const
Definition: qitem_p.h:446
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379
const QXmlName::LocalNameCode m_ncName

◆ operator==()

bool LocalNameTest::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 qlocalnametest.cpp.

89 {
90  return other.instanceOf() == ClassLocalNameTest &&
91  static_cast<const LocalNameTest &>(other).m_ncName == m_ncName;
92 }
A name test that is of the type *:local-name.
virtual InstanceOf instanceOf() const
Definition: qitemtype.cpp:98
const QXmlName::LocalNameCode m_ncName

◆ patternPriority()

PatternPriority LocalNameTest::patternPriority ( ) const
virtual

Reimplemented from QPatternist::AnyNodeType.

Definition at line 94 of file qlocalnametest.cpp.

95 {
96  return -0.25;
97 }

Properties

◆ m_ncName

const QXmlName::LocalNameCode QPatternist::LocalNameTest::m_ncName
private

Definition at line 94 of file qlocalnametest_p.h.

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


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