void tst_QXmlItem::isNode() const { /* Check default value. */ { const QXmlItem item; QVERIFY(!item.isNode()); } /* On atomic value. */ { const QXmlItem item(QVariant(3)); QVERIFY(!item.isNode()); } // TODO on valid node index /* On a QXmlItem constructed from a null QVariant. */ { const QXmlItem item((QVariant())); QVERIFY(!item.isNode()); } /* On a QXmlItem constructed from a null QXmlNodeModelIndex. */ { const QXmlItem item((QXmlNodeModelIndex())); QVERIFY(!item.isNode()); } }
/*! Check that the functions that should be const, are. */ void tst_QXmlItem::constCorrectness() const { const QXmlItem item; item.isNull(); item.isNode(); item.isAtomicValue(); item.toAtomicValue(); item.toNodeModelIndex(); }
ItemType::Ptr AtomicValue::qtToXDMType(const QXmlItem &item) { Q_ASSERT(!item.isNull()); if(item.isNull()) return ItemType::Ptr(); if(item.isNode()) return BuiltinTypes::node; Q_ASSERT(item.isAtomicValue()); const QVariant v(item.toAtomicValue()); switch(int(v.type())) { case QVariant::Char: /* Fallthrough. */ case QVariant::String: /* Fallthrough. */ case QVariant::Url: return BuiltinTypes::xsString; case QVariant::Bool: return BuiltinTypes::xsBoolean; case QVariant::ByteArray: return BuiltinTypes::xsBase64Binary; case QVariant::Int: /* Fallthrough. */ case QVariant::LongLong: return BuiltinTypes::xsInteger; case QVariant::ULongLong: return BuiltinTypes::xsUnsignedLong; case QVariant::Date: return BuiltinTypes::xsDate; case QVariant::DateTime: /* Fallthrough. */ case QVariant::Time: return BuiltinTypes::xsDateTime; case QMetaType::Float: return BuiltinTypes::xsFloat; case QVariant::Double: return BuiltinTypes::xsDouble; default: return ItemType::Ptr(); } }