QXmlItem Class

The QXmlItem class contains either an XML node or an atomic value. 更多...

頭: #include <QXmlItem>
qmake: QT += xmlpatterns
Since: Qt 4.4

該類在 Qt 4.4 引入。

注意: 此類的所有函數 可重入 .

公共類型

typedef Iterator

公共函數

QXmlItem (const QVariant & atomicValue )
QXmlItem (const QXmlNodeModelIndex & node )
QXmlItem (const QXmlItem & other )
QXmlItem ()
QXmlItem & operator= (const QXmlItem & other )
~QXmlItem ()
bool isAtomicValue () const
bool isNode () const
bool isNull () const
QVariant toAtomicValue () const
QXmlNodeModelIndex toNodeModelIndex () const

詳細描述

XQuery , all expressions evaluate to a sequence of items, where each item is either an XML node or an atomic value. The query in the following snippet evaluates to sequence of five items.

<aNode/>,
xs:base64Binary("FFFF"),
current-date(),
3e3, (: A floating point value :)
attribute {"name"} {()}
					

The five items are: An element, an atomic value (binary data encoded in base64), a date, a float, and an attribute.

QXmlItem is the class that represents these XQuery items in the Qt XML Patterns API. A non-null instance of QXmlItem is either a node or an atomic value. Calling isNode () 或 isAtomicValue () tells you which it is. Atomic values are represented elsewhere in the Qt API as instances of QVariant , and an instance of QXmlItem that represents an atomic value can be converted to a QVariant 通過調用 toAtomicValue (). A QXmlItem that wraps a node is represented elsewhere as an instance of QXmlNodeModelIndex . A node QXmlItem can be converted to a QXmlNodeModelIndex 通過調用 toNodeModelIndex ().

A default constructed QXmlItem instance is neither a node nor an atomic value. It is considered null, in which case isNull () returns true.

An instance of QXmlItem will be left dangling if the XML node model it refers to is deleted, if it is a QXmlNodeModelIndex .

成員類型文檔編製

typedef QXmlItem:: Iterator

A QAbstractXmlForwardIterator over QXmlItem .

成員函數文檔編製

QXmlItem:: QXmlItem (const QVariant & atomicValue )

Constructs an atomic value QXmlItem with atomicValue .

另請參閱 isAtomicValue ().

QXmlItem:: QXmlItem (const QXmlNodeModelIndex & node )

Constructs a node QXmlItem that is a copy of node .

另請參閱 isNode ().

QXmlItem:: QXmlItem (const QXmlItem & other )

The copy constructor constructs a copy of other .

QXmlItem:: QXmlItem ()

Constructs a null QXmlItem that is neither a node nor an atomic value. isNull () returns true for a default constructed instance.

QXmlItem &QXmlItem:: operator= (const QXmlItem & other )

賦值 other to this .

QXmlItem:: ~QXmlItem ()

析構函數。

bool QXmlItem:: isAtomicValue () const

Returns true if this item is an atomic value. Returns false if it is a node or null.

另請參閱 isNull () 和 isNode ().

bool QXmlItem:: isNode () const

Returns true if this item is a Node. Returns false if it is an atomic value or null.

另請參閱 isNull () 和 isAtomicValue ().

bool QXmlItem:: isNull () const

返迴 true,若此 QXmlItem is neither a node nor an atomic value. Default constructed instances of QXmlItem are null.

QVariant QXmlItem:: toAtomicValue () const

若此 QXmlItem represents an atomic value, it is converted to an appropriate QVariant and returned. If this QXmlItem is not an atomic value, the return value is a default constructed QVariant 。可以調用 isAtomicValue () to test whether the item is an atomic value.

另請參閱 isAtomicValue ().

QXmlNodeModelIndex QXmlItem:: toNodeModelIndex () const

若此 QXmlItem represents a node, it returns the item as a QXmlNodeModelIndex . If this QXmlItem is not a node, the return value is undefined. You can call isNode () to test whether the item is a node.

另請參閱 isNode ().