本文整理汇总了C++中QXmlQuery::evaluateTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlQuery::evaluateTo方法的具体用法?C++ QXmlQuery::evaluateTo怎么用?C++ QXmlQuery::evaluateTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlQuery
的用法示例。
在下文中一共展示了QXmlQuery::evaluateTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: queryInternal
//! [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;
}
示例2: query
//! [0]
StationInformation::List StationQuery::query(const QString &name)
{
const QString stationIdQueryUrl = QString("doc(concat('http://wap.trafikanten.no/FromLink1.asp?fra=', $station))/wml/card/p/small/a[@title='Velg']/substring(@href,18)");
const QString stationNameQueryUrl = QString("doc(concat('http://wap.trafikanten.no/FromLink1.asp?fra=', $station))/wml/card/p/small/a[@title='Velg']/string()");
QStringList stationIds;
QStringList stationNames;
QXmlQuery query;
query.bindVariable("station", QVariant(QString::fromLatin1(QUrl::toPercentEncoding(name))));
query.setQuery(stationIdQueryUrl);
query.evaluateTo(&stationIds);
query.bindVariable("station", QVariant(QString::fromLatin1(QUrl::toPercentEncoding(name))));
query.setQuery(stationNameQueryUrl);
query.evaluateTo(&stationNames);
if (stationIds.count() != stationNames.count()) // something went wrong...
return StationInformation::List();
StationInformation::List information;
for (int i = 0; i < stationIds.count(); ++i)
information.append(StationInformation(stationIds.at(i), stationNames.at(i)));
return information;
}
示例3: readContextReply
void LastFmContext::readContextReply() {
qDebug("Got reply!");
QString replyString = QString::fromUtf8(contextReply->readAll());
if (replyString.isEmpty()) {
emit contextError();
return; // Avoid empty parsing of XML
}
// Parametres
QString status;
QString artistName;
QString artistPicture;
QString artistSummary;
QString artistProfile;
QXmlQuery query;
query.setFocus(replyString);
query.setQuery("lfm[@status = 'ok']/count(artist)");
query.evaluateTo(&status);
status = status.trimmed();
qDebug("Status: " + status.toUtf8());
/*
* If we got the data successfully, let's read it.
* I hate XML.
*/
if (status == "1") {
query.setQuery("lfm/artist/name/text()");
query.evaluateTo(&artistName);
artistName = artistName.trimmed();
query.setQuery("lfm/artist/url/text()");
query.evaluateTo(&artistProfile);
artistProfile = artistProfile.trimmed();
query.setQuery("lfm/artist/image[@size=\"extralarge\"]/text()");
query.evaluateTo(&artistPicture);
artistPicture = artistPicture.trimmed();
// Summary has HTML entities that must be un-replaced.
query.setQuery("lfm/artist/bio/summary/text()");
query.evaluateTo(&artistSummary);
artistSummary = artistSummary.trimmed().replace("<","<").replace(">",">");
// Store the context data into... contextData. Nice!
contextData.clear();
contextData.insert("artist", artistName);
contextData.insert("picture", artistPicture);
contextData.insert("summary", artistSummary);
contextData.insert("profile", artistProfile);
// Emit the signal
emit contextUpdated(contextData);
}
else {
qDebug("FAIL!");
emit contextError();
}
}
示例4: loadMasterSettings
void MasterConfiguration::loadMasterSettings()
{
QXmlQuery query;
if(!query.setFocus(QUrl(filename_)))
{
put_flog(LOG_FATAL, "failed to load %s", filename_.toLatin1().constData());
exit(-1);
}
QString queryResult;
// dock start directory
query.setQuery("string(/configuration/dock/@directory)");
if (query.evaluateTo(&queryResult))
dockStartDir_ = queryResult.remove(QRegExp("[\\n\\t\\r]"));
if( dockStartDir_.isEmpty( ))
dockStartDir_ = QDir::homePath();
// WebService server port
query.setQuery("string(/configuration/webservice/@port)");
if (query.evaluateTo(&queryResult))
{
if (queryResult.isEmpty())
dcWebServicePort_ = DEFAULT_WEBSERVICE_PORT;
else
dcWebServicePort_ = queryResult.toInt();
}
}
示例5: xml
QString F520xmlserializer::query(F520Status *f520, QString day, QString month, SysError &sysErr) {
QXmlQuery query;
QString res;
QFile xml(f520->getXmlPath());
if ( ! xml.exists()) {
xml.setFileName(f520->getXmlPath());
if ( ! xml.exists()) {
sysErr = SysError(SysError::F520_CAN_NOT_OPEN_FILE, "F520 Rasource file not exist");
return "";
}
}
if (!xml.open(QIODevice::ReadOnly | QIODevice::Text)) {
sysErr = SysError(SysError::F520_RESOUCES_NOT_EXIST, "F520 can not open xml resource file");
return "";
}
QString queryStr = CARICO + "/" + DAYS + "/" + DAY + "[@" + DAY_VALUE + "='" + day + "'][@" + MONTH_VALUE + "='" + month + "']";
qDebug() << "F520xmlserializer::query: " << queryStr;
query.setFocus(&xml);
query.setQuery(queryStr);
if ( ! query.isValid()) {
qDebug() << "F520xmlserializer::query query not valid";
sysErr = SysError(SysError::F520_QUERY_ERROR, "F520 Query is invalid: " + queryStr);
return "";
}
query.evaluateTo(&res);
if (!(res.length() > 1)) {
queryStr = CARICO + "/" + DAYS + "/" + DAY + "[@" + NAME + "='" + DEFAULT_DAY + "']";
qDebug() << "F520xmlserializer::query: " << queryStr;
query.setQuery(queryStr);
if (!query.isValid()) {
qDebug() << "F520xmlserializer::query query not valid";
sysErr = SysError(SysError::F520_QUERY_ERROR, "F520 Query is invalid: " + queryStr);
return "";
}
query.evaluateTo(&res);
}
xml.close();
qDebug() << "F520xmlserializer::query " << res;
QDomDocument watt;
watt.setContent("" + res + "");
QDomNodeList entryNodes = watt.elementsByTagName(DAY);
QString rtn;
for (int i = 0; i < entryNodes.count(); i++) {
QDomElement node = entryNodes.at(i).toElement();
rtn = node.attribute(WATT);
break;
}
qDebug() << "F520xmlserializer::query " << rtn;
return rtn;
}
示例6: load
void Configuration::load()
{
QXmlQuery query;
if(!query.setFocus(QUrl(filename_)))
throw std::runtime_error("Invalid configuration file: " + filename_.toStdString());
QString queryResult;
// get screen / mullion dimensions
query.setQuery("string(/configuration/dimensions/@numTilesWidth)");
if(query.evaluateTo(&queryResult))
totalScreenCountX_ = queryResult.toInt();
query.setQuery("string(/configuration/dimensions/@numTilesHeight)");
if(query.evaluateTo(&queryResult))
totalScreenCountY_ = queryResult.toInt();
query.setQuery("string(/configuration/dimensions/@screenWidth)");
if(query.evaluateTo(&queryResult))
screenWidth_ = queryResult.toInt();
query.setQuery("string(/configuration/dimensions/@screenHeight)");
if(query.evaluateTo(&queryResult))
screenHeight_ = queryResult.toInt();
query.setQuery("string(/configuration/dimensions/@mullionWidth)");
if(query.evaluateTo(&queryResult))
mullionWidth_ = queryResult.toInt();
query.setQuery("string(/configuration/dimensions/@mullionHeight)");
if(query.evaluateTo(&queryResult))
mullionHeight_ = queryResult.toInt();
// check for fullscreen mode flag
query.setQuery("string(/configuration/dimensions/@fullscreen)");
if(query.evaluateTo(&queryResult))
fullscreen_ = queryResult.toInt() != 0;
// Background content URI
query.setQuery("string(/configuration/background/@uri)");
if(query.evaluateTo(&queryResult))
backgroundUri_ = queryResult.remove(QRegExp("[\\n\\t\\r]"));
// Background color
query.setQuery("string(/configuration/background/@color)");
if (query.evaluateTo(&queryResult))
{
queryResult.remove(QRegExp("[\\n\\t\\r]"));
QColor newColor( queryResult );
if( newColor.isValid( ))
backgroundColor_ = newColor;
}
}
示例7: 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());
}
}
示例8: getQueueRequestCompleted
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.";
}
示例9: 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;
}
示例10: 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()));
}
示例11: newStationsAvailable
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);
}
示例12: 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()));
}
示例13: 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();
}
示例14: getAnyValue
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();
}
}
示例15: getNode
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;
}