Qt 4.8
Public Functions | Properties | List of all members
QPatternist::MultiItemType Class Reference

Represents multiple types such as document() or xs:integer. More...

#include <qmultiitemtype_p.h>

Inheritance diagram for QPatternist::MultiItemType:
QPatternist::ItemType QSharedData

Public Functions

virtual ItemType::Ptr atomizedType () const
 
virtual QString displayName (const NamePool::Ptr &np) const
 
virtual bool isAtomicType () const
 
virtual bool isNodeType () const
 
virtual bool itemMatches (const Item &item) const
 
 MultiItemType (const ItemType::List &typeList)
 
virtual ItemType::Ptr xdtSuperType () const
 
virtual bool xdtTypeMatches (const ItemType::Ptr &other) 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...
 

Properties

const ItemType::List::const_iterator m_end
 
const ItemType::List m_types
 

Additional Inherited Members

- 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

Represents multiple types such as document() or xs:integer.

In some situations two or more different types are allowed. For example, XQuery's validate expression accepts document or element nodes(but not attribute nodes, for example). MultiItemType is useful in such situations, its constructor takes a list of ItemType instances which its member functions treats as a wholeness.

For example, xdtTypeMatches() returns true if any of the represented types matches.

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

Definition at line 78 of file qmultiitemtype_p.h.

Constructors and Destructors

◆ MultiItemType()

MultiItemType::MultiItemType ( const ItemType::List typeList)

Creates a MultiItemType representing the types in typeList. typeList must contain two or more types.

Definition at line 50 of file qmultiitemtype.cpp.

50  : m_types(list),
51  m_end(list.constEnd())
52 {
53  Q_ASSERT_X(list.count() >= 2, Q_FUNC_INFO,
54  "It makes no sense to use MultiItemType for types less than two.");
55  Q_ASSERT_X(list.count(ItemType::Ptr()) == 0, Q_FUNC_INFO,
56  "No member in the list can be null.");
57 }
const ItemType::List m_types
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
const ItemType::List::const_iterator m_end
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Functions

◆ atomizedType()

ItemType::Ptr MultiItemType::atomizedType ( ) const
virtual

Determines the union type of all the represented types atomized types. For example, if the represented types are xs:integer and document(), xs:anyAtomicType is returned, because that's the super type of xs:integer and xs:untypedAtomic.

Implements QPatternist::ItemType.

Definition at line 127 of file qmultiitemtype.cpp.

128 {
130  /* Load the first one, and jump over it in the loop. */
131  ItemType::Ptr result((*it)->atomizedType());
132  ++it;
133 
134  for(; it != m_end; ++it)
135  result |= (*it)->atomizedType();
136 
137  return result;
138 }
const ItemType::List m_types
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
const ItemType::List::const_iterator m_end

◆ displayName()

QString MultiItemType::displayName ( const NamePool::Ptr np) const
virtual

The display name are the names concatenated with "|" as separator. For example, if this MultiItemType represents the types document(), xs:integer, and xs:anyAtomicType, the display name is "document() | xs:integer | xs:anyAtomicType".

Implements QPatternist::ItemType.

Definition at line 59 of file qmultiitemtype.cpp.

60 {
61  QString result;
63 
64  while(true)
65  {
66  result += (*it)->displayName(np);
67  ++it;
68 
69  if(it != m_end)
70  result += QLatin1String(" | ");
71  else
72  break;
73  }
74 
75  return result;
76 }
const ItemType::List m_types
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
const ItemType::List::const_iterator m_end

◆ isAtomicType()

bool MultiItemType::isAtomicType ( ) const
virtual
Returns
true if any of the represented types is an atomic type.

Implements QPatternist::ItemType.

Definition at line 105 of file qmultiitemtype.cpp.

106 {
108  if((*it)->isAtomicType())
109  return true;
110 
111  return false;
112 }
const ItemType::List m_types
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
const ItemType::List::const_iterator m_end

◆ isNodeType()

bool MultiItemType::isNodeType ( ) const
virtual
Returns
true if any of the represented types is a node type.

Implements QPatternist::ItemType.

Definition at line 96 of file qmultiitemtype.cpp.

97 {
99  if((*it)->isNodeType())
100  return true;
101 
102  return false;
103 }
const ItemType::List m_types
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
const ItemType::List::const_iterator m_end

◆ itemMatches()

bool MultiItemType::itemMatches ( const Item item) const
virtual

If any of the types this MultiItemType represents matches item, it is considered a match.

Returns
true if any of the housed ItemType instances matches item, otherwise false

Implements QPatternist::ItemType.

Definition at line 78 of file qmultiitemtype.cpp.

79 {
81  if((*it)->itemMatches(item))
82  return true;
83 
84  return false;
85 }
const ItemType::List m_types
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
const ItemType::List::const_iterator m_end

◆ xdtSuperType()

ItemType::Ptr MultiItemType::xdtSuperType ( ) const
virtual

Determines the union type of all the represented types super types. For example, if the represented types are xs:integer, document() and xs:string, item() is returned.

Implements QPatternist::ItemType.

Definition at line 114 of file qmultiitemtype.cpp.

115 {
117  /* Load the first one, and jump over it in the loop. */
118  ItemType::Ptr result((*it)->xdtSuperType());
119  ++it;
120 
121  for(; it != m_end; ++it)
122  result |= (*it)->xdtSuperType();
123 
124  return result;
125 }
const ItemType::List m_types
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
const ItemType::List::const_iterator m_end

◆ xdtTypeMatches()

bool MultiItemType::xdtTypeMatches ( const ItemType::Ptr other) const
virtual

If any of the types this MultiItemType represents matches other, it is considered a match.

Returns
true if any of the housed ItemType instances matches other, otherwise false

Implements QPatternist::ItemType.

Definition at line 87 of file qmultiitemtype.cpp.

88 {
90  if((*it)->xdtTypeMatches(type))
91  return true;
92 
93  return false;
94 }
const ItemType::List m_types
int type
Definition: qmetatype.cpp:239
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
const ItemType::List::const_iterator m_end

Properties

◆ m_end

const ItemType::List::const_iterator QPatternist::MultiItemType::m_end
private

◆ m_types

const ItemType::List QPatternist::MultiItemType::m_types
private

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