本文整理汇总了C++中QXmlResultItems::hasError方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlResultItems::hasError方法的具体用法?C++ QXmlResultItems::hasError怎么用?C++ QXmlResultItems::hasError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlResultItems
的用法示例。
在下文中一共展示了QXmlResultItems::hasError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hasError
void tst_QXmlResultItems::hasError() const
{
/* Check default value. */
{
QXmlResultItems result;
QVERIFY(!result.hasError());
}
/* Stress it on a default constructed value. */
{
QXmlResultItems result;
QVERIFY(!result.hasError());
QVERIFY(!result.hasError());
QVERIFY(!result.hasError());
}
}
示例2: evaluate
void tst_QXmlResultItems::evaluate() const
{
QFETCH(QString, queryString);
QXmlQuery query;
query.setQuery(queryString);
QVERIFY(query.isValid());
QXmlResultItems result;
query.evaluateTo(&result);
QXmlItem item(result.next());
while(!item.isNull())
{
QVERIFY(!result.current().isNull());
QVERIFY(!result.hasError());
item = result.next();
}
/* Now, stress beyond the end. */
for(int i = 0; i < 3; ++i)
{
QVERIFY(result.current().isNull());
QVERIFY(result.next().isNull());
}
}
示例3: constCorrectness
void tst_QXmlResultItems::constCorrectness() const
{
const QXmlResultItems result;
/* These functions should be const. */
result.current();
result.hasError();
}
示例4: evalateWithQueryError
void tst_QXmlResultItems::evalateWithQueryError() const
{
/* This query is invalid. */
const QXmlQuery query;
QXmlResultItems result;
query.evaluateTo(&result);
QVERIFY(result.hasError());
QVERIFY(result.next().isNull());
}
示例5: evalateWithInstantError
/*!
What's special about this is that it's not the QAbstractXmlForwardIterator::next()
that triggers the error, it's QPatternist::Expression::evaluateSingleton() directly.
*/
void tst_QXmlResultItems::evalateWithInstantError() const
{
QXmlQuery query;
MessageSilencer silencer;
query.setMessageHandler(&silencer);
query.setQuery(QLatin1String("fn:error()"));
QXmlResultItems result;
query.evaluateTo(&result);
/* Check the values, and stress it. */
for(int i = 0; i < 3; ++i)
{
QVERIFY(result.current().isNull());
QVERIFY(result.next().isNull());
QVERIFY(result.hasError());
}
}
示例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: parseFeatures
void WfsCapabilitiesParser::parseFeatures(std::vector<Resource> &wfsFeatures)
{
qDebug() << "WfsCapabilitiesParser::parseFeatures()";
QXmlResultItems results;
UPXmlQuery& query = _parser->queryFromRoot("//wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType");
if (query->isValid()) {
query->evaluateTo( &results);
QXmlItem item(results.next());
while (!item.isNull()) {
WfsFeature feature;
parseFeature(item, feature);
wfsFeatures.push_back(feature);
item = results.next();
}
if (results.hasError()) {
ERROR0(TR(QString("XPath evaluation failed.")));
}
}
}
示例8: testXmlQuery
void TestSimulationMaker::testXmlQuery()
{
writeQuery("/simulation/model", 1);
writeQuery("/simulation//model[@type='LifeCycle']", 2);
writeQuery("/simulation/model[@name='wasp']/model[@name='egg']/parameter[@name='k']", 3);
writeQuery("/simulation/output[@name='butterflyOutput']/"
"presentation[@name='butterflyPlot']/xyvariables[@name='butterflyXY']", 4);
QXmlQuery query;
query.setQuery("<e/>, 1, 'two'");
QXmlResultItems result;
if (query.isValid()) {
query.evaluateTo(&result);
QXmlItem item(result.next());
while (!item.isNull()) {
// use item
item = result.next();
}
if (result.hasError())
/* Runtime error! */;
}
}