本文整理汇总了C++中QXmlQuery::namePool方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlQuery::namePool方法的具体用法?C++ QXmlQuery::namePool怎么用?C++ QXmlQuery::namePool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlQuery
的用法示例。
在下文中一共展示了QXmlQuery::namePool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isPreviousAtomic
QXmlSerializerPrivate::QXmlSerializerPrivate(const QXmlQuery &query,
QIODevice *outputDevice)
: isPreviousAtomic(false),
state(QXmlSerializer::BeforeDocumentElement),
np(query.namePool().d),
device(outputDevice),
codec(QTextCodec::codecForMib(106)), /* UTF-8 */
query(query)
{
hasClosedElement.reserve(EstimatedTreeDepth);
namespaces.reserve(EstimatedTreeDepth);
nameCache.reserve(EstimatedNameCount);
hasClosedElement.push(qMakePair(QXmlName(), true));
/*
We push the empty namespace such that first of all
namespaceBinding() won't assert on an empty QStack,
and such that the empty namespace is in-scope and
that the code doesn't attempt to declare it.
We push the XML namespace. Although we won't receive
declarations for it, we may output attributes by that
name.
*/
QVector<QXmlName> defNss;
defNss.resize(2);
defNss[0] = QXmlName(StandardNamespaces::empty,
StandardLocalNames::empty,
StandardPrefixes::empty);
defNss[1] = QXmlName(StandardNamespaces::xml,
StandardLocalNames::empty,
StandardPrefixes::xml);
namespaces.push(defNss);
/* If we don't set this flag, QTextCodec will generate a BOM. */
converterState.flags = QTextCodec::IgnoreHeader;
}
示例2: model
std::vector<SimXmlElement> SimXmlDoc::findElementsWithChildValue(const std::string& elementName, const std::string& childName, const std::string& childValue) const
{
std::vector<SimXmlElement> result;
if (isNull()){
return result;
}
QString queryString = simQuery("/SimModel/" + elementName + "[" + childName + "='" + childValue + "']");
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());
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;
}