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


C++ QXmlQuery::setMessageHandler方法代码示例

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


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

示例1: sipKeepReference

static PyObject *meth_QXmlQuery_setMessageHandler(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QAbstractMessageHandler* a0;
        PyObject *a0Keep;
        QXmlQuery *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "[email protected]", &sipSelf, sipType_QXmlQuery, &sipCpp, &a0Keep, sipType_QAbstractMessageHandler, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->setMessageHandler(a0);
            Py_END_ALLOW_THREADS

            sipKeepReference(sipSelf, -2, a0Keep);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QXmlQuery, sipName_setMessageHandler, doc_QXmlQuery_setMessageHandler);

    return NULL;
}
开发者ID:kunwijik,项目名称:Spectroscopy_paper,代码行数:27,代码来源:sipQtXmlPatternsQXmlQuery.cpp

示例2: setContent

void JobEventList::setContent(const QString &content, const QString &userName,
                              QList<qint64> jobIds)
{
  m_xml = content;
  m_valid = true;

  MessageHandler handler;
  QXmlQuery query;
  query.setMessageHandler(&handler);
  JobEventListXmlReceiver receiver(query.namePool());
  query.setFocus(m_xml);

  if (jobIds.isEmpty()) {
    query.setQuery("/list/JobEvent");
  }
  else {
    QString xpath = "/list/JobEvent/jobID[";
    QListIterator<qint64> iter(jobIds);

    while (iter.hasNext()) {
      qint64 jobId = iter.next();
      xpath += QString("starts-with(text(), '%1')").arg(jobId);
      if (iter.hasNext())
        xpath += " or ";
    }

    xpath += "]/parent::node()";

    query.setQuery(xpath);
  }

  m_valid = query.evaluateTo(&receiver);

  m_jobEvents = receiver.jobEvents();
}
开发者ID:OpenChemistry,项目名称:molequeue,代码行数:35,代码来源:jobeventlist.cpp

示例3: 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

示例4: serializationError

void tst_QXmlSerializer::serializationError() const
{
    QFETCH(QString, queryString);
    QXmlQuery query;
    MessageSilencer silencer;
    query.setMessageHandler(&silencer);

    query.setQuery(queryString);

    QByteArray output;
    QBuffer buffer(&output);
    QVERIFY(buffer.open(QIODevice::WriteOnly));
    QVERIFY(query.isValid());

    QXmlSerializer serializer(query, &buffer);

    QEXPECT_FAIL("Two top elements", "Bug, this is not checked for", Continue);
    QVERIFY(!query.evaluateTo(&serializer));
}
开发者ID:KDE,项目名称:android-qt,代码行数:19,代码来源:tst_qxmlserializer.cpp

示例5: setContent

void DirListingInfo::setContent(const QString &content)
{
  m_xml = content;
  m_valid = true;

  MessageHandler handler;
  QXmlQuery query;
  query.setMessageHandler(&handler);
  query.setFocus(m_xml);

  QString dir;
  query.setQuery("/DirListingInfo/currentDirectory/string()");
  m_valid = query.evaluateTo(&dir);

  if (!m_valid)
    return;

  m_currentDirectory = dir.trimmed();

  // Get the directories;
  FileInfoXmlReceiver dirReceiver(query.namePool());
  query.setQuery("/DirListingInfo/directories");
  m_valid = query.evaluateTo(&dirReceiver);

  if (!m_valid)
    return;

  m_directories = dirReceiver.fileInfos();

  // Get the files
  FileInfoXmlReceiver fileReceiver(query.namePool());
  query.setQuery("/DirListingInfo/files");
  m_valid = query.evaluateTo(&fileReceiver);

  if (!m_valid)
    return;

  m_files = fileReceiver.fileInfos();
}
开发者ID:OpenChemistry,项目名称:molequeue,代码行数:39,代码来源:dirlistinginfo.cpp

示例6: main

int main(int argc, char **argv)
{
    enum ExitCode
    {
        /**
         * We start from 2, because QApplicationArgumentParser
         * uses 1.
         */
        QueryFailure = 2,
        StdOutFailure
    };

    const QCoreApplication app(argc, argv);
    QCoreApplication::setApplicationName(QLatin1String("xmlpatterns"));

    PatternistApplicationParser parser(argc, argv);
    parser.setApplicationDescription(QLatin1String("A tool for running XQuery queries."));
    parser.setApplicationVersion(QLatin1String("0.1"));

    /* Is there a better way to do this? Probably not, but if the class becomes public, we probably
     * want a helper function that wraps this hack. */
    const int parameterType = qVariantFromValue(Parameter()).userType();
    const int outputType = qVariantFromValue(static_cast<QIODevice *>(0)).userType();

    QApplicationArgument param(QLatin1String("param"),
                               QXmlPatternistCLI::tr("Binds an external variable. The value is directly available using the variable reference: $name."),
                               parameterType);
    param.setMaximumOccurrence(-1);
    parser.addArgument(param);

    const QApplicationArgument noformat(QLatin1String("no-format"),
                                        QXmlPatternistCLI::tr("By default output is formatted for readability. When specified, strict serialization is performed."));
    parser.addArgument(noformat);

    const QApplicationArgument isURI(QLatin1String("is-uri"),
                                     QXmlPatternistCLI::tr("If specified, the filename is interpreted as a URI instead of a local filename."));
    parser.addArgument(isURI);

    /* The temporary object is required to compile with g++ 3.3. */
    QApplicationArgument queryURI = QApplicationArgument(QString(), /* Nameless. */
                                                         QXmlPatternistCLI::tr("A local filename pointing to the query to run. "
                                                                               "If the name ends with .xq it's assumed "
                                                                               "to be an XQuery query. (In other cases too, but "
                                                                               "that interpretation may change in a future release of Qt.)"),
                                  QVariant::String);
    queryURI.setMinimumOccurrence(1);
    parser.addArgument(queryURI);

    QApplicationArgument output(QLatin1String("output"),
                                QXmlPatternistCLI::tr("A local file to which the output should be written. The file is overwritten, or if not exist, created. If absent, stdout is used."),
                                outputType);
    parser.addArgument(output);

    if(!parser.parse())
        return parser.exitCode();

    QXmlQuery query;

    /* Bind external variables. */
    {
        const QVariantList parameters(parser.values(param));
        const int len = parameters.count();

        for(int i = 0; i < len; ++i)
        {
            const Parameter p(qVariantValue<Parameter>(parameters.at(i)));
            query.bindVariable(p.first, QXmlItem(p.second));
        }
    }

    /* The final preparations and execute the query. */
    QPatternist::ColoringMessageHandler messageHandler;
    query.setMessageHandler(&messageHandler);

    /* Get the query URI. */
    QUrl userURI;
    {
        const QString stringURI(parser.value(queryURI).toString());

        if(parser.has(isURI))
            userURI = QUrl::fromEncoded(stringURI.toLatin1());
        else
            userURI = QUrl::fromLocalFile(stringURI);
    }
    const QUrl effectiveURI(QUrl::fromLocalFile(QDir::current().absolutePath() + QLatin1Char('/')).resolved(userURI));

    Q_ASSERT_X(userURI.isValid(), Q_FUNC_INFO,
               "QApplicationArgumentParser should promise us this.");

    query.setQuery(effectiveURI);

    QIODevice *const outDevice = qVariantValue<QIODevice *>(parser.value(output));
    Q_ASSERT(outDevice);
    Q_ASSERT(outDevice->isWritable());

    if(query.isValid())
    {
        QAbstractXmlReceiver *receiver = 0;

        if(parser.has(noformat))
//.........这里部分代码省略.........
开发者ID:FilipBE,项目名称:qtextended,代码行数:101,代码来源:main.cpp


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