QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsexpression.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexpression.h
3  -------------------
4  begin : August 2011
5  copyright : (C) 2011 Martin Dobias
6  email : wonder.sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSEXPRESSION_H
17 #define QGSEXPRESSION_H
18 
19 #include <QMetaType>
20 #include <QStringList>
21 #include <QVariant>
22 #include <QList>
23 #include <QDomDocument>
24 
25 #include "qgsfield.h"
26 #include "qgsdistancearea.h"
27 
28 class QgsFeature;
29 class QgsGeometry;
30 class QgsOgcUtils;
31 class QgsVectorLayer;
33 
34 class QDomElement;
35 
89 class CORE_EXPORT QgsExpression
90 {
91  public:
92  QgsExpression( const QString& expr );
93  ~QgsExpression();
94 
96  bool hasParserError() const { return !mParserErrorString.isNull(); }
98  QString parserErrorString() const { return mParserErrorString; }
99 
100  class Node;
101 
103  const Node* rootNode() const { return mRootNode; }
104 
106  bool prepare( const QgsFields &fields );
107 
113  QStringList referencedColumns();
114 
116  bool needsGeometry();
117 
118  // evaluation
119 
122  QVariant evaluate( const QgsFeature* f = NULL );
123 
127  inline QVariant evaluate( const QgsFeature& f ) { return evaluate( &f ); }
128 
131  QVariant evaluate( const QgsFeature* f, const QgsFields& fields );
132 
136  inline QVariant evaluate( const QgsFeature& f, const QgsFields& fields ) { return evaluate( &f, fields ); }
137 
139  bool hasEvalError() const { return !mEvalErrorString.isNull(); }
141  QString evalErrorString() const { return mEvalErrorString; }
143  void setEvalErrorString( QString str ) { mEvalErrorString = str; }
144 
146  void setCurrentRowNumber( int rowNumber ) { mRowNumber = rowNumber; }
148  int currentRowNumber() { return mRowNumber; }
149 
151  static void setSpecialColumn( const QString& name, QVariant value );
153  static void unsetSpecialColumn( const QString& name );
155  static QVariant specialColumn( const QString& name );
158  static bool hasSpecialColumn( const QString& name );
159 
160  static bool isValid( const QString& text, const QgsFields& fields, QString &errorMessage );
161 
162  void setScale( double scale ) { mScale = scale; }
163 
164  double scale() { return mScale; }
165 
167  const QString expression() const { return dump(); }
168 
170  QString dump() const;
171 
174  QgsDistanceArea *geomCalculator() { initGeomCalculator(); return mCalc; }
175 
177  // instead of the default.
178  void setGeomCalculator( const QgsDistanceArea &calc );
179 
193  static QString replaceExpressionText( const QString &action, const QgsFeature *feat,
194  QgsVectorLayer *layer,
195  const QMap<QString, QVariant> *substitutionMap = 0,
196  const QgsDistanceArea* distanceArea = 0
197  );
199  {
202  };
204  {
205  // logical
208 
209  // comparison
210  boEQ, // =
211  boNE, // <>
212  boLE, // <=
213  boGE, // >=
214  boLT, // <
215  boGT, // >
223 
224  // math
231 
232  // strings
234  };
236  {
246  };
247 
248  static const char* BinaryOperatorText[];
249  static const char* UnaryOperatorText[];
250 
251  typedef QVariant( *FcnEval )( const QVariantList& values, const QgsFeature* f, QgsExpression* parent );
252 
253 
257  class CORE_EXPORT Function
258  {
259  public:
260  Function( QString fnname, int params, QString group, QString helpText = QString(), bool usesGeometry = false, QStringList referencedColumns = QStringList() )
261  : mName( fnname ), mParams( params ), mUsesGeometry( usesGeometry ), mGroup( group ), mHelpText( helpText ), mReferencedColumns( referencedColumns ) {}
263  QString name() { return mName; }
265  int params() { return mParams; }
267  bool usesgeometry() { return mUsesGeometry; }
268 
269  virtual QStringList referencedColumns() const { return mReferencedColumns; }
270 
272  QString group() { return mGroup; }
274  QString helptext() { return mHelpText.isEmpty() ? QgsExpression::helptext( mName ) : mHelpText; }
275 
276  virtual QVariant func( const QVariantList& values, const QgsFeature* f, QgsExpression* parent ) = 0;
277 
278  bool operator==( const Function& other ) const
279  {
280  if ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 )
281  return true;
282 
283  return false;
284  }
285 
286  private:
287  QString mName;
288  int mParams;
289  bool mUsesGeometry;
290  QString mGroup;
291  QString mHelpText;
292  QStringList mReferencedColumns;
293  };
294 
295  class StaticFunction : public Function
296  {
297  public:
298  StaticFunction( QString fnname, int params, FcnEval fcn, QString group, QString helpText = QString(), bool usesGeometry = false, QStringList referencedColumns = QStringList() )
299  : Function( fnname, params, group, helpText, usesGeometry, referencedColumns ), mFnc( fcn ) {}
300 
301  virtual QVariant func( const QVariantList& values, const QgsFeature* f, QgsExpression* parent )
302  {
303  return mFnc( values, f, parent );
304  }
305 
306  private:
307  FcnEval mFnc;
308  };
309 
310  static const QList<Function*> &Functions();
311  static QList<Function*> gmFunctions;
312 
313  static QStringList gmBuiltinFunctions;
314  static const QStringList &BuiltinFunctions();
315 
316  static bool registerFunction( Function* function );
317  static bool unregisterFunction( QString name );
318 
319  // tells whether the identifier is a name of existing function
320  static bool isFunctionName( QString name );
321 
322  // return index of the function in Functions array
323  static int functionIndex( QString name );
324 
328  static int functionCount();
329 
333  static QList<Function*> specialColumns();
334 
336  static QString quotedColumnRef( QString name );
338  static QString quotedString( QString text );
339 
341 
342  class Visitor; // visitor interface is defined below
343 
344  enum NodeType
345  {
352  ntCondition
353  };
354 
355  class CORE_EXPORT Node
356  {
357  public:
358  virtual ~Node() {}
359  virtual NodeType nodeType() const = 0;
360  // abstract virtual eval function
361  // errors are reported to the parent
362  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f ) = 0;
363 
364  // abstract virtual preparation function
365  // errors are reported to the parent
366  virtual bool prepare( QgsExpression* parent, const QgsFields &fields ) = 0;
367 
368  virtual QString dump() const = 0;
369 
370  virtual QStringList referencedColumns() const = 0;
371  virtual bool needsGeometry() const = 0;
372 
373  // support for visitor pattern
374  virtual void accept( Visitor& v ) const = 0;
375  };
376 
377  class CORE_EXPORT NodeList
378  {
379  public:
380  NodeList() {}
381  virtual ~NodeList() { qDeleteAll( mList ); }
382  void append( Node* node ) { mList.append( node ); }
383  int count() { return mList.count(); }
384  QList<Node*> list() { return mList; }
385 
386  virtual QString dump() const;
387 
388  protected:
389  QList<Node*> mList;
390  };
391 
392  class CORE_EXPORT Interval
393  {
394  // YEAR const value taken from postgres query
395  // SELECT EXTRACT(EPOCH FROM interval '1 year')
396  static const int YEARS = 31557600;
397  static const int MONTHS = 60 * 60 * 24 * 30;
398  static const int WEEKS = 60 * 60 * 24 * 7;
399  static const int DAY = 60 * 60 * 24;
400  static const int HOUR = 60 * 60;
401  static const int MINUTE = 60;
402  public:
403  Interval( double seconds = 0 ) : mSeconds( seconds ), mValid( true ) { }
404  ~Interval();
405  double years() { return mSeconds / YEARS;}
406  double months() { return mSeconds / MONTHS; }
407  double weeks() { return mSeconds / WEEKS;}
408  double days() { return mSeconds / DAY;}
409  double hours() { return mSeconds / HOUR;}
410  double minutes() { return mSeconds / MINUTE;}
411  double seconds() { return mSeconds; }
412  bool isValid() { return mValid; }
413  void setValid( bool valid ) { mValid = valid; }
414  bool operator==( const QgsExpression::Interval& other ) const;
415  static QgsExpression::Interval invalidInterVal();
416  static QgsExpression::Interval fromString( QString string );
417  private:
418  double mSeconds;
419  bool mValid;
420  };
421 
422  class CORE_EXPORT NodeUnaryOperator : public Node
423  {
424  public:
425  NodeUnaryOperator( UnaryOperator op, Node* operand ) : mOp( op ), mOperand( operand ) {}
426  ~NodeUnaryOperator() { delete mOperand; }
427 
428  UnaryOperator op() const { return mOp; }
429  Node* operand() const { return mOperand; }
430 
431  virtual NodeType nodeType() const { return ntUnaryOperator; }
432  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
433  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
434  virtual QString dump() const;
435 
436  virtual QStringList referencedColumns() const { return mOperand->referencedColumns(); }
437  virtual bool needsGeometry() const { return mOperand->needsGeometry(); }
438  virtual void accept( Visitor& v ) const { v.visit( *this ); }
439 
440  protected:
443  };
444 
445  class CORE_EXPORT NodeBinaryOperator : public Node
446  {
447  public:
448  NodeBinaryOperator( BinaryOperator op, Node* opLeft, Node* opRight ) : mOp( op ), mOpLeft( opLeft ), mOpRight( opRight ) {}
449  ~NodeBinaryOperator() { delete mOpLeft; delete mOpRight; }
450 
451  BinaryOperator op() const { return mOp; }
452  Node* opLeft() const { return mOpLeft; }
453  Node* opRight() const { return mOpRight; }
454 
455  virtual NodeType nodeType() const { return ntBinaryOperator; }
456  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
457  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
458  virtual QString dump() const;
459 
460  virtual QStringList referencedColumns() const { return mOpLeft->referencedColumns() + mOpRight->referencedColumns(); }
461  virtual bool needsGeometry() const { return mOpLeft->needsGeometry() || mOpRight->needsGeometry(); }
462  virtual void accept( Visitor& v ) const { v.visit( *this ); }
463 
464  int precedence() const;
465 
466  protected:
467  bool compare( double diff );
468  int computeInt( int x, int y );
469  double computeDouble( double x, double y );
470  QDateTime computeDateTimeFromInterval( QDateTime d, QgsExpression::Interval *i );
471 
475  };
476 
477  class CORE_EXPORT NodeInOperator : public Node
478  {
479  public:
480  NodeInOperator( Node* node, NodeList* list, bool notin = false ) : mNode( node ), mList( list ), mNotIn( notin ) {}
481  virtual ~NodeInOperator() { delete mNode; delete mList; }
482 
483  Node* node() const { return mNode; }
484  bool isNotIn() const { return mNotIn; }
485  NodeList* list() const { return mList; }
486 
487  virtual NodeType nodeType() const { return ntInOperator; }
488  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
489  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
490  virtual QString dump() const;
491 
492  virtual QStringList referencedColumns() const { QStringList lst( mNode->referencedColumns() ); foreach ( Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
493  virtual bool needsGeometry() const { bool needs = false; foreach ( Node* n, mList->list() ) needs |= n->needsGeometry(); return needs; }
494  virtual void accept( Visitor& v ) const { v.visit( *this ); }
495 
496  protected:
499  bool mNotIn;
500  };
501 
502  class CORE_EXPORT NodeFunction : public Node
503  {
504  public:
505  NodeFunction( int fnIndex, NodeList* args ) : mFnIndex( fnIndex ), mArgs( args ) {}
506  //NodeFunction( QString name, NodeList* args ) : mName(name), mArgs(args) {}
507  virtual ~NodeFunction() { delete mArgs; }
508 
509  int fnIndex() const { return mFnIndex; }
510  NodeList* args() const { return mArgs; }
511 
512  virtual NodeType nodeType() const { return ntFunction; }
513  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
514  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
515  virtual QString dump() const;
516 
517  virtual QStringList referencedColumns() const;
518  virtual bool needsGeometry() const { bool needs = Functions()[mFnIndex]->usesgeometry(); if ( mArgs ) { foreach ( Node* n, mArgs->list() ) needs |= n->needsGeometry(); } return needs; }
519  virtual void accept( Visitor& v ) const { v.visit( *this ); }
520 
521  protected:
522  //QString mName;
523  int mFnIndex;
525  };
526 
527  class CORE_EXPORT NodeLiteral : public Node
528  {
529  public:
530  NodeLiteral( QVariant value ) : mValue( value ) {}
531 
532  QVariant value() const { return mValue; }
533 
534  virtual NodeType nodeType() const { return ntLiteral; }
535  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
536  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
537  virtual QString dump() const;
538 
539  virtual QStringList referencedColumns() const { return QStringList(); }
540  virtual bool needsGeometry() const { return false; }
541  virtual void accept( Visitor& v ) const { v.visit( *this ); }
542 
543  protected:
544  QVariant mValue;
545  };
546 
547  class CORE_EXPORT NodeColumnRef : public Node
548  {
549  public:
550  NodeColumnRef( QString name ) : mName( name ), mIndex( -1 ) {}
551 
552  QString name() const { return mName; }
553 
554  virtual NodeType nodeType() const { return ntColumnRef; }
555  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
556  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
557  virtual QString dump() const;
558 
559  virtual QStringList referencedColumns() const { return QStringList( mName ); }
560  virtual bool needsGeometry() const { return false; }
561 
562  virtual void accept( Visitor& v ) const { v.visit( *this ); }
563 
564  protected:
565  QString mName;
566  int mIndex;
567  };
568 
569  class CORE_EXPORT WhenThen
570  {
571  public:
572  WhenThen( Node* whenExp, Node* thenExp ) : mWhenExp( whenExp ), mThenExp( thenExp ) {}
573  ~WhenThen() { delete mWhenExp; delete mThenExp; }
574 
575  //protected:
578  };
579  typedef QList<WhenThen*> WhenThenList;
580 
581  class CORE_EXPORT NodeCondition : public Node
582  {
583  public:
584  NodeCondition( WhenThenList* conditions, Node* elseExp = NULL ) : mConditions( *conditions ), mElseExp( elseExp ) { delete conditions; }
585  ~NodeCondition() { delete mElseExp; qDeleteAll( mConditions ); }
586 
587  virtual NodeType nodeType() const { return ntCondition; }
588  virtual QVariant eval( QgsExpression* parent, const QgsFeature* f );
589  virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
590  virtual QString dump() const;
591 
592  virtual QStringList referencedColumns() const;
593  virtual bool needsGeometry() const;
594  virtual void accept( Visitor& v ) const { v.visit( *this ); }
595 
596  protected:
597  WhenThenList mConditions;
599  };
600 
602 
605  class CORE_EXPORT Visitor
606  {
607  public:
608  virtual ~Visitor() {}
609  virtual void visit( const NodeUnaryOperator& n ) = 0;
610  virtual void visit( const NodeBinaryOperator& n ) = 0;
611  virtual void visit( const NodeInOperator& n ) = 0;
612  virtual void visit( const NodeFunction& n ) = 0;
613  virtual void visit( const NodeLiteral& n ) = 0;
614  virtual void visit( const NodeColumnRef& n ) = 0;
615  virtual void visit( const NodeCondition& n ) = 0;
616  };
617 
619  void acceptVisitor( Visitor& v ) const;
620 
621  static QString helptext( QString name );
622  static QString group( QString group );
623 
624  protected:
625  // internally used to create an empty expression
626  QgsExpression() : mRootNode( 0 ), mRowNumber( 0 ), mCalc( 0 ) {}
627 
628  void initGeomCalculator();
629 
631 
634 
636  double mScale;
637  QString mExp;
638 
639  static QMap<QString, QVariant> gmSpecialColumns;
640  static QMap<QString, QString> gmSpecialColumnGroups;
641 
643 
644  friend class QgsOgcUtils;
645 
646  static void initFunctionHelp();
647  static QHash<QString, QString> gFunctionHelpTexts;
648  static QHash<QString, QString> gGroups;
649 
650  private:
651  Q_DISABLE_COPY( QgsExpression ) // for now - until we have proper copy constructor / implicit sharing
652 };
653 
655 
656 #endif // QGSEXPRESSION_H
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:438
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:89
double years()
Definition: qgsexpression.h:405
virtual QStringList referencedColumns() const =0
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
Definition: qgsexpression.h:139
QVariant evaluate(const QgsFeature &f, const QgsFields &fields)
Evaluate the feature and return the result.
Definition: qgsexpression.h:136
UnaryOperator
Definition: qgsexpression.h:198
Definition: qgsexpression.h:225
Definition: qgsexpression.h:201
NodeType
Definition: qgsexpression.h:344
QString mName
Definition: qgsexpression.h:565
int mFnIndex
Definition: qgsexpression.h:523
QVariant mValue
Definition: qgsexpression.h:544
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
Definition: qgsexpression.h:96
virtual ~NodeFunction()
Definition: qgsexpression.h:507
Definition: qgsexpression.h:206
Definition: qgsexpression.h:220
double months()
Definition: qgsexpression.h:406
Definition: qgsexpression.h:214
const QString expression() const
Alias for dump()
Definition: qgsexpression.h:167
virtual bool needsGeometry() const
Definition: qgsexpression.h:560
Node is a class used by Line3D.
Definition: Node.h:23
Definition: qgsexpression.h:346
Definition: qgsexpression.h:527
virtual QVariant func(const QVariantList &values, const QgsFeature *f, QgsExpression *parent)
Definition: qgsexpression.h:301
A abstract base class for defining QgsExpression functions.
Definition: qgsexpression.h:257
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:214
~NodeUnaryOperator()
Definition: qgsexpression.h:426
virtual bool needsGeometry() const
Definition: qgsexpression.h:437
Definition: qgsexpression.h:350
virtual QString dump() const =0
NodeCondition(WhenThenList *conditions, Node *elseExp=NULL)
Definition: qgsexpression.h:584
NodeList * mArgs
Definition: qgsexpression.h:524
static QString helptext(QString name)
Definition: qgsexpression.cpp:2702
double weeks()
Definition: qgsexpression.h:407
BinaryOperator mOp
Definition: qgsexpression.h:472
Definition: qgsexpression.h:229
virtual QStringList referencedColumns() const
Definition: qgsexpression.h:559
QgsExpression()
Definition: qgsexpression.h:626
UnaryOperator mOp
Definition: qgsexpression.h:441
virtual NodeType nodeType() const
Definition: qgsexpression.h:455
Definition: qgsexpression.h:477
Definition: qgsexpression.h:244
Container of fields for a vector layer.
Definition: qgsfield.h:172
Definition: qgsgeometry.h:69
Definition: qgsexpression.h:211
Interval(double seconds=0)
Definition: qgsexpression.h:403
virtual NodeType nodeType() const
Definition: qgsexpression.h:587
virtual bool prepare(QgsExpression *parent, const QgsFields &fields)=0
NodeList * list() const
Definition: qgsexpression.h:485
~NodeBinaryOperator()
Definition: qgsexpression.h:449
virtual NodeType nodeType() const
Definition: qgsexpression.h:512
Definition: qgsexpression.h:295
Definition: qgsexpression.h:243
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
QVariant value() const
Definition: qgsexpression.h:532
Definition: qgsexpression.h:212
int currentRowNumber()
Return the number used for $rownum special column.
Definition: qgsexpression.h:148
Definition: qgsexpression.h:445
QString mEvalErrorString
Definition: qgsexpression.h:633
NodeList()
Definition: qgsexpression.h:380
Definition: qgsexpression.h:227
Definition: qgsexpression.h:245
NodeBinaryOperator(BinaryOperator op, Node *opLeft, Node *opRight)
Definition: qgsexpression.h:448
QString mParserErrorString
Definition: qgsexpression.h:632
virtual QStringList referencedColumns() const
Definition: qgsexpression.h:436
static const QList< Function * > & Functions()
Definition: qgsexpression.cpp:1618
Definition: qgsexpression.h:217
virtual QStringList referencedColumns() const
Definition: qgsexpression.h:460
double mScale
Definition: qgsexpression.h:636
bool isValid()
Definition: qgsexpression.h:412
static QHash< QString, QString > gFunctionHelpTexts
Definition: qgsexpression.h:647
virtual NodeType nodeType() const
Definition: qgsexpression.h:534
Node * mElseExp
Definition: qgsexpression.h:598
Definition: qgsexpression.h:213
Definition: qgsexpression.h:233
int mRowNumber
Definition: qgsexpression.h:635
Definition: qgsexpression.h:242
QgsDistanceArea * geomCalculator()
Return calculator used for distance and area calculations (used by internal functions) ...
Definition: qgsexpression.h:174
NodeList * args() const
Definition: qgsexpression.h:510
bool mNotIn
Definition: qgsexpression.h:499
Definition: qgsexpression.h:222
Definition: qgsexpression.h:237
int mIndex
Definition: qgsexpression.h:566
virtual QStringList referencedColumns() const
Definition: qgsexpression.h:492
~NodeCondition()
Definition: qgsexpression.h:585
Node * node() const
Definition: qgsexpression.h:483
QgsDistanceArea * mCalc
Definition: qgsexpression.h:642
QString name() const
Definition: qgsexpression.h:552
Definition: qgsexpression.h:239
virtual bool needsGeometry() const
Definition: qgsexpression.h:540
QList< Node * > mList
Definition: qgsexpression.h:389
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:519
static QHash< QString, QString > gGroups
Definition: qgsexpression.h:648
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
Definition: qgsexpression.h:103
Definition: qgsexpression.h:216
Definition: qgsexpression.h:228
double minutes()
Definition: qgsexpression.h:410
Node * mNode
Definition: qgsexpression.h:497
double hours()
Definition: qgsexpression.h:409
NodeInOperator(Node *node, NodeList *list, bool notin=false)
Definition: qgsexpression.h:480
NodeColumnRef(QString name)
Definition: qgsexpression.h:550
double scale()
Definition: qgsexpression.h:164
int count()
Definition: qgsexpression.h:383
Definition: qgsexpression.h:348
Node * mRootNode
Definition: qgsexpression.h:630
QString helptext()
The help text for the function.
Definition: qgsexpression.h:274
static QList< Function * > gmFunctions
Definition: qgsexpression.h:311
Definition: qgsexpression.h:226
QString name()
The name of the function.
Definition: qgsexpression.h:263
void setCurrentRowNumber(int rowNumber)
Set the number for $rownum special column.
Definition: qgsexpression.h:146
WhenThen(Node *whenExp, Node *thenExp)
Definition: qgsexpression.h:572
WhenThenList mConditions
Definition: qgsexpression.h:597
NodeLiteral(QVariant value)
Definition: qgsexpression.h:530
virtual NodeType nodeType() const
Definition: qgsexpression.h:431
Definition: qgsexpression.h:502
NodeUnaryOperator(UnaryOperator op, Node *operand)
Definition: qgsexpression.h:425
Node * mOpLeft
Definition: qgsexpression.h:473
SpatialOperator
Definition: qgsexpression.h:235
bool isNotIn() const
Definition: qgsexpression.h:484
BinaryOperator op() const
Definition: qgsexpression.h:451
Definition: qgsexpression.h:230
Definition: qgsexpression.h:219
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:494
Definition: qgsexpression.h:218
Definition: qgsexpression.h:200
Definition: qgsexpression.h:547
virtual QVariant eval(QgsExpression *parent, const QgsFeature *f)=0
~WhenThen()
Definition: qgsexpression.h:573
double days()
Definition: qgsexpression.h:408
Definition: qgsexpression.h:241
virtual QStringList referencedColumns() const
Definition: qgsexpression.h:269
void setEvalErrorString(QString str)
Set evaluation error (used internally by evaluation functions)
Definition: qgsexpression.h:143
Definition: qgsexpression.h:221
NodeFunction(int fnIndex, NodeList *args)
Definition: qgsexpression.h:505
General purpose distance and area calculator.
Definition: qgsdistancearea.h:34
Definition: qgsexpression.h:377
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:562
static QMap< QString, QString > gmSpecialColumnGroups
Definition: qgsexpression.h:640
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:462
Definition: qgsexpression.h:581
QString mExp
Definition: qgsexpression.h:637
Definition: qgsexpression.h:351
BinaryOperator
Definition: qgsexpression.h:203
QString group()
The group the function belongs to.
Definition: qgsexpression.h:272
QList< WhenThen * > WhenThenList
Definition: qgsexpression.h:579
virtual NodeType nodeType() const
Definition: qgsexpression.h:487
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:594
double seconds()
Definition: qgsexpression.h:411
virtual void visit(const NodeUnaryOperator &n)=0
QVariant evaluate(const QgsFeature &f)
Evaluate the feature and return the result.
Definition: qgsexpression.h:127
Definition: qgsexpression.h:355
int params()
The number of parameters this function takes.
Definition: qgsexpression.h:265
Node * mThenExp
Definition: qgsexpression.h:577
virtual ~Visitor()
Definition: qgsexpression.h:608
virtual QStringList referencedColumns() const
Definition: qgsexpression.h:539
Definition: qgsexpression.h:238
virtual void accept(Visitor &v) const
Definition: qgsexpression.h:541
Definition: qgsexpression.h:347
Node * mOperand
Definition: qgsexpression.h:442
virtual ~NodeList()
Definition: qgsexpression.h:381
Node * operand() const
Definition: qgsexpression.h:429
support for visitor pattern - algorithms dealing with the expressions may be implemented without modi...
Definition: qgsexpression.h:605
virtual bool needsGeometry() const
Definition: qgsexpression.h:493
virtual bool needsGeometry() const =0
Definition: qgsexpression.h:349
bool operator==(const Function &other) const
Definition: qgsexpression.h:278
static QStringList gmBuiltinFunctions
Definition: qgsexpression.h:313
Definition: qgsexpression.h:352
void append(Node *node)
Definition: qgsexpression.h:382
UnaryOperator op() const
Definition: qgsexpression.h:428
void setValid(bool valid)
Definition: qgsexpression.h:413
Definition: qgsexpression.h:569
Definition: qgsexpression.h:207
Node * mWhenExp
Definition: qgsexpression.h:576
This is the base class for vector data providers.
Definition: qgsvectordataprovider.h:48
void setScale(double scale)
Definition: qgsexpression.h:162
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
Definition: qgsexpression.h:210
int fnIndex() const
Definition: qgsexpression.h:509
Node * mOpRight
Definition: qgsexpression.h:474
QString parserErrorString() const
Returns parser error.
Definition: qgsexpression.h:98
Q_DECLARE_METATYPE(QgsExpression::Interval)
The QgsOgcUtils class provides various utility functions for conversion between OGC (Open Geospatial ...
Definition: qgsogcutils.h:30
NodeList * mList
Definition: qgsexpression.h:498
Definition: qgsexpression.h:240
QString evalErrorString() const
Returns evaluation error.
Definition: qgsexpression.h:141
Node * opRight() const
Definition: qgsexpression.h:453
virtual bool needsGeometry() const
Definition: qgsexpression.h:461
virtual bool needsGeometry() const
Definition: qgsexpression.h:518
bool usesgeometry()
Does this function use a geometry object.
Definition: qgsexpression.h:267
Function(QString fnname, int params, QString group, QString helpText=QString(), bool usesGeometry=false, QStringList referencedColumns=QStringList())
Definition: qgsexpression.h:260
Definition: qgsexpression.h:392
virtual ~Node()
Definition: qgsexpression.h:358
Node * opLeft() const
Definition: qgsexpression.h:452
Definition: qgsexpression.h:422
Definition: qgsexpression.h:215
virtual NodeType nodeType() const
Definition: qgsexpression.h:554
virtual ~NodeInOperator()
Definition: qgsexpression.h:481
QList< Node * > list()
Definition: qgsexpression.h:384
StaticFunction(QString fnname, int params, FcnEval fcn, QString group, QString helpText=QString(), bool usesGeometry=false, QStringList referencedColumns=QStringList())
Definition: qgsexpression.h:298
static QMap< QString, QVariant > gmSpecialColumns
Definition: qgsexpression.h:639