本文整理汇总了C++中QXmlItem类的典型用法代码示例。如果您正苦于以下问题:C++ QXmlItem类的具体用法?C++ QXmlItem怎么用?C++ QXmlItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmlItem类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: item
void tst_QXmlItem::copyConstructorFromQXmlNodeModelIndex() const
{
// TODO copy a valid model index.
/* Construct from a null QXmlNodeModelIndex. */
{
const QXmlItem item((QXmlNodeModelIndex()));
QVERIFY(item.isNull());
}
}
示例2: QVERIFY
void tst_QXmlItem::toNodeModelIndex() const
{
/* Check default value. */
{
const QXmlItem item;
QVERIFY(item.toNodeModelIndex().isNull());
}
/* On valid atomic value. */
{
const QXmlItem item(QVariant(3));
QVERIFY(item.toNodeModelIndex().isNull());
}
/* On a QXmlItem constructed from a null QVariant. */
{
const QXmlItem item((QVariant()));
QVERIFY(item.isNull());
}
/* On a QXmlItem constructed from a null QXmlNodeModelIndex. */
{
const QXmlItem item((QXmlNodeModelIndex()));
QVERIFY(item.isNull());
}
}
示例3: qtToXDMType
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();
}
}
示例4: PyBool_FromLong
static PyObject *meth_QXmlItem_isNull(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QXmlItem *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QXmlItem, &sipCpp))
{
bool sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->isNull();
Py_END_ALLOW_THREADS
return PyBool_FromLong(sipRes);
}
}
示例5: newMessage
Presets *PtzManagement::getPresets()
{
Presets *presets = NULL;
Message *msg = newMessage();
QDomElement getPresets = newElement("wsdl:GetPresets");
QDomElement profileToken = newElement("wsdl:ProfileToken","profile_CIF");
getPresets.appendChild(profileToken);
msg->appendToBody(getPresets);
MessageParser *result = sendMessage(msg);
if(result != NULL){
presets = new Presets();
QXmlQuery *query = result->query();
QXmlResultItems items;
QXmlItem item;
QString value,xml;
QDomDocument doc;
QDomNodeList itemNodeList;
QDomNode node;
query->setQuery(result->nameSpace()+"doc($inputDocument)//tptz:Preset");
query->evaluateTo(&items);
item = items.next();
while(!item.isNull()){
query->setFocus(item);
query->setQuery(result->nameSpace()+".");
query->evaluateTo(&xml);
doc.setContent(xml);
itemNodeList = doc.elementsByTagName("tptz:Preset");
for(int i=0; i<itemNodeList.size(); i++)
{
node = itemNodeList.at(i);
value = node.toElement().attribute("token");
presets->setToken(value.trimmed());
}
query->setQuery(result->nameSpace()+"./tt:Name/string()");
query->evaluateTo(&value);
presets->setName(value.trimmed());
item = items.next();
}
}
delete msg;
delete result;
return presets;
}
示例6: setFocusHelper
bool setFocusHelper(QXmlQuery *const queryInstance,
const TInputType &focusValue)
{
/* We call resourceLoader(), so we have ensured that we have a resourceLoader
* that we will share in our copy. */
queryInstance->d->resourceLoader();
QXmlQuery focusQuery(*queryInstance);
/* Now we use the same, so we own the loaded document. */
focusQuery.d->m_resourceLoader = queryInstance->d->m_resourceLoader;
/* The copy constructor doesn't allow us to copy an existing QXmlQuery and
* changing the language at the same time so we need to use private API. */
focusQuery.d->queryLanguage = QXmlQuery::XQuery10;
Q_ASSERT(focusQuery.queryLanguage() == QXmlQuery::XQuery10);
focusQuery.bindVariable(QChar::fromLatin1('u'), focusValue);
focusQuery.setQuery(QLatin1String("doc($u)"));
Q_ASSERT(focusQuery.isValid());
QXmlResultItems focusResult;
queryInstance->d->m_resourceLoader = focusQuery.d->m_resourceLoader;
focusQuery.evaluateTo(&focusResult);
const QXmlItem focusItem(focusResult.next());
if(focusItem.isNull() || focusResult.hasError())
{
/* The previous focus must be cleared in error situations.
* Otherwise the query may be left in an inconsistent state. */
queryInstance->setFocus(QXmlItem());
return false;
}
else
{
queryInstance->setFocus(focusItem);
return true;
}
}
示例7: constCorrectness
/*!
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();
}
示例8: bindVariable
/*!
Binds the variable \a name to the \a value so that $\a name can be
used from within the query to refer to the \a value.
\a name must not be \e null. \a {name}.isNull() must return false.
If \a name has already been bound by a previous bindVariable() call,
its previous binding will be overridden.
If \a {value} is null so that \a {value}.isNull() returns true, and
\a {name} already has a binding, the effect is to remove the
existing binding for \a {name}.
To bind a value of type QString or QUrl, wrap the value in a
QVariant such that QXmlItem's QVariant constructor is called.
All strings processed by the query must be valid XQuery strings,
which means they must contain only XML 1.0 characters. However,
this requirement is not checked. If the query processes an invalid
string, the behavior is undefined.
\sa QVariant::isValid(), {QtXDM}{How QVariant maps to XQuery's Data Model},
QXmlItem::isNull()
*/
void QXmlQuery::bindVariable(const QXmlName &name, const QXmlItem &value)
{
if(name.isNull())
{
qWarning("The variable name cannot be null.");
return;
}
const QPatternist::VariableLoader::Ptr vl(d->variableLoader());
const QVariant variant(QVariant::fromValue(value));
/* If the type of the variable changed(as opposed to only the value),
* we will have to recompile. */
if(vl->invalidationRequired(name, variant) || value.isNull())
d->recompileRequired();
vl->addBinding(name, variant);
}
示例9: pDebug
TestResult::List TestCase::execute(const ExecutionStage stage)
{
ErrorHandler errHandler;
ErrorHandler::installQtMessageHandler(&errHandler);
pDebug() << "TestCase::execute()";
delete m_result;
QXmlQuery query(language(), Global::namePoolAsPublic());
query.d->setExpressionFactory(s_exprFact);
query.setInitialTemplateName(initialTemplateName());
QXmlQuery openDoc(query.namePool());
if(contextItemSource().isValid())
{
openDoc.setQuery(QString::fromLatin1("doc('") + contextItemSource().toString() + QLatin1String("')"));
Q_ASSERT(openDoc.isValid());
QXmlResultItems result;
openDoc.evaluateTo(&result);
const QXmlItem item(result.next());
Q_ASSERT(!item.isNull());
query.setFocus(item);
}
TestResult::List retval;
const Scenario scen(scenario());
TestResult::Status resultStatus = TestResult::Unknown;
bool ok = false;
const QString queryString(sourceCode(ok));
if(!ok)
{
/* Loading the query file failed, or similar. */
resultStatus = TestResult::Fail;
m_result = new TestResult(name(), resultStatus, s_exprFact->astTree(),
errHandler.messages(), QPatternist::Item::List(), QString());
retval.append(m_result);
ErrorHandler::installQtMessageHandler(0);
changed(this);
return retval;
}
query.setMessageHandler(&errHandler);
QXmlNamePool namePool(query.namePool());
/* Bind variables. */
QPatternist::ExternalVariableLoader::Ptr loader(externalVariableLoader());
if(loader)
{
Q_ASSERT(loader);
const ExternalSourceLoader::VariableMap vMap(static_cast<const ExternalSourceLoader *>(loader.data())->variableMap());
const QStringList variables(vMap.keys());
for(int i = 0; i < variables.count(); ++i)
{
const QXmlName name(namePool, variables.at(i));
const QXmlItem val(QPatternist::Item::toPublic(loader->evaluateSingleton(name, QPatternist::DynamicContext::Ptr())));
query.bindVariable(name, val);
}
}
/* We pass in the testCasePath(), such that the base URI is correct fort
* XSL-T stylesheets. */
query.setQuery(queryString, testCasePath());
if(!query.isValid())
{
pDebug() << "Got compilation exception.";
resultStatus = TestBaseLine::scanErrors(errHandler.messages(), baseLines());
Q_ASSERT(resultStatus != TestResult::Unknown);
m_result = new TestResult(name(), resultStatus, s_exprFact->astTree(),
errHandler.messages(), QPatternist::Item::List(), QString());
retval.append(m_result);
ErrorHandler::installQtMessageHandler(0);
changed(this);
return retval;
}
if(stage == CompileOnly)
{
m_result = new TestResult(name(), TestResult::Fail, s_exprFact->astTree(),
errHandler.messages(), QPatternist::Item::List(), QString());
retval.append(m_result);
return retval;
}
Q_ASSERT(stage == CompileAndRun);
if(scen == ParseError) /* We're supposed to have received an error
at this point. */
{
m_result = new TestResult(name(), TestResult::Fail, s_exprFact->astTree(),
errHandler.messages(), QPatternist::Item::List(), QString());
//.........这里部分代码省略.........
示例10: spriteFile
//Load the asset from the specified file
bool GMAsset_Sprite::Load(const QFileInfo &file)
{
this->GMAsset::Load(file);
QFile spriteFile(file.absoluteFilePath());
if (!spriteFile.exists()) return false; //File does not exist
if (!spriteFile.open(QIODevice::ReadOnly | QIODevice::Text))
return false; //Failed to open the file
QXmlQuery query;
QXmlResultItems result;
QXmlItem item;
query.setFocus(&spriteFile);
//Type of sprite
query.setQuery("sprite/type/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetType(item.toAtomicValue().toInt());
}
QPoint origin;
//X Origin
query.setQuery("sprite/xorig/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
origin.setX(item.toAtomicValue().toInt());
}
//Y Origin
query.setQuery("sprite/yorigin/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
origin.setY(item.toAtomicValue().toInt());
}
SetOrigin(origin);
//Collision Kind
query.setQuery("sprite/colkind/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetCollisionKind((CollisionKind)item.toAtomicValue().toInt());
}
//Color Tolerance
query.setQuery("sprite/coltolerance/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetColTolerance(item.toAtomicValue().toInt());
}
//Seprate Masks?
query.setQuery("sprite/sepmasks/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetSepMasks(item.toAtomicValue().toBool());
}
//Bounding Box Mode
query.setQuery("sprite/bboxmode/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetBboxMode((BoundingBoxMode)item.toAtomicValue().toInt());
}
QRect bbox; //Bounding box
//Bounding Box Left
query.setQuery("sprite/bbox_left/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
bbox.setLeft(item.toAtomicValue().toInt());
}
//Bounding Box Right
query.setQuery("sprite/bbox_right/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
bbox.setRight(item.toAtomicValue().toInt());
}
//Bounding Box Top
query.setQuery("sprite/bbox_top/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
bbox.setTop(item.toAtomicValue().toInt());
}
//Bounding Box Bottom
query.setQuery("sprite/bbox_bottom/string()");
query.evaluateTo(&result);
item = result.next();
//.........这里部分代码省略.........