当前位置: 首页>>代码示例>>C++>>正文


C++ QXmlResultItems类代码示例

本文整理汇总了C++中QXmlResultItems的典型用法代码示例。如果您正苦于以下问题:C++ QXmlResultItems类的具体用法?C++ QXmlResultItems怎么用?C++ QXmlResultItems使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QXmlResultItems类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Q_ASSERT

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());
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:33,代码来源:ExternalSourceLoader.cpp

示例2: query

//! [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;
}
开发者ID:eagafonov,项目名称:qtmoko,代码行数:27,代码来源:qobjectxmlmodel.cpp

示例3: result

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;
}
开发者ID:bobzabcik,项目名称:OpenStudio,代码行数:35,代码来源:SimXmlDoc.cpp

示例4: constCorrectness

void tst_QXmlResultItems::constCorrectness() const
{
    const QXmlResultItems result;

    /* These functions should be const. */
    result.current();
    result.hasError();
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:8,代码来源:tst_qxmlresultitems.cpp

示例5: QNetworkAccessManager

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();
}
开发者ID:hicknhack-software,项目名称:Qt-Grantlee,代码行数:58,代码来源:rssfeed.cpp

示例6: 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());
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:11,代码来源:tst_qxmlresultitems.cpp

示例7: QVERIFY

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());
    }
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:16,代码来源:tst_qxmlresultitems.cpp

示例8: QFETCH

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());
    }
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:27,代码来源:tst_qxmlresultitems.cpp

示例9: 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());
    }
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:22,代码来源:tst_qxmlresultitems.cpp

示例10: 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;
}
开发者ID:EricChen2013,项目名称:qt-onvif-client,代码行数:43,代码来源:ptzmanagement.cpp

示例11: 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;
    }
}
开发者ID:maxxant,项目名称:qt,代码行数:41,代码来源:qxmlquery.cpp

示例12: qDebug

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.")));
        }
    }
}
开发者ID:52North,项目名称:IlwisConnectors,代码行数:21,代码来源:wfscapabilitiesparser.cpp

示例13: simQuery

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;
}
开发者ID:bobzabcik,项目名称:OpenStudio,代码行数:40,代码来源:SimXmlDoc.cpp

示例14: QXmlItem

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;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:22,代码来源:sipQtXmlPatternsQXmlResultItems.cpp

示例15: writeQuery

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! */;
	}
}
开发者ID:ZhaoweiDing,项目名称:UniSim,代码行数:23,代码来源:test_simulation_maker.cpp


注:本文中的QXmlResultItems类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。