本文整理汇总了C++中QXmlResultItems::next方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlResultItems::next方法的具体用法?C++ QXmlResultItems::next怎么用?C++ QXmlResultItems::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlResultItems
的用法示例。
在下文中一共展示了QXmlResultItems::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allMetaObjects
//! [9]
QObjectXmlModel::AllMetaObjects QObjectXmlModel::allMetaObjects() const
{
QXmlQuery query(namePool());
query.bindVariable("root", root());
query.setQuery("declare variable $root external;"
"$root/descendant-or-self::QObject");
Q_ASSERT(query.isValid());
QXmlResultItems result;
query.evaluateTo(&result);
QXmlItem i(result.next());
AllMetaObjects objects;
while (!i.isNull()) {
const QMetaObject *moo = asQObject(i.toNodeModelIndex())->metaObject();
while (moo) {
if (!objects.contains(moo))
objects.append(moo);
moo = moo->superClass();
}
i = result.next();
}
Q_ASSERT(!objects.contains(0));
return objects;
}
示例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: render
void RssFeedNode::render(Grantlee::OutputStream* stream, Grantlee::Context* c)
{
QNetworkAccessManager *mgr = new QNetworkAccessManager(this);
QUrl url(Grantlee::getSafeString(m_url.resolve(c)));
QNetworkReply *reply = mgr->get(QNetworkRequest(url));
QEventLoop eLoop;
connect( mgr, SIGNAL( finished( QNetworkReply * ) ), &eLoop, SLOT( quit() ) );
eLoop.exec( QEventLoop::ExcludeUserInputEvents );
c->push();
foreach(Grantlee::Node *n, m_childNodes) {
if (!n->inherits(XmlNamespaceNode::staticMetaObject.className()))
continue;
Grantlee::OutputStream _dummy;
n->render(&_dummy, c);
}
QXmlQuery query;
QByteArray ba = reply->readAll();
QBuffer buffer;
buffer.setData(ba);
buffer.open(QIODevice::ReadOnly);
query.bindVariable("inputDocument", &buffer);
QString ns;
QHash<QString, QVariant> h = c->lookup("_ns").toHash();
QHash<QString, QVariant>::const_iterator it = h.constBegin();
const QHash<QString, QVariant>::const_iterator end = h.constEnd();
for ( ; it != end; ++it ) {
if (it.key().isEmpty()) {
ns += QLatin1Literal( "declare default element namespace " ) + QLatin1Literal( " \"" ) + it.value().toString() + QLatin1Literal( "\";\n" );
} else {
ns += QLatin1Literal( "declare namespace " ) + it.key() + QLatin1Literal( " = \"" ) + it.value().toString() + QLatin1Literal( "\";\n" );
}
}
query.setQuery(ns + "doc($inputDocument)" + Grantlee::getSafeString(m_query.resolve(c)).get());
QXmlResultItems result;
query.evaluateTo(&result);
QXmlItem item(result.next());
int count = 0;
while (!item.isNull()) {
if (count++ > 20)
break;
query.setFocus(item);
c->push();
foreach(Grantlee::Node *n, m_childNodes) {
if (n->inherits(XmlNamespaceNode::staticMetaObject.className()))
continue;
c->insert("_q", QVariant::fromValue(query));
n->render(stream, c);
}
c->pop();
item = result.next();
}
c->pop();
}
示例4: next
void tst_QXmlResultItems::next() const
{
/* Check default value. */
{
QXmlResultItems result;
QVERIFY(result.next().isNull());
}
/* Stress it on a default constructed value. */
{
QXmlResultItems result;
QVERIFY(result.next().isNull());
QVERIFY(result.next().isNull());
QVERIFY(result.next().isNull());
}
}
示例5: variable
QPatternist::Item
ExternalSourceLoader::evaluateSingleton(const QXmlName name,
const QPatternist::DynamicContext::Ptr &context)
{
Q_ASSERT(!name.isNull());
const VariableValue variable(m_variableMap.value(Global::namePool()->stringForLocalName(name.localName())));
if(variable.second == Document)
{
Q_ASSERT_X(QFile::exists(variable.first.toLocalFile()), Q_FUNC_INFO,
qPrintable(QString::fromLatin1("The file %1 doesn't exist").arg(variable.first.toLocalFile())));
Q_ASSERT_X(m_resourceLoader->openDocument(variable.first, context), Q_FUNC_INFO,
"We're supposed to have the value. If not, an error should have been issued at query compile time.");
return m_resourceLoader->openDocument(variable.first, context);
}
else if(variable.second == Query)
{
/* Well, here we open the file and execute it. */
m_query.setQuery(QUrl::fromLocalFile(variable.first.toLocalFile()));
Q_ASSERT(m_query.isValid());
QXmlResultItems result;
m_query.evaluateTo(&result);
return QPatternist::Item::fromPublic(result.next());
}
else
{
Q_ASSERT(variable.second == URI);
return QPatternist::AtomicString::fromValue(variable.first.toString());
}
}
示例6: findElement
SimXmlElement SimXmlDoc::findElement(const std::string& elementName, const std::string& refId) const
{
SimXmlElement result(QSharedPointer<QDomElement>(), *this);
if (isNull()){
return result;
}
QString queryString = simQuery("/SimModel/" + elementName + "[@RefId='" + refId + "'][1]");
QXmlQuery query;
QDomNodeModel model(query.namePool(), *(impl()));
query.setFocus(QXmlItem(model.fromDomNode(impl()->documentElement())));
query.setQuery(queryString, QUrl(QString::fromStdString(this->path())));
if (query.isValid()) {
QXmlResultItems items;
query.evaluateTo(&items);
QXmlItem item(items.next());
if(!item.isNull()) {
QDomElement elem = model.toDomNode(item.toNodeModelIndex()).toElement();
QSharedPointer<QDomElement> impl(new QDomElement(elem));
result = SimXmlElement(impl, *this);
}
}
return result;
}
示例7: 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;
}
示例8: 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());
}
示例9: 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.")));
}
}
}
示例10: model
std::vector<SimXmlElement> SimXmlDoc::getElements(const std::string& elementName) const
{
std::vector<SimXmlElement> result;
if (isNull()){
return result;
}
QString queryString = simQuery("/SimModel/" + elementName);
QXmlQuery query;
QDomNodeModel model(query.namePool(), *(impl()));
query.setFocus(QXmlItem(model.fromDomNode(impl()->documentElement())));
query.setQuery(queryString, QUrl(QString::fromStdString(this->path())));
if (query.isValid()) {
QString junk;
QXmlResultItems items;
query.evaluateTo(&items);
QXmlItem item(items.next());
while (!item.isNull()) {
QDomElement elem = model.toDomNode(item.toNodeModelIndex()).toElement();
QSharedPointer<QDomElement> impl(new QDomElement(elem));
result.push_back(SimXmlElement(impl, *this));
// get next item
item = items.next();
}
}
return result;
}
示例11: 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! */;
}
}
示例12: 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());
}
}
示例13: 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;
}
}
示例14: sipConvertFromNewType
static PyObject *meth_QXmlResultItems_next(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QXmlResultItems *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QXmlResultItems, &sipCpp))
{
QXmlItem*sipRes;
sipRes = new QXmlItem(sipCpp->next());
return sipConvertFromNewType(sipRes,sipType_QXmlItem,NULL);
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QXmlResultItems, sipName_next, doc_QXmlResultItems_next);
return NULL;
}
示例15: execute
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());
//.........这里部分代码省略.........