本文整理汇总了C++中item::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSequence
Sequence FunctionLocalname::createSequence(DynamicContext* context, int flags) const
{
XPath2MemoryManager* memMgr = context->getMemoryManager();
Node::Ptr ctxNode;
if(getNumArgs() == 1) {
Sequence arg=getParamNumber(1,context)->toSequence(context);
if(arg.isEmpty())
return Sequence(context->getItemFactory()->createString(XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgZeroLenString, context), memMgr);
ctxNode=arg.first();
}
else {
const Item::Ptr item = context->getContextItem();
if(item==NULLRCP)
XQThrow(FunctionException, X("FunctionLocalName::createSequence"),X("Undefined context item in fn:local-name [err:XPDY0002]"));
if(!item->isNode())
XQThrow(FunctionException, X("FunctionLocalName::createSequence"),X("The context item is not a node [err:XPTY0004]"));
ctxNode=item;
}
ATQNameOrDerived::Ptr name = ctxNode->dmNodeName(context);
if(name.notNull())
return Sequence(context->getItemFactory()->createString(((const ATQNameOrDerived*)name.get())->getName(), context), memMgr);
return Sequence(context->getItemFactory()->createString(XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgZeroLenString, context), memMgr);
}
示例2: reset
Item::Ptr UTransform::TransformResult::next(DynamicContext *context)
{
context->testInterrupt();
AutoVariableStoreReset reset(context, &scope_);
if(toDo_) {
toDo_ = false;
NodeSet copiedNodes = NodeSet(nodecompare(context));
VectorOfCopyBinding::const_iterator end = transform_->getBindings()->end();
for(VectorOfCopyBinding::const_iterator it = transform_->getBindings()->begin();
it != end; ++it) {
if((*it)->qname_ == 0) continue;
Sequence values = (*it)->expr_->createResult(context)->toSequence(context);
// Keep a record of the nodes that have been copied
Result valIt = values;
Item::Ptr val;
while((val = valIt->next(context)).notNull()) {
copiedNodes.insert((Node*)val.get());
}
scope_.setVar((*it)->uri_, (*it)->name_, values);
}
// Get the pending update list
PendingUpdateList pul = transform_->getModifyExpr()->createUpdateList(context);
// Check that the targets of the pending updates are copied nodes
for(PendingUpdateList::const_iterator i = pul.begin(); i != pul.end(); ++i) {
Node::Ptr target = i->getTarget();
while(copiedNodes.find(target) == copiedNodes.end()) {
target = target->dmParent(context);
if(target.isNull()) {
XQThrow3(StaticErrorException,X("UTransform::staticTyping"),
X("The target node of an update expression in the transform expression is not a node from the copy clauses [err:XUDY0014]"), &(*i));
}
}
}
// Apply the updates
AutoDelete<UpdateFactory> ufactory(context->createUpdateFactory());
ufactory->applyUpdates(pul, context, transform_->getRevalidationMode());
// Execute the return expression
result_ = transform_->getReturnExpr()->createResult(context);
}
Item::Ptr result = result_->next(context);
if(result.isNull()) {
result_ = 0;
return 0;
}
return result;
}
示例3: next
Item::Ptr PromoteNumericResult::next(DynamicContext *context)
{
Item::Ptr item = parent_->next(context);
if(item.notNull()) {
assert(item->isAtomicValue());
const AnyAtomicType *atomic = (const AnyAtomicType *)item.get();
// 3. For each numeric item in the atomic sequence that can be promoted to the expected atomic type using
// the promotion rules in B.1 Type Promotion, the promotion is done.
if(atomic->isNumericValue()) {
try {
const Numeric::Ptr promotedType = ((const Numeric*)atomic)->
promoteTypeIfApplicable(typeIndex_, context);
if(promotedType.notNull()) {
item = promotedType;
}
} catch (XPath2TypeCastException &e) {
XQThrow(XPath2ErrorException, X("SequenceType::AtomicTypeConvertFunctionArgResult::next"),
X("Numeric type promotion failed (for promotable type)"));
} catch (const XMLException& e) {
XQThrow(XPath2ErrorException, X("SequenceType::AtomicTypeConvertFunctionArgResult::next"),
X("Numeric type promotion failed (for promotable type)"));
}
}
}
else {
parent_ = 0;
}
return item;
}
示例4: main
int main(int argc, char *argv[]) {
// Initialise Xerces-C and XQilla by creating the factory object
XQilla xqilla;
// Parse an XQuery expression
// (AutoDelete deletes the object at the end of the scope)
AutoDelete<XQQuery> query(xqilla.parse(X("foo/bar/@baz")));
// Create a context object
AutoDelete<DynamicContext> context(query->createDynamicContext());
// Parse a document, and set it as the context item
Sequence seq = context->resolveDocument(X("foo.xml"));
if(!seq.isEmpty() && seq.first()->isNode()) {
context->setContextItem(seq.first());
context->setContextPosition(1);
context->setContextSize(1);
}
// Execute the query, using the context
Result result = query->execute(context);
// Iterate over the results, printing them
Item::Ptr item;
while(item = result->next(context)) {
std::cout << UTF8(item->asString(context)) << std::endl;
}
return 0;
}
示例5: getParamNumber
ContainerBase *LookupIndexFunction::getContainerArg(DynamicContext *context, bool lookup) const
{
if(container_ != 0) return container_;
if(!_args[0]->isConstant() && !lookup) return 0;
DbXmlConfiguration *conf = GET_CONFIGURATION(context);
Item::Ptr containerName = getParamNumber(1, context)->next(context);
try {
XmlContainer container = DbXmlUri::openContainer(XMLChToUTF8(containerName->asString(context)).str(),
conf->getManager(), conf->getTransaction());
Container *tcont = (Container*)container;
conf->getMinder()->addContainer(tcont);
return tcont;
}
catch(XmlException &e) {
e.setLocationInfo(this);
throw;
}
// Never reached
return 0;
}
示例6: createSequence
Sequence FunctionSentences::createSequence(DynamicContext* context, int flags) const
{
XPath2MemoryManager* memMgr = context->getMemoryManager();
// If the value of $operand1 is the empty sequence, the empty sequence is returned.
Item::Ptr inputString = getParamNumber(1,context)->next(context);
if(inputString.isNull())
return Sequence(memMgr);
const XMLCh *input=inputString->asString(context);
AutoDeallocate<XMLCh> buf(UnicodeTransformer::sentences(input, memMgr), memMgr);
XMLCh* rb = buf.get();
XMLCh* start = NULL;
Sequence resultSeq(0, memMgr);
// Build sequence
for (int i = 0; rb[i]; i++) {
if (rb[i] != UTF8PROC_SB_MARK)
continue;
rb[i] = 0;
if (rb[i+1] == 0 || rb[i+1] != UTF8PROC_SB_MARK) {
if (start != NULL)
resultSeq.addItem(context->getItemFactory()->createString(start, context));
start = rb + (i+1);
}
}
return resultSeq;
}
示例7: createSequence
Sequence FunctionDocument::createSequence(DynamicContext* context, int flags) const
{
const XMLCh *baseURI;
if(getNumArgs() == 2) {
baseURI = ((Node*)getParamNumber(2, context)->next(context).get())->dmBaseURI(context).first()->asString(context);
}
else {
baseURI = context->getBaseURI();
}
Sequence result(context->getMemoryManager());
Result args = getParamNumber(1, context);
Item::Ptr uriArg;
while((uriArg = args->next(context)).notNull()) {
const XMLCh *uri = uriArg->asString(context);
if(!XPath2Utils::isValidURI(uri, context->getMemoryManager()))
XQThrow(FunctionException, X("FunctionDocument::createSequence"), X("Invalid argument to fn:document function [err:FODC0005]"));
try {
XMLUri base(baseURI);
XMLUri full(&base, uri);
uri = context->getMemoryManager()->getPooledString(full.getUriText());
}
catch(MalformedURLException &e){
XQThrow(FunctionException, X("FunctionDocument::createSequence"), X("Invalid argument to resolve-uri [err:FORG0002]"));
}
result.joinSequence(context->resolveDocument(uri, this, context->getProjection() ? queryPathTree_ : 0));
}
return result;
}
示例8: X
Item::Ptr MetaDataFunction::MetaDataResult::getSingleResult(DynamicContext *context) const
{
// Get the node argument
Item::Ptr node = 0;
if(func_->getNumArgs() == 1) {
// node argument is the context item
node = context->getContextItem();
if(node == NULLRCP || !node->isNode()) {
XQThrow(FunctionException,X("MetaDataFunction::MetaDataResult::getSingleResult"),
X("The context item is not a node in function dbxml:metadata [err:FODC0001]"));
}
} else {
// node argument is given
node = func_->getParamNumber(2, context)->next(context);
}
// Resolve the string argument as a QName
const XMLCh *uri, *name;
func_->getQNameArg(1, uri, name, context);
// Lookup the metadata
const DbXmlNodeImpl *nodeImpl = (const DbXmlNodeImpl*)node->getInterface(DbXmlNodeImpl::gDbXml);
DBXML_ASSERT(nodeImpl != 0);
return nodeImpl->getMetaData(uri, name, context);
}
示例9: createSequence
Sequence FunctionDoc::createSequence(DynamicContext* context, int flags) const
{
Item::Ptr uriArg = getParamNumber(1,context)->next(context);
if(uriArg.isNull()) {
return Sequence(context->getMemoryManager());
}
const XMLCh *uri = uriArg->asString(context);
// on Windows, we can have URIs using \ instead of /; let's normalize them
if(uri != 0) {
unsigned int len = XPath2Utils::uintStrlen(uri);
AutoDeleteArray<XMLCh> newURI(new XMLCh[len + 1]);
const XMLCh *src = uri;
XMLCh *dst = newURI;
while(*src != 0) {
if(*src == '\\') *dst = '/';
else *dst = *src;
++src; ++dst;
}
*dst = 0;
uri = context->getMemoryManager()->getPooledString(newURI);
}
if(!XPath2Utils::isValidURI(uri, context->getMemoryManager()))
XQThrow(FunctionException, X("FunctionDoc::createSequence"), X("Invalid argument to fn:doc function [err:FODC0005]"));
return context->resolveDocument(uri, this, context->getProjection() ? queryPathTree_ : 0);
}
示例10: toBeCasted
Item::Ptr XQCastAs::CastAsResult::getSingleResult(DynamicContext *context) const
{
// The semantics of the cast expression are as follows:
// 1. Atomization is performed on the input expression.
Result toBeCasted(_di->getExpression()->createResult(context));
const Item::Ptr first = toBeCasted->next(context);
if(first == NULLRCP) {
// 3. If the result of atomization is an empty sequence:
// 1. If ? is specified after the target type, the result of the cast expression is an empty sequence.
// 2. If ? is not specified after the target type, a type error is raised [err:XPTY0004].
if(_di->getSequenceType()->getOccurrenceIndicator() == SequenceType::EXACTLY_ONE) {
XQThrow(TypeErrorException,X("XQCastAs::CastAsResult::getSingleResult"),
X("The input to a non-optional cast as expression is an empty sequence [err:XPTY0004]"));
}
else {
return 0;
}
}
const Item::Ptr second = toBeCasted->next(context);
// 2. If the result of atomization is a sequence of more than one atomic value, a type error is raised.[err:XPTY0004]
if(second != NULLRCP) {
XQThrow(TypeErrorException,X("XQCastAs::CastAsResult::getSingleResult"),
X("The input to a cast as expression is more than one atomic value [err:XPTY0004]"));
}
// 4. If the result of atomization is a single atomic value, the result of the cast expression depends on the input type and the target type.
// The normative definition of these rules is given in [XQuery 1.0 and XPath 2.0 Functions and Operators].
return _di->cast((const AnyAtomicType*)first.get(), context);
}
示例11: createUpdateList
PendingUpdateList UInsertAsLast::createUpdateList(DynamicContext *context) const
{
Node::Ptr node = (Node*)target_->createResult(context)->next(context).get();
if(node->dmNodeKind() != Node::element_string &&
node->dmNodeKind() != Node::document_string)
XQThrow(XPath2TypeMatchException,X("UInsertAsLast::createUpdateList"),
X("It is a type error for the target expression of an insert as last expression not to be a single element "
"or document [err:XUTY0005]"));
Sequence alist(context->getMemoryManager());
Sequence clist(context->getMemoryManager());
Result value = source_->createResult(context);
Item::Ptr item;
while((item = value->next(context)).notNull()) {
if(((Node*)item.get())->dmNodeKind() == Node::attribute_string) {
if(!clist.isEmpty())
XQThrow(ASTException,X("UInsertAsLast::createUpdateList"),
X("Attribute nodes must occur before other nodes in the source expression for an insert as last expression [err:XUTY0004]"));
// b. No attribute node in $alist may have a QName whose implied namespace binding conflicts with a namespace
// binding in the "namespaces" property of $target [err:XUDY0023].
ATQNameOrDerived::Ptr qname = ((Node*)item.get())->dmNodeName(context);
if(qname->getURI() != 0 && *(qname->getURI()) != 0) {
ATAnyURIOrDerived::Ptr uri = FunctionNamespaceURIForPrefix::uriForPrefix(qname->getPrefix(), node, context, this);
if(uri.notNull() && !XPath2Utils::equals(uri->asString(context), qname->getURI())) {
XMLBuffer buf;
buf.append(X("Implied namespace binding for the insert as last expression (\""));
buf.append(qname->getPrefix());
buf.append(X("\" -> \""));
buf.append(qname->getURI());
buf.append(X("\") conflicts with those already existing on the parent element of the target attribute [err:XUDY0023]"));
XQThrow3(DynamicErrorException, X("UInsertInto::createUpdateList"), buf.getRawBuffer(), this);
}
}
alist.addItem(item);
}
else
clist.addItem(item);
}
PendingUpdateList result;
if(!alist.isEmpty()) {
// 3. If $alist is not empty and into is specified, the following checks are performed:
// a. $target must be an element node [err:XUTY0022].
if(node->dmNodeKind() == Node::document_string)
XQThrow(XPath2TypeMatchException,X("UInsertInto::createUpdateList"),
X("It is a type error if an insert expression specifies the insertion of an attribute node into a document node [err:XUTY0022]"));
result.addUpdate(PendingUpdate(PendingUpdate::INSERT_ATTRIBUTES, node, alist, this));
}
if(!clist.isEmpty()) {
result.addUpdate(PendingUpdate(PendingUpdate::INSERT_INTO_AS_LAST, node, clist, this));
}
return result;
}
示例12: generateEventsImpl
EventGenerator::Ptr XQCopy::generateEventsImpl(const Item::Ptr &toBeCopied, EventHandler *events, DynamicContext *context,
bool preserveNS, bool preserveType) const
{
if(!toBeCopied->isNode()) {
toBeCopied->generateEvents(events, context, preserveNS, preserveType);
return 0;
}
Node *node = (Node*)toBeCopied.get();
if(node->dmNodeKind() == Node::element_string) {
NoInheritFilter niFilter(events, context->getMemoryManager());
if(!inheritNamespaces_) events = &niFilter;
AnyAtomicType::Ptr itemName = node->dmNodeName(context);
const ATQNameOrDerived *pQName = (const ATQNameOrDerived*)itemName.get();
const XMLCh *prefix = emptyToNull(pQName->getPrefix());
const XMLCh *uri = emptyToNull(pQName->getURI());
const XMLCh *localname = pQName->getName();
events->startElementEvent(prefix, uri, localname);
ElemConstructFilter elemFilter(events, this, context->getMemoryManager());
if(copyNamespaces_) {
Result nsnodes = node->dmNamespaceNodes(context, this);
Item::Ptr ns;
while((ns = nsnodes->next(context)).notNull()) {
ns->generateEvents(&elemFilter, context, preserveNS, preserveType);
}
}
for(VectorOfASTNodes::const_iterator itCont = children_.begin(); itCont != children_.end (); ++itCont) {
(*itCont)->generateAndTailCall(&elemFilter, context, preserveNS, preserveType);
}
// TBD validation and type - jpcs
const XMLCh *typeURI = SchemaSymbols::fgURI_SCHEMAFORSCHEMA;
const XMLCh *typeName = DocumentCache::g_szUntyped;
events->endElementEvent(prefix, uri, localname, typeURI, typeName);
}
else if(node->dmNodeKind() == Node::document_string) {
events->startDocumentEvent(0, 0);
DocConstructFilter filter(events, this);
for(VectorOfASTNodes::const_iterator itCont = children_.begin(); itCont != children_.end (); ++itCont) {
(*itCont)->generateAndTailCall(&filter, context, preserveNS, preserveType);
}
events->endDocumentEvent();
}
else {
node->generateEvents(events, context, preserveNS, preserveType);
}
return 0;
}
示例13: result
Result XQContextItem::result(DynamicContext *context, const LocationInfo *info)
{
const Item::Ptr item = context->getContextItem();
if(item.isNull()) {
XQThrow3(DynamicErrorException,X("XQContextItem::result"),
X("It is an error for the context item to be undefined when using it [err:XPDY0002]"), info);
}
return item;
}
示例14: createResult
Result XQContextItem::createResult(DynamicContext* context, int flags) const
{
const Item::Ptr item = context->getContextItem();
if(item.isNull()) {
XQThrow(DynamicErrorException,X("XQContextItem::ContextItemResult::createResult"),
X("It is an error for the context item to be undefined when using it [err:XPDY0002]"));
}
return item;
}
示例15: createSequence
Sequence FunctionMinutesFromDateTime::createSequence(DynamicContext* context, int flags) const
{
XPath2MemoryManager* memMgr = context->getMemoryManager();
Item::Ptr arg = getParamNumber(1, context)->next(context);
if(arg.isNull()) return Sequence(memMgr);
return Sequence(((const ATDateTimeOrDerived*)arg.get())->getMinutes(context), memMgr);
}