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( node->
name.toLower() );
56 mHasNamedNodes =
true;
65 nl->mList.append( node->clone() );
67 nl->mNameList = mNameList;
78 if ( !first ) msg += QLatin1String(
", " );
90 QVariant val = mOperand->eval( parent, context );
97 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( val, parent );
99 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::NOT[tvl] );
103 if ( QgsExpressionUtils::isIntSafe( val ) )
104 return QVariant( - QgsExpressionUtils::getIntValue( val, parent ) );
105 else if ( QgsExpressionUtils::isDoubleSafe( val ) )
106 return QVariant( - QgsExpressionUtils::getDoubleValue( val, parent ) );
110 Q_ASSERT(
false &&
"unknown unary operation" );
122 return mOperand->prepare( parent, context );
128 return QStringLiteral(
"%1 ( %2 )" ).arg( UNARY_OPERATOR_TEXT[mOp], mOperand->dump() );
130 return QStringLiteral(
"%1 %2" ).arg( UNARY_OPERATOR_TEXT[mOp], mOperand->dump() );
135 return mOperand->referencedColumns();
140 return mOperand->referencedVariables();
145 return mOperand->referencedFunctions();
150 QList<const QgsExpressionNode *> lst;
152 lst += mOperand->nodes();
158 return mOperand->needsGeometry();
170 return mOperand->isStatic( parent, context );
175 return UNARY_OPERATOR_TEXT[mOp];
182 QVariant vL = mOpLeft->eval( parent, context );
185 if ( mOp == boAnd || mOp == boOr )
187 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent );
189 if ( mOp == boAnd && tvlL == QgsExpressionUtils::False )
191 if ( mOp == boOr && tvlL == QgsExpressionUtils::True )
195 QVariant vR = mOpRight->eval( parent, context );
201 if ( vL.type() == QVariant::String && vR.type() == QVariant::String )
203 QString sL = QgsExpressionUtils::isNull( vL ) ? QString() : QgsExpressionUtils::getStringValue( vL, parent );
205 QString sR = QgsExpressionUtils::isNull( vR ) ? QString() : QgsExpressionUtils::getStringValue( vR, parent );
207 return QVariant( sL + sR );
216 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
218 else if ( mOp != boDiv && QgsExpressionUtils::isIntSafe( vL ) && QgsExpressionUtils::isIntSafe( vR ) )
221 qlonglong iL = QgsExpressionUtils::getIntValue( vL, parent );
223 qlonglong iR = QgsExpressionUtils::getIntValue( vR, parent );
226 if ( mOp == boMod && iR == 0 )
229 return QVariant( computeInt( iL, iR ) );
231 else if ( QgsExpressionUtils::isDateTimeSafe( vL ) && QgsExpressionUtils::isIntervalSafe( vR ) )
233 QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent );
235 QgsInterval iL = QgsExpressionUtils::getInterval( vR, parent );
237 if ( mOp == boDiv || mOp == boMul || mOp == boMod )
239 parent->
setEvalErrorString( tr(
"Can't perform /, *, or % on DateTime and Interval" ) );
242 return QVariant( computeDateTimeFromInterval( dL, &iL ) );
244 else if ( mOp == boPlus && ( ( vL.type() == QVariant::Date && vR.type() == QVariant::Time ) ||
245 ( vR.type() == QVariant::Date && vL.type() == QVariant::Time ) ) )
247 QDate date = QgsExpressionUtils::getDateValue( vL.type() == QVariant::Date ? vL : vR, parent );
249 QTime time = QgsExpressionUtils::getTimeValue( vR.type() == QVariant::Time ? vR : vL, parent );
251 QDateTime dt = QDateTime( date, time );
252 return QVariant( dt );
254 else if ( mOp == boMinus && vL.type() == QVariant::Date && vR.type() == QVariant::Date )
256 QDate date1 = QgsExpressionUtils::getDateValue( vL, parent );
258 QDate date2 = QgsExpressionUtils::getDateValue( vR, parent );
260 return date1 - date2;
262 else if ( mOp == boMinus && vL.type() == QVariant::Time && vR.type() == QVariant::Time )
264 QTime time1 = QgsExpressionUtils::getTimeValue( vL, parent );
266 QTime time2 = QgsExpressionUtils::getTimeValue( vR, parent );
268 return time1 - time2;
270 else if ( mOp == boMinus && vL.type() == QVariant::DateTime && vR.type() == QVariant::DateTime )
272 QDateTime datetime1 = QgsExpressionUtils::getDateTimeValue( vL, parent );
274 QDateTime datetime2 = QgsExpressionUtils::getDateTimeValue( vR, parent );
276 return datetime1 - datetime2;
281 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
283 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
285 if ( ( mOp == boDiv || mOp == boMod ) && fR == 0. )
287 return QVariant( computeDouble( fL, fR ) );
293 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
295 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
299 return QVariant( qlonglong( std::floor( fL / fR ) ) );
302 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
306 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
308 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
310 return QVariant( std::pow( fL, fR ) );
315 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent ), tvlR = QgsExpressionUtils::getTVLValue( vR, parent );
317 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::AND[tvlL][tvlR] );
322 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent ), tvlR = QgsExpressionUtils::getTVLValue( vR, parent );
324 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::OR[tvlL][tvlR] );
333 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
337 else if ( QgsExpressionUtils::isList( vL ) || QgsExpressionUtils::isList( vR ) )
340 if ( !QgsExpressionUtils::isList( vL ) || !QgsExpressionUtils::isList( vR ) )
344 QVariantList lL = vL.toList();
345 QVariantList lR = vR.toList();
346 for (
int i = 0; i < lL.length() && i < lR.length(); i++ )
348 if ( QgsExpressionUtils::isNull( lL.at( i ) ) && QgsExpressionUtils::isNull( lR.at( i ) ) )
351 if ( QgsExpressionUtils::isNull( lL.at( i ) ) || QgsExpressionUtils::isNull( lR.at( i ) ) )
361 return QgsExpressionUtils::isNull( lR.at( i ) );
364 return QgsExpressionUtils::isNull( lL.at( i ) );
374 QVariant eq = eqNode.
eval( parent, context );
376 if ( eq == TVL_False )
380 QVariant v = node.
eval( parent, context );
390 return lL.length() == lR.length();
392 return lL.length() != lR.length();
394 return lL.length() < lR.length();
396 return lL.length() > lR.length();
398 return lL.length() <= lR.length();
400 return lL.length() >= lR.length();
406 else if ( ( vL.type() == QVariant::DateTime && vR.type() == QVariant::DateTime ) )
408 QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent );
410 QDateTime dR = QgsExpressionUtils::getDateTimeValue( vR, parent );
417 dL.setTimeSpec( Qt::UTC );
418 dR.setTimeSpec( Qt::UTC );
420 return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False;
422 else if ( ( vL.type() == QVariant::Date && vR.type() == QVariant::Date ) )
424 const QDate dL = QgsExpressionUtils::getDateValue( vL, parent );
426 const QDate dR = QgsExpressionUtils::getDateValue( vR, parent );
428 return compare( dR.daysTo( dL ) ) ? TVL_True : TVL_False;
430 else if ( ( vL.type() == QVariant::Time && vR.type() == QVariant::Time ) )
432 const QTime dL = QgsExpressionUtils::getTimeValue( vL, parent );
434 const QTime dR = QgsExpressionUtils::getTimeValue( vR, parent );
436 return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False;
438 else if ( ( vL.type() != QVariant::String || vR.type() != QVariant::String ) &&
439 QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) )
443 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
445 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
447 return compare( fL - fR ) ? TVL_True : TVL_False;
452 double fL = QgsExpressionUtils::getInterval( vL, parent ).seconds();
454 double fR = QgsExpressionUtils::getInterval( vR, parent ).seconds();
456 return compare( fL - fR ) ? TVL_True : TVL_False;
461 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
463 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
465 int diff = QString::compare( sL, sR );
466 return compare( diff ) ? TVL_True : TVL_False;
471 if ( QgsExpressionUtils::isNull( vL ) && QgsExpressionUtils::isNull( vR ) )
472 return ( mOp == boIs ? TVL_True : TVL_False );
473 else if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
474 return ( mOp == boIs ? TVL_False : TVL_True );
478 if ( QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) &&
479 ( vL.type() != QVariant::String || vR.type() != QVariant::String ) )
481 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
483 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
489 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
491 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
493 equal = QString::compare( sL, sR ) == 0;
496 return mOp == boIs ? TVL_True : TVL_False;
498 return mOp == boIs ? TVL_False : TVL_True;
506 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
510 QString str = QgsExpressionUtils::getStringValue( vL, parent );
512 QString regexp = QgsExpressionUtils::getStringValue( vR, parent );
516 if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp == boNotILike )
518 QString esc_regexp = QRegExp::escape( regexp );
520 if ( esc_regexp.startsWith(
'%' ) )
522 esc_regexp.replace( 0, 1, QStringLiteral(
".*" ) );
524 QRegExp rx(
"[^\\\\](%)" );
526 while ( ( pos = rx.indexIn( esc_regexp, pos ) ) != -1 )
528 esc_regexp.replace( pos + 1, 1, QStringLiteral(
".*" ) );
531 rx.setPattern( QStringLiteral(
"\\\\%" ) );
532 esc_regexp.replace( rx, QStringLiteral(
"%" ) );
533 if ( esc_regexp.startsWith(
'_' ) )
535 esc_regexp.replace( 0, 1, QStringLiteral(
"." ) );
537 rx.setPattern( QStringLiteral(
"[^\\\\](_)" ) );
539 while ( ( pos = rx.indexIn( esc_regexp, pos ) ) != -1 )
541 esc_regexp.replace( pos + 1, 1,
'.' );
544 rx.setPattern( QStringLiteral(
"\\\\_" ) );
545 esc_regexp.replace( rx, QStringLiteral(
"_" ) );
546 matches = QRegExp( esc_regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
550 matches = QRegExp( regexp ).indexIn( str ) != -1;
553 if ( mOp == boNotLike || mOp == boNotILike )
558 return matches ? TVL_True : TVL_False;
562 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
566 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
568 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
570 return QVariant( sL + sR );
580 bool QgsExpressionNodeBinaryOperator::compare(
double diff )
602 qlonglong QgsExpressionNodeBinaryOperator::computeInt( qlonglong x, qlonglong y )
622 QDateTime QgsExpressionNodeBinaryOperator::computeDateTimeFromInterval(
const QDateTime &d,
QgsInterval *i )
627 return d.addSecs( i->
seconds() );
629 return d.addSecs( -i->
seconds() );
636 double QgsExpressionNodeBinaryOperator::computeDouble(
double x,
double y )
649 return std::fmod( x, y );
663 bool resL = mOpLeft->prepare( parent, context );
664 bool resR = mOpRight->prepare( parent, context );
710 Q_ASSERT(
false &&
"unexpected binary operator" );
746 Q_ASSERT(
false &&
"unexpected binary operator" );
756 QString rdump( mOpRight->dump() );
761 rdump.prepend(
'(' ).append(
')' );
765 if ( leftAssociative() )
767 fmt += lOp && ( lOp->
precedence() < precedence() ) ? QStringLiteral(
"(%1)" ) : QStringLiteral(
"%1" );
768 fmt += QLatin1String(
" %2 " );
769 fmt += rOp && ( rOp->
precedence() <= precedence() ) ? QStringLiteral(
"(%3)" ) : QStringLiteral(
"%3" );
773 fmt += lOp && ( lOp->
precedence() <= precedence() ) ? QStringLiteral(
"(%1)" ) : QStringLiteral(
"%1" );
774 fmt += QLatin1String(
" %2 " );
775 fmt += rOp && ( rOp->
precedence() < precedence() ) ? QStringLiteral(
"(%3)" ) : QStringLiteral(
"%3" );
778 return fmt.arg( mOpLeft->dump(), BINARY_OPERATOR_TEXT[mOp], rdump );
783 return mOpLeft->referencedColumns() + mOpRight->referencedColumns();
788 return mOpLeft->referencedVariables() + mOpRight->referencedVariables();
793 return mOpLeft->referencedFunctions() + mOpRight->referencedFunctions();
798 QList<const QgsExpressionNode *> lst;
800 lst += mOpLeft->nodes() + mOpRight->nodes();
806 return mOpLeft->needsGeometry() || mOpRight->needsGeometry();
818 return mOpLeft->isStatic( parent, context ) && mOpRight->isStatic( parent, context );
825 if ( mList->count() == 0 )
826 return mNotIn ? TVL_True : TVL_False;
827 QVariant v1 = mNode->eval( parent, context );
829 if ( QgsExpressionUtils::isNull( v1 ) )
832 bool listHasNull =
false;
834 const QList< QgsExpressionNode * > nodeList = mList->list();
837 QVariant v2 = n->eval( parent, context );
839 if ( QgsExpressionUtils::isNull( v2 ) )
845 if ( ( v1.type() != QVariant::String || v2.type() != QVariant::String ) &&
846 QgsExpressionUtils::isDoubleSafe( v1 ) && QgsExpressionUtils::isDoubleSafe( v2 ) )
850 double f1 = QgsExpressionUtils::getDoubleValue( v1, parent );
852 double f2 = QgsExpressionUtils::getDoubleValue( v2, parent );
858 QString s1 = QgsExpressionUtils::getStringValue( v1, parent );
860 QString s2 = QgsExpressionUtils::getStringValue( v2, parent );
862 equal = QString::compare( s1, s2 ) == 0;
866 return mNotIn ? TVL_False : TVL_True;
874 return mNotIn ? TVL_True : TVL_False;
890 bool res = mNode->prepare( parent, context );
891 const QList< QgsExpressionNode * > nodeList = mList->list();
894 res = res && n->prepare( parent, context );
901 return QStringLiteral(
"%1 %2 IN (%3)" ).arg( mNode->dump(), mNotIn ?
"NOT" :
"", mList->dump() );
913 if ( !mNode->isStatic( parent, context ) )
916 const QList< QgsExpressionNode * > nodeList = mList->list();
919 if ( !n->isStatic( parent, context ) )
930 QString name = QgsExpression::QgsExpression::Functions()[mFnIndex]->name();
933 QVariant res = fd->
run( mArgs, context, parent,
this );
941 : mFnIndex( fnIndex )
944 if ( !
args || functionParams.isEmpty() )
955 while ( idx < args->names().size() &&
args->
names().at( idx ).isEmpty() )
962 for ( ; idx < functionParams.count(); ++idx )
964 int nodeIdx =
args->
names().indexOf( functionParams.at( idx ).name().toLower() );
994 bool res = fd->
prepare(
this, parent, context );
997 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1000 res = res && n->prepare( parent, context );
1010 return QStringLiteral(
"%1%2" ).arg( fd->
name(), fd->
name().startsWith(
'$' ) ?
"" :
"()" );
1012 return QStringLiteral(
"%1(%2)" ).arg( fd->
name(), mArgs ? mArgs->
dump() : QString() );
1023 return functionColumns;
1027 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1030 if ( fd->
parameters().count() <= paramIndex || !fd->
parameters().at( paramIndex ).isSubExpression() )
1031 functionColumns.unite( n->referencedColumns() );
1035 return functionColumns;
1041 if ( fd->
name() == QLatin1String(
"var" ) )
1043 if ( !mArgs->
list().isEmpty() )
1047 return QSet<QString>() << var->
value().toString();
1049 return QSet<QString>() << QString();
1053 QSet<QString> functionVariables = QSet<QString>();
1056 return functionVariables;
1058 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1061 functionVariables.unite( n->referencedVariables() );
1064 return functionVariables;
1071 QSet<QString> functions = QSet<QString>();
1072 functions.insert( fd->
name() );
1077 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1080 functions.unite( n->referencedFunctions() );
1087 QList<const QgsExpressionNode *> lst;
1092 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1102 bool needs = QgsExpression::QgsExpression::Functions()[mFnIndex]->usesGeometry(
this );
1105 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1107 needs |= n->needsGeometry();
1130 if ( functionParams.isEmpty() )
1137 QSet< int > providedArgs;
1138 QSet< int > handledArgs;
1141 while (
args->
names().at( idx ).isEmpty() )
1143 providedArgs << idx;
1149 for ( ; idx < functionParams.count(); ++idx )
1151 int nodeIdx =
args->
names().indexOf( functionParams.at( idx ).name().toLower() );
1154 if ( !functionParams.at( idx ).optional() )
1156 error = QStringLiteral(
"No value specified for QgsExpressionFunction::Parameter '%1' for %2" ).arg( functionParams.at( idx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1162 if ( providedArgs.contains( idx ) )
1164 error = QStringLiteral(
"Duplicate QgsExpressionFunction::Parameter specified for '%1' for %2" ).arg( functionParams.at( idx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1168 providedArgs << idx;
1169 handledArgs << nodeIdx;
1174 const QStringList nameList =
args->
names();
1175 for (
const QString &name : nameList )
1177 if ( !name.isEmpty() && !functionParams.contains( name ) )
1182 if ( !name.isEmpty() && !handledArgs.contains( idx ) )
1184 int functionIdx = functionParams.indexOf( name );
1185 if ( providedArgs.contains( functionIdx ) )
1187 error = QStringLiteral(
"Duplicate QgsExpressionFunction::Parameter specified for '%1' for %2" ).arg( functionParams.at( functionIdx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1222 if ( mValue.isNull() )
1223 return QStringLiteral(
"NULL" );
1225 switch ( mValue.type() )
1228 return QString::number( mValue.toInt() );
1229 case QVariant::Double:
1230 return QString::number( mValue.toDouble() );
1231 case QVariant::LongLong:
1232 return QString::number( mValue.toLongLong() );
1233 case QVariant::String:
1235 case QVariant::Bool:
1236 return mValue.toBool() ? QStringLiteral(
"TRUE" ) : QStringLiteral(
"FALSE" );
1238 return tr(
"[unsupported type: %1; value: %2]" ).arg( mValue.typeName(), mValue.toString() );
1244 return QSet<QString>();
1249 return QSet<QString>();
1254 return QSet<QString>();
1259 QList<const QgsExpressionNode *> lst;
1349 return QSet<QString>() << mName;
1354 return QSet<QString>();
1359 return QSet<QString>();
1364 QList<const QgsExpressionNode *> result;
1391 : mConditions( *conditions )
1392 , mElseExp( elseExp )
1400 qDeleteAll( mConditions );
1410 for (
WhenThen *cond : qgis::as_const( mConditions ) )
1412 QVariant vWhen = cond->mWhenExp->eval( parent, context );
1413 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( vWhen, parent );
1415 if ( tvl == QgsExpressionUtils::True )
1417 QVariant vRes = cond->mThenExp->eval( parent, context );
1425 QVariant vElse = mElseExp->
eval( parent, context );
1437 for (
WhenThen *cond : qgis::as_const( mConditions ) )
1439 res = cond->mWhenExp->prepare( parent, context )
1440 & cond->mThenExp->prepare( parent, context );
1446 return mElseExp->
prepare( parent, context );
1453 QString msg( QStringLiteral(
"CASE" ) );
1454 for (
WhenThen *cond : mConditions )
1456 msg += QStringLiteral(
" WHEN %1 THEN %2" ).arg( cond->mWhenExp->dump(), cond->mThenExp->dump() );
1459 msg += QStringLiteral(
" ELSE %1" ).arg( mElseExp->
dump() );
1460 msg += QStringLiteral(
" END" );
1467 for (
WhenThen *cond : mConditions )
1469 lst += cond->mWhenExp->referencedColumns() + cond->mThenExp->referencedColumns();
1481 for (
WhenThen *cond : mConditions )
1483 lst += cond->mWhenExp->referencedVariables() + cond->mThenExp->referencedVariables();
1495 for (
WhenThen *cond : mConditions )
1497 lst += cond->mWhenExp->referencedFunctions() + cond->mThenExp->referencedFunctions();
1508 QList<const QgsExpressionNode *> lst;
1510 for (
WhenThen *cond : mConditions )
1512 lst += cond->mWhenExp->nodes() + cond->mThenExp->nodes();
1516 lst += mElseExp->
nodes();
1523 for (
WhenThen *cond : mConditions )
1525 if ( cond->mWhenExp->needsGeometry() ||
1526 cond->mThenExp->needsGeometry() )
1548 if ( !wt->mWhenExp->isStatic( parent, context ) || !wt->mThenExp->isStatic( parent, context ) )
1553 return mElseExp->
isStatic( parent, context );
1561 const QList< QgsExpressionNode * > nodeList = mList->
list();
1563 lst.unite( n->referencedColumns() );
1570 const QList< QgsExpressionNode * > nodeList = mList->
list();
1572 lst.unite( n->referencedVariables() );
1579 const QList< QgsExpressionNode * > nodeList = mList->
list();
1581 lst.unite( n->referencedFunctions() );
1587 QList<const QgsExpressionNode *> lst;
1589 const QList< QgsExpressionNode * > nodeList = mList->
list();
1596 : mWhenExp( whenExp )
1597 , mThenExp( thenExp )
1609 return new WhenThen( mWhenExp->clone(), mThenExp->clone() );
1614 return BINARY_OPERATOR_TEXT[mOp];
1621 const QVariant container = mContainer->eval( parent, context );
1623 const QVariant index = mIndex->eval( parent, context );
1626 switch ( container.type() )
1629 return QgsExpressionUtils::getMapValue( container, parent ).value( index.toString() );
1631 case QVariant::List:
1632 case QVariant::StringList:
1634 const QVariantList list = QgsExpressionUtils::getListValue( container, parent );
1635 qlonglong pos = QgsExpressionUtils::getIntValue( index, parent );
1636 if ( pos >= list.length() || pos < -list.length() )
1643 pos += list.length();
1646 return list.at( pos );
1662 bool resC = mContainer->prepare( parent, context );
1663 bool resV = mIndex->prepare( parent, context );
1664 return resC && resV;
1669 return QStringLiteral(
"%1[%2]" ).arg( mContainer->dump(), mIndex->dump() );
1674 return mContainer->referencedColumns() + mIndex->referencedColumns();
1679 return mContainer->referencedVariables() + mIndex->referencedVariables();
1684 return mContainer->referencedFunctions() + mIndex->referencedFunctions();
1689 QList<const QgsExpressionNode *> lst;
1691 lst += mContainer->nodes() + mIndex->nodes();
1697 return mContainer->needsGeometry() || mIndex->needsGeometry();
1709 return mContainer->isStatic( parent, context ) && mIndex->isStatic( parent, context );