本文整理汇总了C++中expression::List::first方法的典型用法代码示例。如果您正苦于以下问题:C++ List::first方法的具体用法?C++ List::first怎么用?C++ List::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类expression::List
的用法示例。
在下文中一共展示了List::first方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOperands
void TripleContainer::setOperands(const Expression::List &ops)
{
Q_ASSERT(ops.count() == 3);
m_operand1 = ops.first();
m_operand2 = ops.at(1);
m_operand3 = ops.at(2);
}
示例2: setOperands
void PairContainer::setOperands(const Expression::List &ops)
{
Q_ASSERT(ops.count() == 2);
m_operand1 = ops.first();
m_operand2 = ops.last();
Q_ASSERT(m_operand1);
Q_ASSERT(m_operand2);
}
示例3: retrieveExpression
Expression::Ptr ConstructorFunctionsFactory::retrieveExpression(const QXmlName name,
const Expression::List &args,
const FunctionSignature::Ptr &sign) const
{
Q_UNUSED(sign);
/* This function is only called if the callsite is valid, so createSchemaType() will always
* return an AtomicType. */
const AtomicType::Ptr at(static_cast<AtomicType *>(m_typeFactory->createSchemaType(name).data()));
return Expression::Ptr(new CastAs(args.first(),
makeGenericSequenceType(at,
Cardinality::zeroOrOne())));
}
示例4: compress
Expression::Ptr ExpressionSequence::compress(const StaticContext::Ptr &context)
{
const Expression::Ptr me(UnlimitedContainer::compress(context));
if(me != this)
return me;
Expression::List::const_iterator it(m_operands.constBegin());
const Expression::List::const_iterator end(m_operands.constEnd());
Expression::List result;
for(; it != end; ++it)
{
const ID Id = (*it)->id();
/* Remove empty sequences. This is rather important because we have some steps in the parser that
* intentionally, unconditionally and for temporary reasons create expressions like (expr, ()). Of course,
* empty sequences also occur as part of optimizations.
*
* User function call sites that are of type empty-sequence() must be avoided since
* they may contain calls to fn:error(), which we would rewrite away otherwise. */
if(Id != IDUserFunctionCallsite && (*it)->staticType()->cardinality().isEmpty())
{
/* Rewrite "(1, (), 2)" into "(1, 2)" by not
* adding (*it) to result. */
continue;
}
else if(Id == IDExpressionSequence)
{
/* Rewrite "(1, (2, 3), 4)" into "(1, 2, 3, 4)" */
Expression::List::const_iterator seqIt((*it)->operands().constBegin());
const Expression::List::const_iterator seqEnd((*it)->operands().constEnd());
for(; seqIt != seqEnd; ++seqIt)
result.append(*seqIt);
}
else
result.append(*it);
}
if(result.isEmpty())
return EmptySequence::create(this, context);
else if(result.count() == 1)
return result.first();
else
{
m_operands = result;
return me;
}
}
示例5: setOperands
void SingleContainer::setOperands(const Expression::List &ops)
{
Q_ASSERT(ops.count() == 1);
m_operand = ops.first();
}
示例6: invokeOptimizers
Expression::Ptr Expression::invokeOptimizers(const Expression::Ptr &expr,
const StaticContext::Ptr &context)
{
Q_ASSERT(expr);
const OptimizationPass::List opts(expr->optimizationPasses());
if(opts.isEmpty()) /* Early exit. */
{
return expr;
}
const OptimizationPass::List::const_iterator passEnd(opts.constEnd());
const OptimizationPass::List::const_iterator end(opts.constEnd());
OptimizationPass::List::const_iterator passIt(opts.constBegin());
for(; passIt != passEnd; ++passIt) /* Invoke each optimization pass. */
{
const OptimizationPass::Ptr pass(*passIt); /* Alias, for readability. */
OptimizationPass::ExpressionMarker sourceMarker(pass->sourceExpression);
if(pass->startIdentifier && !pass->startIdentifier->matches(expr))
{
/* This pass specified a start identifier and it did
* not match -- let's try the next OptimizationPass. */
continue;
}
const ExpressionIdentifier::List::const_iterator idEnd(pass->operandIdentifiers.constEnd());
ExpressionIdentifier::List::const_iterator idIt(pass->operandIdentifiers.constBegin());
const Expression::List ops(expr->operands());
const Expression::List::const_iterator opEnd(ops.constEnd());
Expression::List::const_iterator opIt(ops.constBegin());
switch(pass->operandsMatchMethod)
{
case OptimizationPass::Sequential:
{
for(; opIt != opEnd; ++opIt)
{
const Expression::Ptr operand(*opIt); /* Alias, for readability. */
const ExpressionIdentifier::Ptr opIdentifier(*idIt); /* Alias, for readability. */
if(opIdentifier && !opIdentifier->matches(operand))
{
break;
}
++idIt;
}
if(opIt == opEnd)
break; /* All operands matched, so this pass matched. */
else
{
/* The loop above did not finish which means all operands did not match.
Therefore, this OptimizationPass did not match -- let's try the next one. */
continue;
}
}
case OptimizationPass::AnyOrder:
{
Q_ASSERT_X(ops.count() == 2, Q_FUNC_INFO,
"AnyOrder is currently only supported for Expressions with two operands.");
if(pass->operandIdentifiers.first()->matches(ops.first()) &&
pass->operandIdentifiers.last()->matches(ops.last()))
{
break;
}
else if(pass->operandIdentifiers.first()->matches(ops.last()) &&
pass->operandIdentifiers.last()->matches(ops.first()))
{
sourceMarker.first() = 1;
sourceMarker[1] = 0;
break; /* This pass matched. */
}
else
continue; /* This pass didn't match, let's loop through the next pass. */
}
}
/* Figure out the source Expression, if any. */
Expression::List operands;
Expression::Ptr sourceExpr;
if(!sourceMarker.isEmpty())
{
const OptimizationPass::ExpressionMarker::const_iterator mEnd(sourceMarker.constEnd());
OptimizationPass::ExpressionMarker::const_iterator mIt(sourceMarker.constBegin());
sourceExpr = expr;
for(; mIt != mEnd; ++mIt)
{
Q_ASSERT(*mIt >= 0);
sourceExpr = sourceExpr->operands().at(*mIt);
}
operands.append(sourceExpr);
}
if(operands.isEmpty())
//.........这里部分代码省略.........