23 const char *QgsExpressionNodeBinaryOperator::BINARY_OPERATOR_TEXT[] =
27 "=",
"<>",
"<=",
">=",
"<",
">",
"~",
"LIKE",
"NOT LIKE",
"ILIKE",
"NOT ILIKE",
"IS",
"IS NOT",
28 "+",
"-",
"*",
"/",
"//",
"%",
"^",
32 const char *QgsExpressionNodeUnaryOperator::UNARY_OPERATOR_TEXT[] =
41 const QList< QgsExpressionNode * > nodeList = mList->
list();
43 needs |= n->needsGeometry();
54 mList.append( node->
node );
55 mNameList.append( cleanNamedNodeName( node->
name ) );
56 mHasNamedNodes =
true;
65 nl->mList.append( node->clone() );
67 nl->mNameList = mNameList;
78 if ( !first ) msg += QLatin1String(
", " );
85 QString QgsExpressionNode::NodeList::cleanNamedNodeName(
const QString &name )
87 QString cleaned = name.toLower();
90 if ( cleaned == QLatin1String(
"geom" ) )
91 cleaned = QStringLiteral(
"geometry" );
92 else if ( cleaned == QLatin1String(
"val" ) )
93 cleaned = QStringLiteral(
"value" );
94 else if ( cleaned == QLatin1String(
"geometry a" ) )
95 cleaned = QStringLiteral(
"geometry1" );
96 else if ( cleaned == QLatin1String(
"geometry b" ) )
97 cleaned = QStringLiteral(
"geometry2" );
107 QVariant val = mOperand->eval( parent, context );
114 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( val, parent );
116 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::NOT[tvl] );
120 if ( QgsExpressionUtils::isIntSafe( val ) )
121 return QVariant( - QgsExpressionUtils::getIntValue( val, parent ) );
122 else if ( QgsExpressionUtils::isDoubleSafe( val ) )
123 return QVariant( - QgsExpressionUtils::getDoubleValue( val, parent ) );
127 Q_ASSERT(
false &&
"unknown unary operation" );
139 return mOperand->prepare( parent, context );
145 return QStringLiteral(
"%1 ( %2 )" ).arg( UNARY_OPERATOR_TEXT[mOp], mOperand->dump() );
147 return QStringLiteral(
"%1 %2" ).arg( UNARY_OPERATOR_TEXT[mOp], mOperand->dump() );
152 return mOperand->referencedColumns();
157 return mOperand->referencedVariables();
162 return mOperand->referencedFunctions();
167 QList<const QgsExpressionNode *> lst;
169 lst += mOperand->nodes();
175 return mOperand->needsGeometry();
187 return mOperand->isStatic( parent, context );
192 return UNARY_OPERATOR_TEXT[mOp];
199 QVariant vL = mOpLeft->eval( parent, context );
202 if ( mOp == boAnd || mOp == boOr )
204 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent );
206 if ( mOp == boAnd && tvlL == QgsExpressionUtils::False )
208 if ( mOp == boOr && tvlL == QgsExpressionUtils::True )
212 QVariant vR = mOpRight->eval( parent, context );
218 if ( vL.type() == QVariant::String && vR.type() == QVariant::String )
220 QString sL = QgsExpressionUtils::isNull( vL ) ? QString() : QgsExpressionUtils::getStringValue( vL, parent );
222 QString sR = QgsExpressionUtils::isNull( vR ) ? QString() : QgsExpressionUtils::getStringValue( vR, parent );
224 return QVariant( sL + sR );
233 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
235 else if ( mOp != boDiv && QgsExpressionUtils::isIntSafe( vL ) && QgsExpressionUtils::isIntSafe( vR ) )
238 qlonglong iL = QgsExpressionUtils::getIntValue( vL, parent );
240 qlonglong iR = QgsExpressionUtils::getIntValue( vR, parent );
243 if ( mOp == boMod && iR == 0 )
246 return QVariant( computeInt( iL, iR ) );
248 else if ( QgsExpressionUtils::isDateTimeSafe( vL ) && QgsExpressionUtils::isIntervalSafe( vR ) )
250 QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent );
252 QgsInterval iL = QgsExpressionUtils::getInterval( vR, parent );
254 if ( mOp == boDiv || mOp == boMul || mOp == boMod )
256 parent->
setEvalErrorString( tr(
"Can't perform /, *, or % on DateTime and Interval" ) );
259 return QVariant( computeDateTimeFromInterval( dL, &iL ) );
261 else if ( mOp == boPlus && ( ( vL.type() == QVariant::Date && vR.type() == QVariant::Time ) ||
262 ( vR.type() == QVariant::Date && vL.type() == QVariant::Time ) ) )
264 QDate date = QgsExpressionUtils::getDateValue( vL.type() == QVariant::Date ? vL : vR, parent );
266 QTime time = QgsExpressionUtils::getTimeValue( vR.type() == QVariant::Time ? vR : vL, parent );
268 QDateTime dt = QDateTime( date, time );
269 return QVariant( dt );
271 else if ( mOp == boMinus && vL.type() == QVariant::Date && vR.type() == QVariant::Date )
273 QDate date1 = QgsExpressionUtils::getDateValue( vL, parent );
275 QDate date2 = QgsExpressionUtils::getDateValue( vR, parent );
277 return date1 - date2;
279 else if ( mOp == boMinus && vL.type() == QVariant::Time && vR.type() == QVariant::Time )
281 QTime time1 = QgsExpressionUtils::getTimeValue( vL, parent );
283 QTime time2 = QgsExpressionUtils::getTimeValue( vR, parent );
285 return time1 - time2;
287 else if ( mOp == boMinus && vL.type() == QVariant::DateTime && vR.type() == QVariant::DateTime )
289 QDateTime datetime1 = QgsExpressionUtils::getDateTimeValue( vL, parent );
291 QDateTime datetime2 = QgsExpressionUtils::getDateTimeValue( vR, parent );
293 return datetime1 - datetime2;
298 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
300 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
302 if ( ( mOp == boDiv || mOp == boMod ) && fR == 0. )
304 return QVariant( computeDouble( fL, fR ) );
310 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
312 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
316 return QVariant( qlonglong( std::floor( fL / fR ) ) );
319 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
323 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
325 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
327 return QVariant( std::pow( fL, fR ) );
332 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent ), tvlR = QgsExpressionUtils::getTVLValue( vR, parent );
334 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::AND[tvlL][tvlR] );
339 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent ), tvlR = QgsExpressionUtils::getTVLValue( vR, parent );
341 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::OR[tvlL][tvlR] );
350 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
354 else if ( QgsExpressionUtils::isList( vL ) || QgsExpressionUtils::isList( vR ) )
357 if ( !QgsExpressionUtils::isList( vL ) || !QgsExpressionUtils::isList( vR ) )
361 QVariantList lL = vL.toList();
362 QVariantList lR = vR.toList();
363 for (
int i = 0; i < lL.length() && i < lR.length(); i++ )
365 if ( QgsExpressionUtils::isNull( lL.at( i ) ) && QgsExpressionUtils::isNull( lR.at( i ) ) )
368 if ( QgsExpressionUtils::isNull( lL.at( i ) ) || QgsExpressionUtils::isNull( lR.at( i ) ) )
378 return QgsExpressionUtils::isNull( lR.at( i ) );
381 return QgsExpressionUtils::isNull( lL.at( i ) );
391 QVariant eq = eqNode.
eval( parent, context );
393 if ( eq == TVL_False )
397 QVariant v = node.
eval( parent, context );
407 return lL.length() == lR.length();
409 return lL.length() != lR.length();
411 return lL.length() < lR.length();
413 return lL.length() > lR.length();
415 return lL.length() <= lR.length();
417 return lL.length() >= lR.length();
423 else if ( ( vL.type() == QVariant::DateTime && vR.type() == QVariant::DateTime ) )
425 QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent );
427 QDateTime dR = QgsExpressionUtils::getDateTimeValue( vR, parent );
434 dL.setTimeSpec( Qt::UTC );
435 dR.setTimeSpec( Qt::UTC );
437 return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False;
439 else if ( ( vL.type() == QVariant::Date && vR.type() == QVariant::Date ) )
441 const QDate dL = QgsExpressionUtils::getDateValue( vL, parent );
443 const QDate dR = QgsExpressionUtils::getDateValue( vR, parent );
445 return compare( dR.daysTo( dL ) ) ? TVL_True : TVL_False;
447 else if ( ( vL.type() == QVariant::Time && vR.type() == QVariant::Time ) )
449 const QTime dL = QgsExpressionUtils::getTimeValue( vL, parent );
451 const QTime dR = QgsExpressionUtils::getTimeValue( vR, parent );
453 return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False;
455 else if ( ( vL.type() != QVariant::String || vR.type() != QVariant::String ) &&
456 QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) )
460 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
462 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
464 return compare( fL - fR ) ? TVL_True : TVL_False;
469 double fL = QgsExpressionUtils::getInterval( vL, parent ).seconds();
471 double fR = QgsExpressionUtils::getInterval( vR, parent ).seconds();
473 return compare( fL - fR ) ? TVL_True : TVL_False;
478 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
480 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
482 int diff = QString::compare( sL, sR );
483 return compare( diff ) ? TVL_True : TVL_False;
488 if ( QgsExpressionUtils::isNull( vL ) && QgsExpressionUtils::isNull( vR ) )
489 return ( mOp == boIs ? TVL_True : TVL_False );
490 else if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
491 return ( mOp == boIs ? TVL_False : TVL_True );
495 if ( QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) &&
496 ( vL.type() != QVariant::String || vR.type() != QVariant::String ) )
498 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
500 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
506 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
508 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
510 equal = QString::compare( sL, sR ) == 0;
513 return mOp == boIs ? TVL_True : TVL_False;
515 return mOp == boIs ? TVL_False : TVL_True;
523 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
527 QString str = QgsExpressionUtils::getStringValue( vL, parent );
529 QString regexp = QgsExpressionUtils::getStringValue( vR, parent );
533 if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp == boNotILike )
535 QString esc_regexp = QRegExp::escape( regexp );
537 if ( esc_regexp.startsWith(
'%' ) )
539 esc_regexp.replace( 0, 1, QStringLiteral(
".*" ) );
541 QRegExp rx(
"[^\\\\](%)" );
543 while ( ( pos = rx.indexIn( esc_regexp, pos ) ) != -1 )
545 esc_regexp.replace( pos + 1, 1, QStringLiteral(
".*" ) );
548 rx.setPattern( QStringLiteral(
"\\\\%" ) );
549 esc_regexp.replace( rx, QStringLiteral(
"%" ) );
550 if ( esc_regexp.startsWith(
'_' ) )
552 esc_regexp.replace( 0, 1, QStringLiteral(
"." ) );
554 rx.setPattern( QStringLiteral(
"[^\\\\](_)" ) );
556 while ( ( pos = rx.indexIn( esc_regexp, pos ) ) != -1 )
558 esc_regexp.replace( pos + 1, 1,
'.' );
561 rx.setPattern( QStringLiteral(
"\\\\_" ) );
562 esc_regexp.replace( rx, QStringLiteral(
"_" ) );
563 matches = QRegExp( esc_regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
567 matches = QRegExp( regexp ).indexIn( str ) != -1;
570 if ( mOp == boNotLike || mOp == boNotILike )
575 return matches ? TVL_True : TVL_False;
579 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
583 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
585 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
587 return QVariant( sL + sR );
597 bool QgsExpressionNodeBinaryOperator::compare(
double diff )
619 qlonglong QgsExpressionNodeBinaryOperator::computeInt( qlonglong x, qlonglong y )
639 QDateTime QgsExpressionNodeBinaryOperator::computeDateTimeFromInterval(
const QDateTime &d,
QgsInterval *i )
644 return d.addSecs( i->
seconds() );
646 return d.addSecs( -i->
seconds() );
653 double QgsExpressionNodeBinaryOperator::computeDouble(
double x,
double y )
666 return std::fmod( x, y );
680 bool resL = mOpLeft->prepare( parent, context );
681 bool resR = mOpRight->prepare( parent, context );
727 Q_ASSERT(
false &&
"unexpected binary operator" );
763 Q_ASSERT(
false &&
"unexpected binary operator" );
773 QString rdump( mOpRight->dump() );
778 rdump.prepend(
'(' ).append(
')' );
782 if ( leftAssociative() )
784 fmt += lOp && ( lOp->
precedence() < precedence() ) ? QStringLiteral(
"(%1)" ) : QStringLiteral(
"%1" );
785 fmt += QLatin1String(
" %2 " );
786 fmt += rOp && ( rOp->
precedence() <= precedence() ) ? QStringLiteral(
"(%3)" ) : QStringLiteral(
"%3" );
790 fmt += lOp && ( lOp->
precedence() <= precedence() ) ? QStringLiteral(
"(%1)" ) : QStringLiteral(
"%1" );
791 fmt += QLatin1String(
" %2 " );
792 fmt += rOp && ( rOp->
precedence() < precedence() ) ? QStringLiteral(
"(%3)" ) : QStringLiteral(
"%3" );
795 return fmt.arg( mOpLeft->dump(), BINARY_OPERATOR_TEXT[mOp], rdump );
800 return mOpLeft->referencedColumns() + mOpRight->referencedColumns();
805 return mOpLeft->referencedVariables() + mOpRight->referencedVariables();
810 return mOpLeft->referencedFunctions() + mOpRight->referencedFunctions();
815 QList<const QgsExpressionNode *> lst;
817 lst += mOpLeft->nodes() + mOpRight->nodes();
823 return mOpLeft->needsGeometry() || mOpRight->needsGeometry();
835 return mOpLeft->isStatic( parent, context ) && mOpRight->isStatic( parent, context );
842 if ( mList->count() == 0 )
843 return mNotIn ? TVL_True : TVL_False;
844 QVariant v1 = mNode->eval( parent, context );
846 if ( QgsExpressionUtils::isNull( v1 ) )
849 bool listHasNull =
false;
851 const QList< QgsExpressionNode * > nodeList = mList->list();
854 QVariant v2 = n->eval( parent, context );
856 if ( QgsExpressionUtils::isNull( v2 ) )
862 if ( ( v1.type() != QVariant::String || v2.type() != QVariant::String ) &&
863 QgsExpressionUtils::isDoubleSafe( v1 ) && QgsExpressionUtils::isDoubleSafe( v2 ) )
867 double f1 = QgsExpressionUtils::getDoubleValue( v1, parent );
869 double f2 = QgsExpressionUtils::getDoubleValue( v2, parent );
875 QString s1 = QgsExpressionUtils::getStringValue( v1, parent );
877 QString s2 = QgsExpressionUtils::getStringValue( v2, parent );
879 equal = QString::compare( s1, s2 ) == 0;
883 return mNotIn ? TVL_False : TVL_True;
891 return mNotIn ? TVL_True : TVL_False;
907 bool res = mNode->prepare( parent, context );
908 const QList< QgsExpressionNode * > nodeList = mList->list();
911 res = res && n->prepare( parent, context );
918 return QStringLiteral(
"%1 %2 IN (%3)" ).arg( mNode->dump(), mNotIn ?
"NOT" :
"", mList->dump() );
930 if ( !mNode->isStatic( parent, context ) )
933 const QList< QgsExpressionNode * > nodeList = mList->list();
936 if ( !n->isStatic( parent, context ) )
947 QString name = QgsExpression::QgsExpression::Functions()[mFnIndex]->name();
950 QVariant res = fd->
run( mArgs, context, parent,
this );
958 : mFnIndex( fnIndex )
961 if ( !
args || functionParams.isEmpty() )
972 while ( idx < args->names().size() &&
args->
names().at( idx ).isEmpty() )
979 for ( ; idx < functionParams.count(); ++idx )
981 int nodeIdx =
args->
names().indexOf( functionParams.at( idx ).name().toLower() );
1011 bool res = fd->
prepare(
this, parent, context );
1014 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1017 res = res && n->prepare( parent, context );
1027 return QStringLiteral(
"%1%2" ).arg( fd->
name(), fd->
name().startsWith(
'$' ) ? QString() : QStringLiteral(
"()" ) );
1029 return QStringLiteral(
"%1(%2)" ).arg( fd->
name(), mArgs ? mArgs->
dump() : QString() );
1040 return functionColumns;
1044 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1047 if ( fd->
parameters().count() <= paramIndex || !fd->
parameters().at( paramIndex ).isSubExpression() )
1048 functionColumns.unite( n->referencedColumns() );
1052 return functionColumns;
1058 if ( fd->
name() == QLatin1String(
"var" ) )
1060 if ( !mArgs->
list().isEmpty() )
1064 return QSet<QString>() << var->
value().toString();
1066 return QSet<QString>() << QString();
1070 QSet<QString> functionVariables = QSet<QString>();
1073 return functionVariables;
1075 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1078 functionVariables.unite( n->referencedVariables() );
1081 return functionVariables;
1088 QSet<QString> functions = QSet<QString>();
1089 functions.insert( fd->
name() );
1094 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1097 functions.unite( n->referencedFunctions() );
1104 QList<const QgsExpressionNode *> lst;
1109 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1119 bool needs = QgsExpression::QgsExpression::Functions()[mFnIndex]->usesGeometry(
this );
1122 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1124 needs |= n->needsGeometry();
1147 if ( functionParams.isEmpty() )
1154 QSet< int > providedArgs;
1155 QSet< int > handledArgs;
1158 while (
args->
names().at( idx ).isEmpty() )
1160 providedArgs << idx;
1166 for ( ; idx < functionParams.count(); ++idx )
1168 int nodeIdx =
args->
names().indexOf( functionParams.at( idx ).name().toLower() );
1171 if ( !functionParams.at( idx ).optional() )
1173 error = QStringLiteral(
"No value specified for QgsExpressionFunction::Parameter '%1' for %2" ).arg( functionParams.at( idx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1179 if ( providedArgs.contains( idx ) )
1181 error = QStringLiteral(
"Duplicate QgsExpressionFunction::Parameter specified for '%1' for %2" ).arg( functionParams.at( idx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1185 providedArgs << idx;
1186 handledArgs << nodeIdx;
1191 const QStringList nameList =
args->
names();
1192 for (
const QString &name : nameList )
1194 if ( !name.isEmpty() && !functionParams.contains( name ) )
1199 if ( !name.isEmpty() && !handledArgs.contains( idx ) )
1201 int functionIdx = functionParams.indexOf( name );
1202 if ( providedArgs.contains( functionIdx ) )
1204 error = QStringLiteral(
"Duplicate QgsExpressionFunction::Parameter specified for '%1' for %2" ).arg( functionParams.at( functionIdx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1239 if ( mValue.isNull() )
1240 return QStringLiteral(
"NULL" );
1242 switch ( mValue.type() )
1245 return QString::number( mValue.toInt() );
1246 case QVariant::Double:
1247 return QString::number( mValue.toDouble() );
1248 case QVariant::LongLong:
1249 return QString::number( mValue.toLongLong() );
1250 case QVariant::String:
1252 case QVariant::Bool:
1253 return mValue.toBool() ? QStringLiteral(
"TRUE" ) : QStringLiteral(
"FALSE" );
1255 return tr(
"[unsupported type: %1; value: %2]" ).arg( mValue.typeName(), mValue.toString() );
1261 return QSet<QString>();
1266 return QSet<QString>();
1271 return QSet<QString>();
1276 QList<const QgsExpressionNode *> lst;
1329 parent->
setEvalErrorString( tr(
"No feature available for field '%1' evaluation" ).arg( mName ) );
1371 return QSet<QString>() << mName;
1376 return QSet<QString>();
1381 return QSet<QString>();
1386 QList<const QgsExpressionNode *> result;
1413 : mConditions( *conditions )
1414 , mElseExp( elseExp )
1422 qDeleteAll( mConditions );
1432 for (
WhenThen *cond : qgis::as_const( mConditions ) )
1434 QVariant vWhen = cond->mWhenExp->eval( parent, context );
1435 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( vWhen, parent );
1437 if ( tvl == QgsExpressionUtils::True )
1439 QVariant vRes = cond->mThenExp->eval( parent, context );
1447 QVariant vElse = mElseExp->
eval( parent, context );
1459 for (
WhenThen *cond : qgis::as_const( mConditions ) )
1461 res = cond->mWhenExp->prepare( parent, context )
1462 & cond->mThenExp->prepare( parent, context );
1468 return mElseExp->
prepare( parent, context );
1475 QString msg( QStringLiteral(
"CASE" ) );
1476 for (
WhenThen *cond : mConditions )
1478 msg += QStringLiteral(
" WHEN %1 THEN %2" ).arg( cond->mWhenExp->dump(), cond->mThenExp->dump() );
1481 msg += QStringLiteral(
" ELSE %1" ).arg( mElseExp->
dump() );
1482 msg += QLatin1String(
" END" );
1489 for (
WhenThen *cond : mConditions )
1491 lst += cond->mWhenExp->referencedColumns() + cond->mThenExp->referencedColumns();
1503 for (
WhenThen *cond : mConditions )
1505 lst += cond->mWhenExp->referencedVariables() + cond->mThenExp->referencedVariables();
1517 for (
WhenThen *cond : mConditions )
1519 lst += cond->mWhenExp->referencedFunctions() + cond->mThenExp->referencedFunctions();
1530 QList<const QgsExpressionNode *> lst;
1532 for (
WhenThen *cond : mConditions )
1534 lst += cond->mWhenExp->nodes() + cond->mThenExp->nodes();
1538 lst += mElseExp->
nodes();
1545 for (
WhenThen *cond : mConditions )
1547 if ( cond->mWhenExp->needsGeometry() ||
1548 cond->mThenExp->needsGeometry() )
1570 if ( !wt->mWhenExp->isStatic( parent, context ) || !wt->mThenExp->isStatic( parent, context ) )
1575 return mElseExp->
isStatic( parent, context );
1583 const QList< QgsExpressionNode * > nodeList = mList->
list();
1585 lst.unite( n->referencedColumns() );
1592 const QList< QgsExpressionNode * > nodeList = mList->
list();
1594 lst.unite( n->referencedVariables() );
1601 const QList< QgsExpressionNode * > nodeList = mList->
list();
1603 lst.unite( n->referencedFunctions() );
1609 QList<const QgsExpressionNode *> lst;
1611 const QList< QgsExpressionNode * > nodeList = mList->
list();
1618 : mWhenExp( whenExp )
1619 , mThenExp( thenExp )
1631 return new WhenThen( mWhenExp->clone(), mThenExp->clone() );
1636 return BINARY_OPERATOR_TEXT[mOp];
1643 const QVariant container = mContainer->eval( parent, context );
1645 const QVariant index = mIndex->eval( parent, context );
1648 switch ( container.type() )
1651 return QgsExpressionUtils::getMapValue( container, parent ).value( index.toString() );
1653 case QVariant::List:
1654 case QVariant::StringList:
1656 const QVariantList list = QgsExpressionUtils::getListValue( container, parent );
1657 qlonglong pos = QgsExpressionUtils::getIntValue( index, parent );
1658 if ( pos >= list.length() || pos < -list.length() )
1665 pos += list.length();
1668 return list.at( pos );
1684 bool resC = mContainer->prepare( parent, context );
1685 bool resV = mIndex->prepare( parent, context );
1686 return resC && resV;
1691 return QStringLiteral(
"%1[%2]" ).arg( mContainer->dump(), mIndex->dump() );
1696 return mContainer->referencedColumns() + mIndex->referencedColumns();
1701 return mContainer->referencedVariables() + mIndex->referencedVariables();
1706 return mContainer->referencedFunctions() + mIndex->referencedFunctions();
1711 QList<const QgsExpressionNode *> lst;
1713 lst += mContainer->nodes() + mIndex->nodes();
1719 return mContainer->needsGeometry() || mIndex->needsGeometry();
1731 return mContainer->isStatic( parent, context ) && mIndex->isStatic( parent, context );