本文整理汇总了C++中QXmlQuery类的典型用法代码示例。如果您正苦于以下问题:C++ QXmlQuery类的具体用法?C++ QXmlQuery怎么用?C++ QXmlQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmlQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDebug
void NetFlixQueueProxy::getQueueRequestCompleted(int retCode, QString body){
qDebug() << "queue request completed!!";
qDebug() << retCode;
QXmlQuery query;
QString result;
QBuffer device;
device.setData(body.toUtf8());
device.open(QIODevice::ReadOnly);
query.bindVariable("netflix_queue",&device);
query.setQuery(QUrl("qrc:/queries/queue.xq"));
if (query.isValid())
{
if (query.evaluateTo(&result))
qDebug() << result;
else
qDebug() << "Evaluate failed";
}
else
qDebug() << "setQuery Failed.";
}
示例2: buf
void ShoutcastFetcher::newStationsAvailable(QIODevice * openInputDevice, const QString & keyWord)
{
// Using read() putting the content into a QBuffer to workaround
// some strange hang if passing IO device directly into
// QXmlQuery object.
QByteArray content = openInputDevice->read(maxSize);
QBuffer buf(&content);
buf.open(QIODevice::ReadOnly);
QXmlQuery q;
q.bindVariable("stations", &buf);
q.setQuery("for $i in doc($stations)/stationlist/station " \
"let $tunein := doc($stations)/stationlist/tunein/@base " \
"return (string($i/@name), string($i/@id), string($i/@br), string($i/@genre)," \
" string($i/@lc), string($i/@mt), string($i/@ct), string($tunein))");
QStringList strings;
q.evaluateTo(&strings);
m_keywordStationMapping[keyWord].clear();
ShoutcastStationList & sl = m_keywordStationMapping[keyWord];
for (QStringList::const_iterator iter = strings.constBegin(); iter != strings.constEnd(); iter += 8)
{
QString tuneIn = stationsURL + *(iter + 1);
ShoutcastStation s(*iter, (*(iter + 1)).toInt(), (*(iter + 2)).toInt(),
*(iter + 3), (*(iter + 4)).toInt(), *(iter + 5), *(iter + 6),
tuneIn);
sl.append(s);
}
emit newStationsAvailable(keyWord);
}
示例3: QString
//! [1]
TimeInformation::List TimeQuery::queryInternal(const QString &stationId, const QDateTime &dateTime)
{
const QString timesQueryUrl = QString("doc('http://wap.trafikanten.no/F.asp?f=%1&t=%2&m=%3&d=%4&start=1')/wml/card/p/small/a[fn:starts-with(@href, 'Rute')]/string()")
.arg(stationId)
.arg(dateTime.time().hour())
.arg(dateTime.time().minute())
.arg(dateTime.toString("dd.MM.yyyy"));
const QString directionsQueryUrl = QString("doc('http://wap.trafikanten.no/F.asp?f=%1&t=%2&m=%3&d=%4&start=1')/wml/card/p/small/text()[matches(., '[0-9].*')]/string()")
.arg(stationId)
.arg(dateTime.time().hour())
.arg(dateTime.time().minute())
.arg(dateTime.toString("dd.MM.yyyy"));
QStringList times;
QStringList directions;
QXmlQuery query;
query.setQuery(timesQueryUrl);
query.evaluateTo(×);
query.setQuery(directionsQueryUrl);
query.evaluateTo(&directions);
if (times.count() != directions.count()) // something went wrong...
return TimeInformation::List();
TimeInformation::List information;
for (int i = 0; i < times.count(); ++i)
information.append(TimeInformation(times.at(i).simplified(), directions.at(i).simplified()));
return information;
}
示例4: evaluate
void QueryMainWindow::evaluate(const QString &str)
{
/* This function takes the input string and displays the
* appropriate output using QXmlQuery.
*/
QXmlQuery query;
QFile sourceDocument;
sourceDocument.setFileName(":/files/cookbook.xml");
sourceDocument.open(QIODevice::ReadOnly);
query.bindVariable("inputDocument", &sourceDocument);
query.setQuery(str);
if(!query.isValid())
return;
QByteArray outArray;
QBuffer buffer(&outArray);
buffer.open(QIODevice::ReadWrite);
QXmlFormatter formatter(query, &buffer);
if(!query.evaluateTo(&formatter))
return;
buffer.close();
qFindChild<QTextEdit*>(this, "outputTextEdit")->setPlainText(QString::fromUtf8(outArray.constData()));
}
示例5: 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());
}
}
示例6: qDebug
std::string parserxml::getAnyValue(std::string pNodeDirectionValue)
{
if( !_file.open(QIODevice::ReadOnly))
{
qDebug() << "No se pudo abrir el XML para lectura.";
}
else
{
QXmlQuery query;
query.bindVariable("document", &_file);
std::string stringdocument = "doc($document)";
std::string finalstring = std::string(stringdocument) + std::string(pNodeDirectionValue);
query.setQuery(QString::fromStdString(finalstring));
if(!query.isValid())
{
qDebug()<< "Xpath invalido.";
}
QString queryresult;
query.evaluateTo(&queryresult);
if (queryresult == "\n")
{
queryresult = "";
}
_file.close();
return queryresult.toStdString();
}
}
示例7: Parse
void AVRStudioXMLParser::Parse(QString configDirPath, Part *pPart)
{
QXmlQuery query;
QString result;
query.bindVariable("partName", QVariant(configDirPath));
query.setQuery(GetXQuery());
query.evaluateTo(&result);
// for future use
QString errorMsg;
int line;
int col;
QDomDocument doc;
if(!doc.setContent(result, &errorMsg, &line, &col))
return;
QDomNode root = doc.firstChild();
QDomNode fuses = root.firstChild();
QDomNode locks = fuses.nextSibling();
QDomNode interfaces = locks.nextSibling();
pPart->SetFuseBits(GetBits(fuses.firstChild()));
pPart->SetLockBits(GetBits(locks.firstChild()));
pPart->SetProgrammingInterfaces(GetInterfaces(interfaces.firstChild()));
}
示例8: 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;
}
示例9: newMessage
void PtzManagement::getNode(Node *node)
{
Message *msg = newMessage();
msg->appendToBody(node->toxml());
MessageParser *result = sendMessage(msg);
if(result != NULL){
QXmlQuery *query = result->query();
QDomNodeList itemNodeList;
QDomNode node1;
QDomDocument doc;
QString value,xml;
query->setQuery(result->nameSpace()+"doc($inputDocument)//tptz:PTZNode");
query->evaluateTo(&xml);
doc.setContent(xml);
itemNodeList = doc.elementsByTagName("tptz:PTZNode");
for(int i=0; i<itemNodeList.size();i++)
{
node1= itemNodeList.at(i);
value = node1.toElement().attribute("token");
node->setPtzNodeToken(value.trimmed());
}
node->setName(result->getValue("//tt:Name").trimmed());
node->setAbsolutePanTiltPositionSpaceUri(result->getValue("//tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:URI").trimmed());
node->setAbsolutePanTiltPositionSpaceXRangeMin(result->getValue("//tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:XRange/tt:Min").trimmed().toInt());
node->setAbsolutePanTiltPositionSpaceXRangeMax(result->getValue("//tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:XRange/tt:Max").trimmed().toInt());
node->setAbsolutePanTiltPositionSpaceYRangeMin(result->getValue("//tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:YRange/tt:Min").trimmed().toInt());
node->setAbsolutePanTiltPositionSpaceYRangeMax(result->getValue("//tt:SupportedPTZSpaces/tt:AbsolutePanTiltPositionSpace/tt:YRange/tt:Max").trimmed().toInt());
node->setAbsoluteZoomPositionSpaceUri(result->getValue("//tt:SupportedPTZSpaces/tt:AbsoluteZoomPositionSpace/tt:URI").trimmed());
node->setAbsoluteZoomPositionSpaceXRangeMin(result->getValue("//tt:SupportedPTZSpaces/tt:AbsoluteZoomPositionSpace/tt:XRange/tt:Min").trimmed().toInt());
node->setAbsoluteZoomPositionSpaceXRangeMax(result->getValue("//tt:SupportedPTZSpaces/tt:AbsoluteZoomPositionSpace/tt:XRange/tt:Max").trimmed().toInt());
node->setRelativePanTiltTranslationSpaceUri(result->getValue("//tt:SupportPTZSpaces/tt:RelativePanTiltTranslationSpaces/tt:URI").trimmed());
node->setRelativePanTiltTranslationSpaceXRangeMin(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:XRange/tt:Min").trimmed().toInt());
node->setRelativePanTiltTranslationSpaceXRangeMax(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:XRange/tt:Max").trimmed().toInt());
node->setRelativePanTiltTranslationSpaceYRangeMin(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:YRange/tt:Min").trimmed().toInt());
node->setRelativePanTiltTranslationSpaceYRangeMax(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:YRange/tt:Max").trimmed().toInt());
node->setRelativeZoomTranslationSpaceUri(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:URI").trimmed());
node->setRelativeZoomTranslationSpaceXRangeMin(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:XRange/tt:Min").trimmed().toInt());
node->setRelativeZoomTranslationSpaceXRangeMax(result->getValue("//tt:SupportPTZSpace/tt:RelativePanTiltTranslationSpaces/tt:XRange/tt:Max").trimmed().toInt());
node->setContinuousPanTiltVelocityUri(result->getValue("//tt:SupportPTZSpace/tt:ContinuousPanTiltVelocitySpace/tt:URI").trimmed());
node->setContinuousPanTiltVelocityXRangeMin(result->getValue("//tt:SupportPTZSpace/tt:ContinuousPanTiltVelocitySpace/tt:XRange/tt:Min").trimmed().toInt());
node->setContinuousPanTiltVelocityXRangeMax(result->getValue("//tt:SupportPTZSpace/tt:ContinuousPanTiltVelocitySpace/tt:XRange/tt:Max").trimmed().toInt());
node->setContinuousPanTiltVelocityYRangeMin(result->getValue("//tt:SupportPTZSpace/tt:ContinuousPanTiltVelocitySpace/tt:YRange/tt:Min").trimmed().toInt());
node->setContinuousPanTiltVelocityYRangeMax(result->getValue("//tt:SupportPTZSpace/tt:ContinuousPanTiltVelocitySpace/tt:YRange/tt:Max").trimmed().toInt());
node->setContinuousZoomVelocitySpaceUri(result->getValue("//tt:SupportPTZSpace/tt:ContinuousZoomVelocitySpace/tt:URI").trimmed());
node->setContinuousZoomVelocitySpaceXRangeMin(result->getValue("//tt:SupportPTZSpace/tt:ContinuousZoomVelocitySpace/tt:XRange/tt:Min").toInt());
node->setContinuousZoomVelocitySpaceXRangeMax(result->getValue("//tt:SupportPTZSpace/tt:ContinuousZoomVelocitySpace/tt:XRange/tt:Max").toInt());
node->setPanTiltSpeedSpaceUri(result->getValue("//tt:SupportPTZSpace/tt:PanTiltSpeedSpace/tt:URI").trimmed());
node->setPanTiltSpeedSpaceXRangeMin(result->getValue("//tt:SupportPTZSpace/tt:PanTiltSpeedSpace/XRange/tt:Min").trimmed().toInt());
node->setPanTiltSpeedSpaceXRangeMax(result->getValue("//tt:SupportPTZSpace/tt:PanTiltSpeedSpace/XRange/tt:Max").trimmed().toInt());
node->setZoomSpeedSpaceUri(result->getValue("//tt:SupportPTZSpace/tt:ZoomSpeedSpace/tt:URI").trimmed());
node->setZoomSpeedSpaceXRangeMin(result->getValue("//tt:SupportPTZSpace/tt:ZoomSpeedSpace/tt:Min").trimmed().toInt());
node->setZoomSpeedSpaceXRangeMax(result->getValue("//tt:SupportPTZSpace/tt:ZoomSpeedSpace/tt:Max").trimmed().toInt());
node->setMaximumNumberOfPresets(result->getValue("//tt:MaximumNumberOfPresets").trimmed().toInt());
node->setHomeSupport(result->getValue("//tt:HomeSupported").trimmed() == "true"?true:false);
}
delete msg;
delete result;
}
示例10: 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();
}
示例11: loadWebBrowserStartURL
void MasterConfiguration::loadWebBrowserStartURL(QXmlQuery& query)
{
QString queryResult;
query.setQuery("string(/configuration/webbrowser/@defaultURL)");
if (query.evaluateTo(&queryResult))
webBrowserDefaultURL_ = queryResult.remove(QRegExp(TRIM_REGEX));
if (webBrowserDefaultURL_.isEmpty())
webBrowserDefaultURL_ = DEFAULT_URL;
}
示例12: 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());
}
示例13: Q_ASSERT
void YandexNarodUploadJob::onDirectoryChecked()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
Q_ASSERT(reply);
reply->deleteLater();
const int code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (code == 404) {
// Directory is not created yet, so be a god
YandexRequest request(reply->url());
QNetworkReply *reply = YandexNarodFactory::networkManager()
->sendCustomRequest(request, "MKCOL");
connect(reply, SIGNAL(finished()), this, SLOT(onDirectoryCreated()));
return;
}
const QString xmlData = QString::fromUtf8(reply->readAll());
QStringList files;
QXmlQuery query;
query.setFocus(xmlData);
query.setQuery(QLatin1String("declare default element namespace \"DAV:\";"
"/multistatus/response/href/text()/string()"));
query.evaluateTo(&files);
if (files.contains(QLatin1String("/qutim-filetransfer"))) {
// Oops... May be check another directories?
setState(Error);
setError(NetworkError);
setErrorString(QT_TR_NOOP("Can't create directory \"/qutim-filetransfer/\""));
return;
}
const QString fileName = YandexNarodUploadJob::fileName();
QUrl url = reply->url();
QString path = url.path();
QString filePath = path + fileName;
if (files.contains(filePath)) {
const QString basename = fileName.section(QLatin1Char('.'), 0, 0);
const QString suffix = fileName.section(QLatin1Char('.'), 1);
for (int i = 1; ; ++i) {
filePath = path % basename
% QLatin1Char('(') % QString::number(i) % QLatin1Char(')')
% (suffix.isEmpty() ? QLatin1Literal("") : QLatin1Literal("."))
% suffix;
if (!files.contains(filePath))
break;
}
}
uploadFile(reply->url().resolved(QUrl(filePath)));
}
示例14: readRatesUsingXQuery
// Notes: my biggest issue with this design is that the different pieces of
// each rate are pulled out separately. I would prefer one query that
// pulled them out in sets.
void readRatesUsingXQuery(const QFileInfo file) {
const QString queryUrl = QString("doc('%1')//rate/%2/string()").arg(file.absoluteFilePath());
typedef QPair<QStringList &, QString> QueryPair;
QList<QueryPair> queries;
QStringList from, to, conversion;
queries << QueryPair(from, "from") << QueryPair(to, "to") << QueryPair(conversion, "conversion");
QXmlQuery query;
foreach (QueryPair pair, queries) {
query.setQuery(queryUrl.arg(pair.second));
query.evaluateTo(&pair.first);
}
示例15: loadMasterSettings
void MasterConfiguration::loadMasterSettings()
{
QXmlQuery query;
if(!query.setFocus(QUrl(filename_)))
{
put_flog(LOG_FATAL, "failed to load %s", filename_.toLatin1().constData());
exit(-1);
}
loadDockStartDirectory(query);
loadWebBrowserStartURL(query);
}