本文整理汇总了C++中namepool::Ptr::allocateBinding方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::allocateBinding方法的具体用法?C++ Ptr::allocateBinding怎么用?C++ Ptr::allocateBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类namepool::Ptr
的用法示例。
在下文中一共展示了Ptr::allocateBinding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluateToSequenceReceiver
void ComputedNamespaceConstructor::evaluateToSequenceReceiver(const DynamicContext::Ptr &context) const
{
const Item prefixItem(m_operand1->evaluateSingleton(context));
const QString prefix(prefixItem ? prefixItem.stringValue() : QString());
const Item namespaceItem(m_operand2->evaluateSingleton(context));
const QString namespaceURI(namespaceItem ? namespaceItem.stringValue() : QString());
if(namespaceURI.isEmpty())
{
context->error(QtXmlPatterns::tr("In a namespace constructor, the value for a namespace cannot be an empty string."),
ReportContext::XTDE0930,
this);
}
/* One optimization could be to store a pointer to
* the name pool as a member in order to avoid the virtual call(s). */
const NamePool::Ptr np(context->namePool());
if(!prefix.isEmpty() && !QXmlUtils::isNCName(prefix))
{
context->error(QtXmlPatterns::tr("The prefix must be a valid %1, which %2 is not.")
.arg(formatType(np, BuiltinTypes::xsNCName),
formatKeyword(prefix)),
ReportContext::XTDE0920,
this);
}
const QXmlName binding(np->allocateBinding(prefix, namespaceURI));
AnyURI::toQUrl<ReportContext::XTDE0905, DynamicContext::Ptr>(namespaceURI,
context,
this);
if(binding.prefix() == StandardPrefixes::xmlns)
{
context->error(QtXmlPatterns::tr("The prefix %1 cannot be bound.")
.arg(formatKeyword(prefix)),
ReportContext::XTDE0920,
this);
}
if((binding.prefix() == StandardPrefixes::xml && binding.namespaceURI() != StandardNamespaces::xml)
||
(binding.prefix() != StandardPrefixes::xml && binding.namespaceURI() == StandardNamespaces::xml))
{
context->error(QtXmlPatterns::tr("Only the prefix %1 can be bound to %2 and vice versa.")
.arg(formatKeyword(prefix), formatKeyword(namespaceURI)),
ReportContext::XTDE0925,
this);
}
context->outputReceiver()->namespaceBinding(binding);
}
示例2: streamToReceiver
bool AccelTreeResourceLoader::streamToReceiver(QIODevice *const dev,
AccelTreeBuilder<true> *const receiver,
const NamePool::Ptr &np,
const ReportContext::Ptr &context,
const QUrl &uri)
{
Q_ASSERT(dev);
Q_ASSERT(receiver);
Q_ASSERT(np);
QXmlStreamReader reader(dev);
/* Optimize: change NamePool to take QStringRef such that we don't have to call toString() below. That
* will save us a gazillion of temporary QStrings. */
while(!reader.atEnd())
{
reader.readNext();
switch(reader.tokenType())
{
case QXmlStreamReader::StartElement:
{
/* Send the name. */
receiver->startElement(np->allocateQName(reader.namespaceUri().toString(), reader.name().toString(),
reader.prefix().toString()), reader.lineNumber(), reader.columnNumber());
/* Send namespace declarations. */
const QXmlStreamNamespaceDeclarations &nss = reader.namespaceDeclarations();
/* The far most common case, is for it to be empty. */
if(!nss.isEmpty())
{
const int len = nss.size();
for(int i = 0; i < len; ++i)
{
const QXmlStreamNamespaceDeclaration &ns = nss.at(i);
receiver->namespaceBinding(np->allocateBinding(ns.prefix().toString(), ns.namespaceUri().toString()));
}
}
/* Send attributes. */
const QXmlStreamAttributes &attrs = reader.attributes();
const int len = attrs.size();
for(int i = 0; i < len; ++i)
{
const QXmlStreamAttribute &attr = attrs.at(i);
receiver->attribute(np->allocateQName(attr.namespaceUri().toString(), attr.name().toString(),
attr.prefix().toString()),
attr.value());
}
continue;
}
case QXmlStreamReader::EndElement:
{
receiver->endElement();
continue;
}
case QXmlStreamReader::Characters:
{
if(reader.isWhitespace())
receiver->whitespaceOnly(reader.text());
else
receiver->characters(reader.text());
continue;
}
case QXmlStreamReader::Comment:
{
receiver->comment(reader.text().toString());
continue;
}
case QXmlStreamReader::ProcessingInstruction:
{
receiver->processingInstruction(np->allocateQName(QString(), reader.processingInstructionTarget().toString()),
reader.processingInstructionData().toString());
continue;
}
case QXmlStreamReader::StartDocument:
{
receiver->startDocument();
continue;
}
case QXmlStreamReader::EndDocument:
{
receiver->endDocument();
continue;
}
case QXmlStreamReader::EntityReference:
/* Fallthrough. */
case QXmlStreamReader::DTD:
{
/* We just ignore any DTD and entity references. */
continue;
}
case QXmlStreamReader::Invalid:
//.........这里部分代码省略.........