26#include <QRegularExpression>
28const char *QgsExpressionNodeBinaryOperator::BINARY_OPERATOR_TEXT[] =
32 "=",
"<>",
"<=",
">=",
"<",
">",
"~",
"LIKE",
"NOT LIKE",
"ILIKE",
"NOT ILIKE",
"IS",
"IS NOT",
33 "+",
"-",
"*",
"/",
"//",
"%",
"^",
37const char *QgsExpressionNodeUnaryOperator::UNARY_OPERATOR_TEXT[] =
46 const QList< QgsExpressionNode * > nodeList = mList->
list();
48 needs |= n->needsGeometry();
59 mList.append( node->
node );
60 mNameList.append( cleanNamedNodeName( node->
name ) );
61 mHasNamedNodes =
true;
70 nl->mList.append( node->clone() );
72 nl->mNameList = mNameList;
83 if ( !first ) msg += QLatin1String(
", " );
90QString QgsExpressionNode::NodeList::cleanNamedNodeName(
const QString &name )
92 QString cleaned = name.toLower();
95 if ( cleaned == QLatin1String(
"geom" ) )
96 cleaned = QStringLiteral(
"geometry" );
97 else if ( cleaned == QLatin1String(
"val" ) )
98 cleaned = QStringLiteral(
"value" );
99 else if ( cleaned == QLatin1String(
"geometry a" ) )
100 cleaned = QStringLiteral(
"geometry1" );
101 else if ( cleaned == QLatin1String(
"geometry b" ) )
102 cleaned = QStringLiteral(
"geometry2" );
103 else if ( cleaned == QLatin1String(
"i" ) )
104 cleaned = QStringLiteral(
"vertex" );
114 QVariant val = mOperand->eval( parent, context );
121 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( val, parent );
123 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::NOT[tvl] );
127 if ( QgsExpressionUtils::isIntSafe( val ) )
128 return QVariant( - QgsExpressionUtils::getIntValue( val, parent ) );
129 else if ( QgsExpressionUtils::isDoubleSafe( val ) )
130 return QVariant( - QgsExpressionUtils::getDoubleValue( val, parent ) );
144 return mOperand->prepare( parent, context );
150 return QStringLiteral(
"%1 ( %2 )" ).arg( UNARY_OPERATOR_TEXT[mOp], mOperand->dump() );
152 return QStringLiteral(
"%1 %2" ).arg( UNARY_OPERATOR_TEXT[mOp], mOperand->dump() );
158 return QSet< QString >();
160 return mOperand->referencedColumns();
165 return mOperand->referencedVariables();
170 return mOperand->referencedFunctions();
175 QList<const QgsExpressionNode *> lst;
177 lst += mOperand->nodes();
183 return mOperand->needsGeometry();
195 return mOperand->
isStatic( parent, context );
200 return UNARY_OPERATOR_TEXT[mOp];
207 QVariant vL = mOpLeft->eval( parent, context );
210 if ( mOp == boAnd || mOp == boOr )
212 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent );
214 if ( mOp == boAnd && tvlL == QgsExpressionUtils::False )
216 if ( mOp == boOr && tvlL == QgsExpressionUtils::True )
220 QVariant vR = mOpRight->eval( parent, context );
226 if ( vL.userType() == QMetaType::Type::QString && vR.userType() == QMetaType::Type::QString )
228 QString sL = QgsExpressionUtils::isNull( vL ) ? QString() : QgsExpressionUtils::getStringValue( vL, parent );
230 QString sR = QgsExpressionUtils::isNull( vR ) ? QString() : QgsExpressionUtils::getStringValue( vR, parent );
232 return QVariant( sL + sR );
241 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
243 else if ( mOp != boDiv && QgsExpressionUtils::isIntSafe( vL ) && QgsExpressionUtils::isIntSafe( vR ) )
246 qlonglong iL = QgsExpressionUtils::getIntValue( vL, parent );
248 qlonglong iR = QgsExpressionUtils::getIntValue( vR, parent );
251 if ( mOp == boMod && iR == 0 )
254 return QVariant( computeInt( iL, iR ) );
256 else if ( QgsExpressionUtils::isDateTimeSafe( vL ) && QgsExpressionUtils::isIntervalSafe( vR ) )
258 QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent );
260 QgsInterval iL = QgsExpressionUtils::getInterval( vR, parent );
262 if ( mOp == boDiv || mOp == boMul || mOp == boMod )
264 parent->
setEvalErrorString( tr(
"Can't perform /, *, or % on DateTime and Interval" ) );
267 return QVariant( computeDateTimeFromInterval( dL, &iL ) );
269 else if ( mOp == boPlus && ( ( vL.userType() == QMetaType::Type::QDate && vR.userType() == QMetaType::Type::QTime ) ||
270 ( vR.userType() == QMetaType::Type::QDate && vL.userType() == QMetaType::Type::QTime ) ) )
272 QDate date = QgsExpressionUtils::getDateValue( vL.userType() == QMetaType::Type::QDate ? vL : vR, parent );
274 QTime time = QgsExpressionUtils::getTimeValue( vR.userType() == QMetaType::Type::QTime ? vR : vL, parent );
276 QDateTime dt = QDateTime( date, time );
277 return QVariant( dt );
279 else if ( mOp == boMinus && vL.userType() == QMetaType::Type::QDate && vR.userType() == QMetaType::Type::QDate )
281 QDate date1 = QgsExpressionUtils::getDateValue( vL, parent );
283 QDate date2 = QgsExpressionUtils::getDateValue( vR, parent );
285 return date1 - date2;
287 else if ( mOp == boMinus && vL.userType() == QMetaType::Type::QTime && vR.userType() == QMetaType::Type::QTime )
289 QTime time1 = QgsExpressionUtils::getTimeValue( vL, parent );
291 QTime time2 = QgsExpressionUtils::getTimeValue( vR, parent );
293 return time1 - time2;
295 else if ( mOp == boMinus && vL.userType() == QMetaType::Type::QDateTime && vR.userType() == QMetaType::Type::QDateTime )
297 QDateTime datetime1 = QgsExpressionUtils::getDateTimeValue( vL, parent );
299 QDateTime datetime2 = QgsExpressionUtils::getDateTimeValue( vR, parent );
306 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
308 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
310 if ( ( mOp == boDiv || mOp == boMod ) && fR == 0. )
312 return QVariant( computeDouble( fL, fR ) );
318 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
320 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
324 return QVariant( qlonglong( std::floor( fL / fR ) ) );
327 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
331 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
333 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
335 return QVariant( std::pow( fL, fR ) );
340 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent ), tvlR = QgsExpressionUtils::getTVLValue( vR, parent );
342 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::AND[tvlL][tvlR] );
347 QgsExpressionUtils::TVL tvlL = QgsExpressionUtils::getTVLValue( vL, parent ), tvlR = QgsExpressionUtils::getTVLValue( vR, parent );
349 return QgsExpressionUtils::tvl2variant( QgsExpressionUtils::OR[tvlL][tvlR] );
358 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
362 else if ( QgsExpressionUtils::isList( vL ) || QgsExpressionUtils::isList( vR ) )
365 if ( !QgsExpressionUtils::isList( vL ) || !QgsExpressionUtils::isList( vR ) )
369 QVariantList lL = vL.toList();
370 QVariantList lR = vR.toList();
371 for (
int i = 0; i < lL.length() && i < lR.length(); i++ )
373 if ( QgsExpressionUtils::isNull( lL.at( i ) ) && QgsExpressionUtils::isNull( lR.at( i ) ) )
376 if ( QgsExpressionUtils::isNull( lL.at( i ) ) || QgsExpressionUtils::isNull( lR.at( i ) ) )
386 return QgsExpressionUtils::isNull( lR.at( i ) );
389 return QgsExpressionUtils::isNull( lL.at( i ) );
399 QVariant eq = eqNode.
eval( parent, context );
401 if ( eq == TVL_False )
405 QVariant v = node.
eval( parent, context );
415 return lL.length() == lR.length();
417 return lL.length() != lR.length();
419 return lL.length() < lR.length();
421 return lL.length() > lR.length();
423 return lL.length() <= lR.length();
425 return lL.length() >= lR.length();
431 else if ( ( vL.userType() == QMetaType::Type::QDateTime && vR.userType() == QMetaType::Type::QDateTime ) )
433 QDateTime dL = QgsExpressionUtils::getDateTimeValue( vL, parent );
435 QDateTime dR = QgsExpressionUtils::getDateTimeValue( vR, parent );
442 dL.setTimeSpec( Qt::UTC );
443 dR.setTimeSpec( Qt::UTC );
445 return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False;
447 else if ( ( vL.userType() == QMetaType::Type::QDate && vR.userType() == QMetaType::Type::QDate ) )
449 const QDate dL = QgsExpressionUtils::getDateValue( vL, parent );
451 const QDate dR = QgsExpressionUtils::getDateValue( vR, parent );
453 return compare( dR.daysTo( dL ) ) ? TVL_True : TVL_False;
455 else if ( ( vL.userType() == QMetaType::Type::QTime && vR.userType() == QMetaType::Type::QTime ) )
457 const QTime dL = QgsExpressionUtils::getTimeValue( vL, parent );
459 const QTime dR = QgsExpressionUtils::getTimeValue( vR, parent );
461 return compare( dR.msecsTo( dL ) ) ? TVL_True : TVL_False;
463 else if ( ( vL.userType() != QMetaType::Type::QString || vR.userType() != QMetaType::Type::QString ) &&
464 QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) )
468 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
470 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
472 return compare( fL - fR ) ? TVL_True : TVL_False;
475 else if ( vL.userType() == QMetaType::Type::Bool || vR.userType() == QMetaType::Type::Bool )
481 if ( vL.userType() == QMetaType::Type::Bool && vR.userType() == QMetaType::Type::Bool )
482 return vL.toBool() == vR.toBool() ? TVL_True : TVL_False;
487 else if ( vL.userType() == qMetaTypeId< QgsInterval>() && vR.userType() == qMetaTypeId< QgsInterval>() )
489 double fL = QgsExpressionUtils::getInterval( vL, parent ).seconds();
491 double fR = QgsExpressionUtils::getInterval( vR, parent ).seconds();
493 return compare( fL - fR ) ? TVL_True : TVL_False;
498 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
500 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
502 int diff = QString::compare( sL, sR );
503 return compare( diff ) ? TVL_True : TVL_False;
508 if ( QgsExpressionUtils::isNull( vL ) && QgsExpressionUtils::isNull( vR ) )
509 return ( mOp == boIs ? TVL_True : TVL_False );
510 else if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
511 return ( mOp == boIs ? TVL_False : TVL_True );
515 if ( QgsExpressionUtils::isDoubleSafe( vL ) && QgsExpressionUtils::isDoubleSafe( vR ) &&
516 ( vL.userType() != QMetaType::Type::QString || vR.userType() != QMetaType::Type::QString ) )
518 double fL = QgsExpressionUtils::getDoubleValue( vL, parent );
520 double fR = QgsExpressionUtils::getDoubleValue( vR, parent );
526 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
528 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
530 equal = QString::compare( sL, sR ) == 0;
533 return mOp == boIs ? TVL_True : TVL_False;
535 return mOp == boIs ? TVL_False : TVL_True;
543 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
547 QString
str = QgsExpressionUtils::getStringValue( vL, parent );
549 QString regexp = QgsExpressionUtils::getStringValue( vR, parent );
553 if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp == boNotILike )
557 if ( esc_regexp.startsWith(
'%' ) )
559 esc_regexp.replace( 0, 1, QStringLiteral(
".*" ) );
561 const thread_local QRegularExpression rx1( QStringLiteral(
"[^\\\\](%)" ) );
563 while ( ( pos = esc_regexp.indexOf( rx1, pos ) ) != -1 )
565 esc_regexp.replace( pos + 1, 1, QStringLiteral(
".*" ) );
568 const thread_local QRegularExpression rx2( QStringLiteral(
"\\\\%" ) );
569 esc_regexp.replace( rx2, QStringLiteral(
"%" ) );
570 if ( esc_regexp.startsWith(
'_' ) )
572 esc_regexp.replace( 0, 1, QStringLiteral(
"." ) );
574 const thread_local QRegularExpression rx3( QStringLiteral(
"[^\\\\](_)" ) );
576 while ( ( pos = esc_regexp.indexOf( rx3, pos ) ) != -1 )
578 esc_regexp.replace( pos + 1, 1,
'.' );
581 esc_regexp.replace( QLatin1String(
"\\\\_" ), QLatin1String(
"_" ) );
583 matches = QRegularExpression( QRegularExpression::anchoredPattern( esc_regexp ), mOp == boLike || mOp == boNotLike ? QRegularExpression::DotMatchesEverythingOption : QRegularExpression::DotMatchesEverythingOption | QRegularExpression::CaseInsensitiveOption ).match(
str ).hasMatch();
587 matches = QRegularExpression( regexp ).match(
str ).hasMatch();
590 if ( mOp == boNotLike || mOp == boNotILike )
595 return matches ? TVL_True : TVL_False;
599 if ( QgsExpressionUtils::isNull( vL ) || QgsExpressionUtils::isNull( vR ) )
603 QString sL = QgsExpressionUtils::getStringValue( vL, parent );
605 QString sR = QgsExpressionUtils::getStringValue( vR, parent );
607 return QVariant( sL + sR );
614bool QgsExpressionNodeBinaryOperator::compare(
double diff )
636qlonglong QgsExpressionNodeBinaryOperator::computeInt( qlonglong x, qlonglong y )
656QDateTime QgsExpressionNodeBinaryOperator::computeDateTimeFromInterval(
const QDateTime &d,
QgsInterval *i )
661 return d.addSecs( i->
seconds() );
663 return d.addSecs( -i->
seconds() );
670double QgsExpressionNodeBinaryOperator::computeDouble(
double x,
double y )
683 return std::fmod( x, y );
697 bool resL = mOpLeft->prepare( parent, context );
698 bool resR = mOpRight->prepare( parent, context );
744 Q_ASSERT(
false &&
"unexpected binary operator" );
780 Q_ASSERT(
false &&
"unexpected binary operator" );
790 QString rdump( mOpRight->dump() );
795 rdump.prepend(
'(' ).append(
')' );
799 if ( leftAssociative() )
801 fmt += lOp && ( lOp->
precedence() < precedence() ) ? QStringLiteral(
"(%1)" ) : QStringLiteral(
"%1" );
802 fmt += QLatin1String(
" %2 " );
803 fmt += rOp && ( rOp->
precedence() <= precedence() ) ? QStringLiteral(
"(%3)" ) : QStringLiteral(
"%3" );
807 fmt += lOp && ( lOp->
precedence() <= precedence() ) ? QStringLiteral(
"(%1)" ) : QStringLiteral(
"%1" );
808 fmt += QLatin1String(
" %2 " );
809 fmt += rOp && ( rOp->
precedence() < precedence() ) ? QStringLiteral(
"(%3)" ) : QStringLiteral(
"%3" );
812 return fmt.arg( mOpLeft->dump(), BINARY_OPERATOR_TEXT[mOp], rdump );
818 return QSet< QString >();
820 return mOpLeft->referencedColumns() + mOpRight->referencedColumns();
825 return mOpLeft->referencedVariables() + mOpRight->referencedVariables();
830 return mOpLeft->referencedFunctions() + mOpRight->referencedFunctions();
835 QList<const QgsExpressionNode *> lst;
837 lst += mOpLeft->nodes() + mOpRight->nodes();
843 return mOpLeft->needsGeometry() || mOpRight->needsGeometry();
855 const bool leftStatic = mOpLeft->
isStatic( parent, context );
856 const bool rightStatic = mOpRight->isStatic( parent, context );
858 if ( leftStatic && rightStatic )
870 mOpLeft->prepare( parent, context );
871 if ( mOpLeft->hasCachedStaticValue() )
873 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( mOpLeft->cachedStaticValue(), parent );
874 if ( !parent->
hasEvalError() && tvl == QgsExpressionUtils::True )
882 else if ( rightStatic )
884 mOpRight->prepare( parent, context );
885 if ( mOpRight->hasCachedStaticValue() )
887 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( mOpRight->cachedStaticValue(), parent );
888 if ( !parent->
hasEvalError() && tvl == QgsExpressionUtils::True )
906 mOpLeft->prepare( parent, context );
907 if ( mOpLeft->hasCachedStaticValue() )
909 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( mOpLeft->cachedStaticValue(), parent );
910 if ( !parent->
hasEvalError() && tvl == QgsExpressionUtils::False )
918 else if ( rightStatic )
920 mOpRight->prepare( parent, context );
921 if ( mOpRight->hasCachedStaticValue() )
923 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( mOpRight->cachedStaticValue(), parent );
924 if ( !parent->
hasEvalError() && tvl == QgsExpressionUtils::False )
967 if ( mList->count() == 0 )
968 return mNotIn ? TVL_True : TVL_False;
969 QVariant v1 = mNode->eval( parent, context );
971 if ( QgsExpressionUtils::isNull( v1 ) )
974 bool listHasNull =
false;
976 const QList< QgsExpressionNode * > nodeList = mList->list();
979 QVariant v2 = n->eval( parent, context );
981 if ( QgsExpressionUtils::isNull( v2 ) )
987 if ( ( v1.userType() != QMetaType::Type::QString || v2.userType() != QMetaType::Type::QString ) &&
988 QgsExpressionUtils::isDoubleSafe( v1 ) && QgsExpressionUtils::isDoubleSafe( v2 ) )
992 double f1 = QgsExpressionUtils::getDoubleValue( v1, parent );
994 double f2 = QgsExpressionUtils::getDoubleValue( v2, parent );
1000 QString s1 = QgsExpressionUtils::getStringValue( v1, parent );
1002 QString s2 = QgsExpressionUtils::getStringValue( v2, parent );
1004 equal = QString::compare( s1, s2 ) == 0;
1008 return mNotIn ? TVL_False : TVL_True;
1016 return mNotIn ? TVL_True : TVL_False;
1032 bool res = mNode->prepare( parent, context );
1033 const QList< QgsExpressionNode * > nodeList = mList->list();
1036 res = res && n->prepare( parent, context );
1043 return QStringLiteral(
"%1 %2 IN (%3)" ).arg( mNode->dump(), mNotIn ?
"NOT" :
"", mList->dump() );
1055 if ( !mNode->isStatic( parent, context ) )
1058 const QList< QgsExpressionNode * > nodeList = mList->
list();
1061 if ( !n->isStatic( parent, context ) )
1072 QString name = QgsExpression::QgsExpression::Functions()[mFnIndex]->name();
1075 QVariant res = fd->
run( mArgs, context, parent,
this );
1083 : mFnIndex( fnIndex )
1088 QMutexLocker locker( &QgsExpression::QgsExpression::sFunctionsMutex );
1091 const int functionParamsSize = functionParams.size();
1092 if ( functionParams.isEmpty() )
1101 mArgs->
reserve( functionParamsSize );
1111 mArgs->
reserve( functionParamsSize );
1114 const QStringList argNames =
args->
names();
1115 const QList<QgsExpressionNode *> argList =
args->
list();
1118 const int argNamesSize = argNames.size();
1119 while ( idx < argNamesSize && argNames.at( idx ).isEmpty() )
1121 mArgs->
append( argList.at( idx )->clone() );
1127 for ( ; idx < functionParamsSize; ++idx )
1130 int nodeIdx = argNames.indexOf( parameter.
name().toLower() );
1138 mArgs->
append( argList.at( nodeIdx )->clone() );
1160 bool res = fd->
prepare(
this, parent, context );
1163 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1166 res = res && n->prepare( parent, context );
1176 return QStringLiteral(
"%1%2" ).arg( fd->
name(), fd->
name().startsWith(
'$' ) ? QString() : QStringLiteral(
"()" ) );
1178 return QStringLiteral(
"%1(%2)" ).arg( fd->
name(), mArgs ? mArgs->
dump() : QString() );
1184 return QSet< QString >();
1192 return functionColumns;
1196 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1199 if ( fd->
parameters().count() <= paramIndex || !fd->
parameters().at( paramIndex ).isSubExpression() )
1200 functionColumns.unite( n->referencedColumns() );
1204 return functionColumns;
1210 if ( fd->
name() == QLatin1String(
"var" ) )
1212 if ( !mArgs->
list().isEmpty() )
1216 return QSet<QString>() << var->
value().toString();
1218 return QSet<QString>() << QString();
1222 QSet<QString> functionVariables = QSet<QString>();
1225 return functionVariables;
1227 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1230 functionVariables.unite( n->referencedVariables() );
1233 return functionVariables;
1240 QSet<QString> functions = QSet<QString>();
1241 functions.insert( fd->
name() );
1246 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1249 functions.unite( n->referencedFunctions() );
1256 QList<const QgsExpressionNode *> lst;
1261 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1271 bool needs = QgsExpression::QgsExpression::Functions()[mFnIndex]->usesGeometry(
this );
1274 const QList< QgsExpressionNode * > nodeList = mArgs->
list();
1276 needs |= n->needsGeometry();
1299 if ( functionParams.isEmpty() )
1306 QSet< int > providedArgs;
1307 QSet< int > handledArgs;
1310 while (
args->
names().at( idx ).isEmpty() )
1312 providedArgs << idx;
1318 for ( ; idx < functionParams.count(); ++idx )
1320 int nodeIdx =
args->
names().indexOf( functionParams.at( idx ).name().toLower() );
1323 if ( !functionParams.at( idx ).optional() )
1325 error = QStringLiteral(
"No value specified for QgsExpressionFunction::Parameter '%1' for %2" ).arg( functionParams.at( idx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1331 if ( providedArgs.contains( idx ) )
1333 error = QStringLiteral(
"Duplicate QgsExpressionFunction::Parameter specified for '%1' for %2" ).arg( functionParams.at( idx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1337 providedArgs << idx;
1338 handledArgs << nodeIdx;
1343 const QStringList nameList =
args->
names();
1344 for (
const QString &name : nameList )
1346 if ( !name.isEmpty() && !functionParams.contains( name ) )
1351 if ( !name.isEmpty() && !handledArgs.contains( idx ) )
1353 int functionIdx = functionParams.indexOf( name );
1354 if ( providedArgs.contains( functionIdx ) )
1356 error = QStringLiteral(
"Duplicate QgsExpressionFunction::Parameter specified for '%1' for %2" ).arg( functionParams.at( functionIdx ).name(),
QgsExpression::Functions()[
fnIndex]->name() );
1392 return QStringLiteral(
"NULL" );
1394 switch ( mValue.userType() )
1396 case QMetaType::Type::Int:
1397 return QString::number( mValue.toInt() );
1398 case QMetaType::Type::Double:
1399 return QString::number( mValue.toDouble() );
1400 case QMetaType::Type::LongLong:
1401 return QString::number( mValue.toLongLong() );
1402 case QMetaType::Type::QString:
1404 case QMetaType::Type::QTime:
1406 case QMetaType::Type::QDate:
1408 case QMetaType::Type::QDateTime:
1410 case QMetaType::Type::Bool:
1411 return mValue.toBool() ? QStringLiteral(
"TRUE" ) : QStringLiteral(
"FALSE" );
1413 return tr(
"[unsupported type: %1; value: %2]" ).arg( mValue.typeName(), mValue.toString() );
1424 return QSet<QString>();
1429 return QSet<QString>();
1434 return QSet<QString>();
1439 QList<const QgsExpressionNode *> lst;
1492 parent->
setEvalErrorString( tr(
"No feature available for field '%1' evaluation" ).arg( mName ) );
1529 const thread_local QRegularExpression re( QStringLiteral(
"^[A-Za-z_\\x80-\\xff][A-Za-z0-9_\\x80-\\xff]*$" ) );
1530 const QRegularExpressionMatch match = re.match( mName );
1536 return QSet<QString>() << mName;
1541 return QSet<QString>();
1546 return QSet<QString>();
1551 QList<const QgsExpressionNode *> result;
1578 : mConditions( *conditions )
1579 , mElseExp( elseExp )
1587 qDeleteAll( mConditions );
1597 for (
WhenThen *cond : std::as_const( mConditions ) )
1599 QVariant vWhen = cond->mWhenExp->eval( parent, context );
1600 QgsExpressionUtils::TVL tvl = QgsExpressionUtils::getTVLValue( vWhen, parent );
1602 if ( tvl == QgsExpressionUtils::True )
1604 QVariant vRes = cond->mThenExp->eval( parent, context );
1612 QVariant vElse = mElseExp->
eval( parent, context );
1623 bool foundAnyNonStaticConditions =
false;
1624 for (
WhenThen *cond : std::as_const( mConditions ) )
1626 const bool res = cond->mWhenExp->prepare( parent, context )
1627 && cond->mThenExp->prepare( parent, context );
1631 foundAnyNonStaticConditions |= !cond->mWhenExp->hasCachedStaticValue();
1632 if ( !foundAnyNonStaticConditions && QgsExpressionUtils::getTVLValue( cond->mWhenExp->cachedStaticValue(), parent ) == QgsExpressionUtils::True )
1636 if ( cond->mThenExp->hasCachedStaticValue() )
1655 const bool res = mElseExp->
prepare( parent, context );
1659 if ( !foundAnyNonStaticConditions )
1683 QString msg( QStringLiteral(
"CASE" ) );
1684 for (
WhenThen *cond : mConditions )
1686 msg += QStringLiteral(
" WHEN %1 THEN %2" ).arg( cond->mWhenExp->dump(), cond->mThenExp->dump() );
1689 msg += QStringLiteral(
" ELSE %1" ).arg( mElseExp->
dump() );
1690 msg += QLatin1String(
" END" );
1697 return QSet< QString >();
1700 for (
WhenThen *cond : mConditions )
1702 lst += cond->mWhenExp->referencedColumns() + cond->mThenExp->referencedColumns();
1714 for (
WhenThen *cond : mConditions )
1716 lst += cond->mWhenExp->referencedVariables() + cond->mThenExp->referencedVariables();
1728 for (
WhenThen *cond : mConditions )
1730 lst += cond->mWhenExp->referencedFunctions() + cond->mThenExp->referencedFunctions();
1741 QList<const QgsExpressionNode *> lst;
1743 for (
WhenThen *cond : mConditions )
1745 lst += cond->mWhenExp->nodes() + cond->mThenExp->nodes();
1749 lst += mElseExp->
nodes();
1756 for (
WhenThen *cond : mConditions )
1758 if ( cond->mWhenExp->needsGeometry() ||
1759 cond->mThenExp->needsGeometry() )
1782 if ( !wt->mWhenExp->isStatic( parent, context ) || !wt->mThenExp->isStatic( parent, context ) )
1787 return mElseExp->
isStatic( parent, context );
1795 return QSet< QString >();
1798 const QList< QgsExpressionNode * > nodeList = mList->
list();
1800 lst.unite( n->referencedColumns() );
1807 const QList< QgsExpressionNode * > nodeList = mList->
list();
1809 lst.unite( n->referencedVariables() );
1816 const QList< QgsExpressionNode * > nodeList = mList->
list();
1818 lst.unite( n->referencedFunctions() );
1824 QList<const QgsExpressionNode *> lst;
1826 const QList< QgsExpressionNode * > nodeList = mList->
list();
1837 delete mHigherBound;
1847 bool res = mNode->
prepare( parent, context );
1848 res = res && mLowerBound->
prepare( parent, context );
1849 res = res && mHigherBound->
prepare( parent, context );
1855 const QVariant nodeVal = mNode->
eval( parent, context );
1864 const QVariant lowBoundValue = lowBound.
eval( parent, context );
1865 const bool lowBoundBool { lowBoundValue.toBool() };
1869 return QVariant( mNegate );
1873 const QVariant highBoundValue = highBound.
eval( parent, context );
1880 const bool highBoundBool { highBoundValue.toBool() };
1890 return QVariant( mNegate );
1900 return QVariant( mNegate );
1903 const bool res { lowBoundBool &&highBoundBool };
1904 return mNegate ? QVariant( ! res ) : QVariant( res );
1910 return QStringLiteral(
"%1 %2 %3 AND %4" ).arg( mNode->
dump(), mNegate ? QStringLiteral(
"NOT BETWEEN" ) : QStringLiteral(
"BETWEEN" ), mLowerBound->
dump(), mHigherBound->
dump() );
1931 return {
this, mLowerBound, mHigherBound };
1965 if ( !mNode->
isStatic( parent, context ) )
1968 if ( !mLowerBound->
isStatic( parent, context ) )
1971 if ( !mHigherBound->
isStatic( parent, context ) )
1984 return mHigherBound;
1993 : mWhenExp( whenExp )
1994 , mThenExp( thenExp )
2006 return new WhenThen( mWhenExp->clone(), mThenExp->clone() );
2011 return BINARY_OPERATOR_TEXT[mOp];
2018 const QVariant container = mContainer->eval( parent, context );
2020 const QVariant index = mIndex->eval( parent, context );
2023 switch ( container.userType() )
2025 case QMetaType::Type::QVariantMap:
2026 return QgsExpressionUtils::getMapValue( container, parent ).value( index.toString() );
2028 case QMetaType::Type::QVariantList:
2029 case QMetaType::Type::QStringList:
2031 const QVariantList list = QgsExpressionUtils::getListValue( container, parent );
2032 qlonglong pos = QgsExpressionUtils::getIntValue( index, parent );
2033 if ( pos >= list.length() || pos < -list.length() )
2040 pos += list.length();
2043 return list.at( pos );
2048 parent->
setEvalErrorString( tr(
"[] can only be used with map or array values, not %1" ).arg( QMetaType::typeName(
static_cast<QMetaType::Type
>( container.userType() ) ) ) );
2060 bool resC = mContainer->prepare( parent, context );
2061 bool resV = mIndex->prepare( parent, context );
2062 return resC && resV;
2067 return QStringLiteral(
"%1[%2]" ).arg( mContainer->dump(), mIndex->dump() );
2073 return QSet< QString >();
2075 return mContainer->referencedColumns() + mIndex->referencedColumns();
2080 return mContainer->referencedVariables() + mIndex->referencedVariables();
2085 return mContainer->referencedFunctions() + mIndex->referencedFunctions();
2090 QList<const QgsExpressionNode *> lst;
2092 lst += mContainer->nodes() + mIndex->nodes();
2098 return mContainer->needsGeometry() || mIndex->needsGeometry();
2110 return mContainer->
isStatic( parent, context ) && mIndex->isStatic( parent, context );
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool hasFunction(const QString &name) const
Checks whether a specified function is contained in the context.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
static const QString EXPR_FIELDS
Inbuilt variable name for fields storage.
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
QgsExpressionFunction * function(const QString &name) const
Fetches a matching function from the context.
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
bool hasFeature() const
Returns true if the context has a feature associated with it.
Represents a single parameter passed to a function.
QVariant defaultValue() const
Returns the default value for the parameter.
QString name() const
Returns the name of the parameter.
A abstract base class for defining QgsExpression functions.
QList< QgsExpressionFunction::Parameter > ParameterList
List of parameters, used for function definition.
int params() const
The number of parameters this function takes.
bool lazyEval() const
true if this function should use lazy evaluation.
QString name() const
The name of the function.
virtual QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Evaluates the function, first evaluating all required arguments before passing them to the function's...
const QgsExpressionFunction::ParameterList & parameters() const
Returns the list of named parameters for the function, if set.
virtual QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const
Returns a set of field names which are required for this function.
virtual bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
This will be called during the prepare step() of an expression if it is not static.
SQL-like BETWEEN and NOT BETWEEN predicates.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
bool negate() const
Returns true if the predicate is an exclusion test (NOT BETWEEN).
QgsExpressionNode * lowerBound() const
Returns the lower bound expression node of the range.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
QgsExpressionNode * clone() const override
Generate a clone of this node.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QgsExpressionNode * higherBound() const
Returns the higher bound expression node of the range.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
~QgsExpressionNodeBetweenOperator() override
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
A binary expression operator, which operates on two values.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
bool leftAssociative() const
Returns true if the operator is left-associative.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
int precedence() const
Returns the precedence index for the operator.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
QgsExpressionNode * clone() const override
Generate a clone of this node.
QString text() const
Returns a the name of this operator without the operands.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
An expression node which takes it value from a feature's field.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QgsExpressionNode * clone() const override
Generate a clone of this node.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
Represents a "WHEN... THEN..." portation of a CASE WHEN clause in an expression.
WhenThen(QgsExpressionNode *whenExp, QgsExpressionNode *thenExp)
A combination of when and then.
QgsExpressionNodeCondition::WhenThen * clone() const
Gets a deep copy of this WhenThen combination.
An expression node for CASE WHEN clauses.
QList< QgsExpressionNodeCondition::WhenThen * > WhenThenList
QgsExpressionNodeCondition(QgsExpressionNodeCondition::WhenThenList *conditions, QgsExpressionNode *elseExp=nullptr)
Create a new node with the given list of conditions and an optional elseExp expression.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
QgsExpressionNode * clone() const override
Generate a clone of this node.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
WhenThenList conditions() const
The list of WHEN THEN expression parts of the expression.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
~QgsExpressionNodeCondition() override
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
An expression node for expression functions.
int fnIndex() const
Returns the index of the node's function.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QgsExpressionNode::NodeList * args() const
Returns a list of arguments specified for the function.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
~QgsExpressionNodeFunction() override
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QgsExpressionNodeFunction(int fnIndex, QgsExpressionNode::NodeList *args)
A function node consists of an index of the function in the global function array and a list of argum...
QgsExpressionNode * clone() const override
Generate a clone of this node.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
static bool validateParams(int fnIndex, QgsExpressionNode::NodeList *args, QString &error)
Tests whether the provided argument list is valid for the matching function.
An expression node for value IN or NOT IN clauses.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
~QgsExpressionNodeInOperator() override
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
QgsExpressionNode * clone() const override
Generate a clone of this node.
QgsExpressionNode::NodeList * list() const
Returns the list of nodes to search for matching values within.
A indexing expression operator, which allows use of square brackets [] to reference map and array ite...
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QgsExpressionNode * clone() const override
Generate a clone of this node.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
An expression node for literal values.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QString valueAsString() const
Returns a string representation of the node's literal value.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QgsExpressionNode * clone() const override
Generate a clone of this node.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
QVariant value() const
The value of the literal.
A unary node is either negative as in boolean (not) or as in numbers (minus).
QgsExpressionNode::NodeType nodeType() const override
Gets the type of this node.
bool prepareNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QSet< QString > referencedFunctions() const override
Returns a set of all functions which are used in this expression.
QgsExpressionNodeUnaryOperator::UnaryOperator op() const
Returns the unary operator.
QSet< QString > referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node.
QList< const QgsExpressionNode * > nodes() const override
Returns a list of all nodes which are used in this expression.
QString text() const
Returns a the name of this operator without the operands.
bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const override
Returns true if this node can be evaluated for a static value.
QVariant evalNode(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression.
QgsExpressionNode * clone() const override
Generate a clone of this node.
QString dump() const override
Dump this node into a serialized (part) of an expression.
QSet< QString > referencedVariables() const override
Returns a set of all variables which are used in this expression.
A list of expression nodes.
bool hasNamedNodes() const
Returns true if list contains any named nodes.
virtual QString dump() const
Returns a string dump of the expression node.
QStringList names() const
Returns a list of names for nodes.
QgsExpressionNode::NodeList * clone() const
Creates a deep copy of this list. Ownership is transferred to the caller.
void append(QgsExpressionNode *node)
Takes ownership of the provided node.
void reserve(int size)
Reserves size for the node list.
QList< QgsExpressionNode * > list()
Gets a list of all the nodes.
Abstract base class for all nodes that can appear in an expression.
bool hasCachedStaticValue() const
Returns true if the node can be replaced by a static cached value.
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
QVariant eval(QgsExpression *parent, const QgsExpressionContext *context)
Evaluate this node with the given context and parent.
virtual QgsExpressionNode * clone() const =0
Generate a clone of this node.
virtual bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const =0
Returns true if this node can be evaluated for a static value.
bool prepare(QgsExpression *parent, const QgsExpressionContext *context)
Prepare this node for evaluation.
virtual QSet< QString > referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node.
bool mHasCachedValue
true if the node has a static, precalculated value.
const QgsExpressionNode * effectiveNode() const
Returns a reference to the simplest node which represents this node, after any compilation optimizati...
QVariant cachedStaticValue() const
Returns the node's static cached value.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
QVariant mCachedStaticValue
Contains the static, precalculated value for the node if mHasCachedValue is true.
std::unique_ptr< QgsExpressionNode > mCompiledSimplifiedNode
Contains a compiled node which represents a simplified version of this node as a result of compilatio...
NodeType
Known node types.
@ ntBetweenOperator
Between operator.
@ ntIndexOperator
Index operator.
virtual bool needsGeometry() const =0
Abstract virtual method which returns if the geometry is required to evaluate this expression.
virtual QList< const QgsExpressionNode * > nodes() const =0
Returns a list of all nodes which are used in this expression.
void cloneTo(QgsExpressionNode *target) const
Copies the members of this node to the node provided in target.
virtual QSet< QString > referencedFunctions() const =0
Returns a set of all functions which are used in this expression.
Class for parsing and evaluation of expressions (formerly called "search strings").
static const QList< QgsExpressionFunction * > & Functions()
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
void setEvalErrorString(const QString &str)
Sets evaluation error (used internally by evaluation functions)
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
int fieldNameIndex(const QString &fieldName) const
Utility method to get attribute index from name.
bool isValid() const
Returns the validity of this feature.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Container of fields for a vector layer.
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A representation of the interval between two datetime values.
double seconds() const
Returns the interval duration in seconds.
static QString qRegExpEscape(const QString &string)
Returns an escaped string matching the behavior of QRegExp::escape.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define ENSURE_NO_EVAL_ERROR
#define SET_EVAL_ERROR(x)
QgsExpressionNode * node
Node.