QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgssqlstatement.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssqlstatement.h
3  ---------------------
4  begin : April 2016
5  copyright : (C) 2011 by Martin Dobias
6  copyright : (C) 2016 by Even Rouault
7  email : even.rouault at spatialys.com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSSQLSTATEMENT_H
18 #define QGSSQLSTATEMENT_H
19 
20 #include <QCoreApplication>
21 #include "qgis_sip.h"
22 #include <QMetaType>
23 #include <QStringList>
24 #include <QVariant>
25 #include <QList>
26 #include <QSet>
27 
28 #include "qgis_core.h"
29 
35 class CORE_EXPORT QgsSQLStatement
36 {
37  Q_DECLARE_TR_FUNCTIONS( QgsSQLStatement )
38  public:
39 
43  QgsSQLStatement( const QString &statement );
44 
48  QgsSQLStatement( const QgsSQLStatement &other );
49 
53  QgsSQLStatement &operator=( const QgsSQLStatement &other );
54  virtual ~QgsSQLStatement();
55 
57  bool hasParserError() const;
59  QString parserErrorString() const;
60 
66  bool doBasicValidationChecks( QString &errorMsgOut SIP_OUT ) const;
67 
68  class Node;
69 
74  const QgsSQLStatement::Node *rootNode() const;
75 
81  QString statement() const;
82 
89  QString dump() const;
90 
95  static QString quotedIdentifier( QString name );
96 
102  static QString quotedIdentifierIfNeeded( const QString &name );
103 
108  static QString stripQuotedIdentifier( QString text );
109 
114  static QString stripMsQuotedIdentifier( QString text );
115 
120  static QString quotedString( QString text );
121 
127  {
130  };
131 
137  {
138  // logical
141 
142  // comparison
143  boEQ, // =
144  boNE, // <>
145  boLE, // <=
146  boGE, // >=
147  boLT, // <
148  boGT, // >
155 
156  // math
164 
165  // strings
167  };
168 
173  enum JoinType
174  {
182  jtFull
183  };
184 
186  static const char *BINARY_OPERATOR_TEXT[] SIP_SKIP;
187 
189  static const char *UNARY_OPERATOR_TEXT[] SIP_SKIP;
190 
192  static const char *JOIN_TYPE_TEXT[] SIP_SKIP;
193 
195 
196  class Visitor; // visitor interface is defined below
197 
199  enum NodeType
200  {
213  ntCast
214  };
215 
220  class CORE_EXPORT Node
221  {
222 
223 #ifdef SIP_RUN
225  switch ( sipCpp->nodeType() )
226  {
227  case QgsSQLStatement::ntUnaryOperator: sipType = sipType_QgsSQLStatement_NodeUnaryOperator; break;
228  case QgsSQLStatement::ntBinaryOperator: sipType = sipType_QgsSQLStatement_NodeBinaryOperator; break;
229  case QgsSQLStatement::ntInOperator: sipType = sipType_QgsSQLStatement_NodeInOperator; break;
230  case QgsSQLStatement::ntBetweenOperator: sipType = sipType_QgsSQLStatement_NodeBetweenOperator; break;
231  case QgsSQLStatement::ntFunction: sipType = sipType_QgsSQLStatement_NodeFunction; break;
232  case QgsSQLStatement::ntLiteral: sipType = sipType_QgsSQLStatement_NodeLiteral; break;
233  case QgsSQLStatement::ntColumnRef: sipType = sipType_QgsSQLStatement_NodeColumnRef; break;
234  case QgsSQLStatement::ntSelectedColumn: sipType = sipType_QgsSQLStatement_NodeSelectedColumn; break;
235  case QgsSQLStatement::ntSelect: sipType = sipType_QgsSQLStatement_NodeSelect; break;
236  case QgsSQLStatement::ntTableDef: sipType = sipType_QgsSQLStatement_NodeTableDef; break;
237  case QgsSQLStatement::ntJoin: sipType = sipType_QgsSQLStatement_NodeJoin; break;
238  case QgsSQLStatement::ntColumnSorted: sipType = sipType_QgsSQLStatement_NodeColumnSorted; break;
239  case QgsSQLStatement::ntCast: sipType = sipType_QgsSQLStatement_NodeCast; break;
240  default: sipType = 0; break;
241  }
242  SIP_END
243 #endif
244 
245  public:
246  virtual ~Node() = default;
247 
253  virtual QgsSQLStatement::NodeType nodeType() const = 0;
254 
260  virtual QString dump() const = 0;
261 
271 
287  virtual void accept( QgsSQLStatement::Visitor &v ) const = 0;
288  };
289 
294  class CORE_EXPORT NodeList
295  {
296  public:
298  NodeList() = default;
299  virtual ~NodeList() { qDeleteAll( mList ); }
300 
302  void append( QgsSQLStatement::Node *node SIP_TRANSFER ) { mList.append( node ); }
303 
305  QList<QgsSQLStatement::Node *> list() { return mList; }
306 
310  int count() const { return mList.count(); }
311 
313  void accept( QgsSQLStatement::Visitor &v ) const;
314 
316  QgsSQLStatement::NodeList *clone() const SIP_FACTORY;
317 
319  virtual QString dump() const;
320 
321  protected:
322  QList<Node *> mList;
323  };
324 
329  class CORE_EXPORT NodeUnaryOperator : public QgsSQLStatement::Node
330  {
331  public:
333  NodeUnaryOperator( QgsSQLStatement::UnaryOperator op, QgsSQLStatement::Node *operand SIP_TRANSFER ) : mOp( op ), mOperand( operand ) {}
334  ~NodeUnaryOperator() override { delete mOperand; }
335 
337  QgsSQLStatement::UnaryOperator op() const { return mOp; }
338 
340  QgsSQLStatement::Node *operand() const { return mOperand; }
341 
342  QgsSQLStatement::NodeType nodeType() const override { return ntUnaryOperator; }
343  QString dump() const override;
344 
345  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
346  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
347 
348  protected:
350  Node *mOperand = nullptr;
351  };
352 
357  class CORE_EXPORT NodeBinaryOperator : public QgsSQLStatement::Node
358  {
359  public:
362  : mOp( op )
363  , mOpLeft( opLeft )
364  , mOpRight( opRight )
365  {}
366  ~NodeBinaryOperator() override { delete mOpLeft; delete mOpRight; }
367 
369  QgsSQLStatement::BinaryOperator op() const { return mOp; }
370 
372  QgsSQLStatement::Node *opLeft() const { return mOpLeft; }
373 
375  QgsSQLStatement::Node *opRight() const { return mOpRight; }
376 
377  QgsSQLStatement::NodeType nodeType() const override { return ntBinaryOperator; }
378  QString dump() const override;
379 
380  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
381  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
382 
384  int precedence() const;
385 
387  bool leftAssociative() const;
388 
389  protected:
390 
392  Node *mOpLeft = nullptr;
393  Node *mOpRight = nullptr;
394  };
395 
400  class CORE_EXPORT NodeInOperator : public QgsSQLStatement::Node
401  {
402  public:
404  NodeInOperator( QgsSQLStatement::Node *node SIP_TRANSFER, QgsSQLStatement::NodeList *list SIP_TRANSFER, bool notin = false ) : mNode( node ), mList( list ), mNotIn( notin ) {}
405  ~NodeInOperator() override { delete mNode; delete mList; }
406 
408  QgsSQLStatement::Node *node() const { return mNode; }
409 
411  bool isNotIn() const { return mNotIn; }
412 
414  QgsSQLStatement::NodeList *list() const { return mList; }
415 
416  QgsSQLStatement::NodeType nodeType() const override { return ntInOperator; }
417  QString dump() const override;
418 
419  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
420  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
421 
422  protected:
423  Node *mNode = nullptr;
424  NodeList *mList = nullptr;
425  bool mNotIn;
426  };
427 
432  class CORE_EXPORT NodeBetweenOperator : public QgsSQLStatement::Node
433  {
434  public:
437  : mNode( node ), mMinVal( minVal ), mMaxVal( maxVal ), mNotBetween( notBetween ) {}
438  ~NodeBetweenOperator() override { delete mNode; delete mMinVal; delete mMaxVal; }
439 
441  QgsSQLStatement::Node *node() const { return mNode; }
442 
444  bool isNotBetween() const { return mNotBetween; }
445 
447  QgsSQLStatement::Node *minVal() const { return mMinVal; }
448 
450  QgsSQLStatement::Node *maxVal() const { return mMaxVal; }
451 
452  QgsSQLStatement::NodeType nodeType() const override { return ntBetweenOperator; }
453  QString dump() const override;
454 
455  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
456  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
457 
458  protected:
459  Node *mNode = nullptr;
460  Node *mMinVal = nullptr;
461  Node *mMaxVal = nullptr;
462  bool mNotBetween;
463  };
464 
469  class CORE_EXPORT NodeFunction : public QgsSQLStatement::Node
470  {
471  public:
473  NodeFunction( const QString &name, QgsSQLStatement::NodeList *args SIP_TRANSFER ) : mName( name ), mArgs( args ) {}
474  ~NodeFunction() override { delete mArgs; }
475 
477  QString name() const { return mName; }
478 
480  QgsSQLStatement::NodeList *args() const { return mArgs; }
481 
482  QgsSQLStatement::NodeType nodeType() const override { return ntFunction; }
483  QString dump() const override;
484 
485  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
486  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
487 
488  protected:
489  QString mName;
490  NodeList *mArgs = nullptr;
491 
492  };
493 
498  class CORE_EXPORT NodeLiteral : public QgsSQLStatement::Node
499  {
500  public:
502  NodeLiteral( const QVariant &value ) : mValue( value ) {}
503 
505  inline QVariant value() const { return mValue; }
506 
507  QgsSQLStatement::NodeType nodeType() const override { return ntLiteral; }
508  QString dump() const override;
509 
510  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
511  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
512 
513  protected:
514  QVariant mValue;
515  };
516 
521  class CORE_EXPORT NodeColumnRef : public QgsSQLStatement::Node
522  {
523  public:
525  NodeColumnRef( const QString &name, bool star ) : mName( name ), mDistinct( false ), mStar( star ) {}
527  NodeColumnRef( const QString &tableName, const QString &name, bool star ) : mTableName( tableName ), mName( name ), mDistinct( false ), mStar( star ) {}
528 
530  void setDistinct( bool distinct = true ) { mDistinct = distinct; }
531 
533  QString tableName() const { return mTableName; }
534 
536  QString name() const { return mName; }
537 
539  bool star() const { return mStar; }
540 
542  bool distinct() const { return mDistinct; }
543 
544  QgsSQLStatement::NodeType nodeType() const override { return ntColumnRef; }
545  QString dump() const override;
546 
547  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
548  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
550  QgsSQLStatement::NodeColumnRef *cloneThis() const SIP_FACTORY;
551 
552  protected:
553  QString mTableName;
554  QString mName;
555  bool mDistinct;
556  bool mStar;
557  };
558 
563  class CORE_EXPORT NodeSelectedColumn : public QgsSQLStatement::Node
564  {
565  public:
567  NodeSelectedColumn( QgsSQLStatement::Node *node SIP_TRANSFER ) : mColumnNode( node ) {}
568  ~NodeSelectedColumn() override { delete mColumnNode; }
569 
571  void setAlias( const QString &alias ) { mAlias = alias; }
572 
574  QgsSQLStatement::Node *column() const { return mColumnNode; }
575 
577  QString alias() const { return mAlias; }
578 
579  QgsSQLStatement::NodeType nodeType() const override { return ntSelectedColumn; }
580  QString dump() const override;
581 
582  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
583  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
585  QgsSQLStatement::NodeSelectedColumn *cloneThis() const SIP_FACTORY;
586 
587  protected:
588  Node *mColumnNode = nullptr;
589  QString mAlias;
590  };
591 
596  class CORE_EXPORT NodeCast : public QgsSQLStatement::Node
597  {
598  public:
600  NodeCast( QgsSQLStatement::Node *node SIP_TRANSFER, const QString &type ) : mNode( node ), mType( type ) {}
601  ~NodeCast() override { delete mNode; }
602 
604  QgsSQLStatement::Node *node() const { return mNode; }
605 
607  QString type() const { return mType; }
608 
609  QgsSQLStatement::NodeType nodeType() const override { return ntCast; }
610  QString dump() const override;
611 
612  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
613  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
614 
615  protected:
616  Node *mNode = nullptr;
617  QString mType;
618  };
619 
624  class CORE_EXPORT NodeTableDef : public QgsSQLStatement::Node
625  {
626  public:
628  NodeTableDef( const QString &name ) : mName( name ) {}
630  NodeTableDef( const QString &name, const QString &alias ) : mName( name ), mAlias( alias ) {}
631 
633  QString name() const { return mName; }
634 
636  QString alias() const { return mAlias; }
637 
638  QgsSQLStatement::NodeType nodeType() const override { return ntTableDef; }
639  QString dump() const override;
640 
641  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
642  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
644  QgsSQLStatement::NodeTableDef *cloneThis() const SIP_FACTORY;
645 
646  protected:
647  QString mName;
648  QString mAlias;
649  };
650 
655  class CORE_EXPORT NodeJoin : public QgsSQLStatement::Node
656  {
657  public:
659  NodeJoin( QgsSQLStatement::NodeTableDef *tabledef SIP_TRANSFER, QgsSQLStatement::Node *onExpr SIP_TRANSFER, QgsSQLStatement::JoinType type ) : mTableDef( tabledef ), mOnExpr( onExpr ), mType( type ) {}
661  NodeJoin( QgsSQLStatement::NodeTableDef *tabledef SIP_TRANSFER, const QList<QString> &usingColumns, QgsSQLStatement::JoinType type ) : mTableDef( tabledef ), mUsingColumns( usingColumns ), mType( type ) {}
662  ~NodeJoin() override { delete mTableDef; delete mOnExpr; }
663 
665  QgsSQLStatement::NodeTableDef *tableDef() const { return mTableDef; }
666 
668  QgsSQLStatement::Node *onExpr() const { return mOnExpr; }
669 
671  QList<QString> usingColumns() const { return mUsingColumns; }
672 
674  QgsSQLStatement::JoinType type() const { return mType; }
675 
676  QgsSQLStatement::NodeType nodeType() const override { return ntJoin; }
677  QString dump() const override;
678 
679  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
680  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
682  QgsSQLStatement::NodeJoin *cloneThis() const SIP_FACTORY;
683 
684  protected:
685  NodeTableDef *mTableDef = nullptr;
686  Node *mOnExpr = nullptr;
687  QList<QString> mUsingColumns;
688  JoinType mType;
689  };
690 
695  class CORE_EXPORT NodeColumnSorted : public QgsSQLStatement::Node
696  {
697  public:
699  NodeColumnSorted( QgsSQLStatement::NodeColumnRef *column SIP_TRANSFER, bool asc ) : mColumn( column ), mAsc( asc ) {}
700  ~NodeColumnSorted() override { delete mColumn; }
701 
703  QgsSQLStatement::NodeColumnRef *column() const { return mColumn; }
704 
706  bool ascending() const { return mAsc; }
707 
708  QgsSQLStatement::NodeType nodeType() const override { return ntColumnSorted; }
709  QString dump() const override;
710 
711  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
712  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
714  QgsSQLStatement::NodeColumnSorted *cloneThis() const SIP_FACTORY;
715 
716  protected:
717  NodeColumnRef *mColumn = nullptr;
718  bool mAsc;
719  };
720 
725  class CORE_EXPORT NodeSelect : public QgsSQLStatement::Node
726  {
727  public:
729  NodeSelect( const QList<QgsSQLStatement::NodeTableDef *> &tableList SIP_TRANSFER, const QList<QgsSQLStatement::NodeSelectedColumn *> &columns SIP_TRANSFER, bool distinct ) : mTableList( tableList ), mColumns( columns ), mDistinct( distinct ) {}
730  ~NodeSelect() override;
731 
733  void setJoins( const QList<QgsSQLStatement::NodeJoin *> &joins SIP_TRANSFER ) { qDeleteAll( mJoins ); mJoins = joins; }
735  void appendJoin( QgsSQLStatement::NodeJoin *join SIP_TRANSFER ) { mJoins.append( join ); }
737  void setWhere( QgsSQLStatement::Node *where SIP_TRANSFER ) { delete mWhere; mWhere = where; }
739  void setOrderBy( const QList<QgsSQLStatement::NodeColumnSorted *> &orderBy SIP_TRANSFER ) { qDeleteAll( mOrderBy ); mOrderBy = orderBy; }
740 
742  QList<QgsSQLStatement::NodeTableDef *> tables() const { return mTableList; }
744  QList<QgsSQLStatement::NodeSelectedColumn *> columns() const { return mColumns; }
746  bool distinct() const { return mDistinct; }
748  QList<QgsSQLStatement::NodeJoin *> joins() const { return mJoins; }
750  QgsSQLStatement::Node *where() const { return mWhere; }
752  QList<QgsSQLStatement::NodeColumnSorted *> orderBy() const { return mOrderBy; }
753 
754  QgsSQLStatement::NodeType nodeType() const override { return ntSelect; }
755  QString dump() const override;
756 
757  void accept( QgsSQLStatement::Visitor &v ) const override { v.visit( *this ); }
758  QgsSQLStatement::Node *clone() const override SIP_FACTORY;
759 
760  protected:
761  QList<NodeTableDef *> mTableList;
762  QList<NodeSelectedColumn *> mColumns;
763  bool mDistinct;
764  QList<NodeJoin *> mJoins;
765  Node *mWhere = nullptr;
766  QList<NodeColumnSorted *> mOrderBy;
767  };
768 
770 
776  class CORE_EXPORT Visitor
777  {
778  public:
779  virtual ~Visitor() = default;
781  virtual void visit( const QgsSQLStatement::NodeUnaryOperator &n ) = 0;
783  virtual void visit( const QgsSQLStatement::NodeBinaryOperator &n ) = 0;
785  virtual void visit( const QgsSQLStatement::NodeInOperator &n ) = 0;
787  virtual void visit( const QgsSQLStatement::NodeBetweenOperator &n ) = 0;
789  virtual void visit( const QgsSQLStatement::NodeFunction &n ) = 0;
791  virtual void visit( const QgsSQLStatement::NodeLiteral &n ) = 0;
793  virtual void visit( const QgsSQLStatement::NodeColumnRef &n ) = 0;
795  virtual void visit( const QgsSQLStatement::NodeSelectedColumn &n ) = 0;
797  virtual void visit( const QgsSQLStatement::NodeTableDef &n ) = 0;
799  virtual void visit( const QgsSQLStatement::NodeSelect &n ) = 0;
801  virtual void visit( const QgsSQLStatement::NodeJoin &n ) = 0;
803  virtual void visit( const QgsSQLStatement::NodeColumnSorted &n ) = 0;
805  virtual void visit( const QgsSQLStatement::NodeCast &n ) = 0;
806  };
807 
812  class CORE_EXPORT RecursiveVisitor: public QgsSQLStatement::Visitor
813  {
814  public:
816  RecursiveVisitor() = default;
817 
818  void visit( const QgsSQLStatement::NodeUnaryOperator &n ) override { n.operand()->accept( *this ); }
819  void visit( const QgsSQLStatement::NodeBinaryOperator &n ) override { n.opLeft()->accept( *this ); n.opRight()->accept( *this ); }
820  void visit( const QgsSQLStatement::NodeInOperator &n ) override { n.node()->accept( *this ); n.list()->accept( *this ); }
821  void visit( const QgsSQLStatement::NodeBetweenOperator &n ) override { n.node()->accept( *this ); n.minVal()->accept( *this ); n.maxVal()->accept( *this ); }
822  void visit( const QgsSQLStatement::NodeFunction &n ) override { n.args()->accept( *this ); }
823  void visit( const QgsSQLStatement::NodeLiteral & ) override {}
824  void visit( const QgsSQLStatement::NodeColumnRef & ) override { }
825  void visit( const QgsSQLStatement::NodeSelectedColumn &n ) override { n.column()->accept( *this ); }
826  void visit( const QgsSQLStatement::NodeTableDef & ) override {}
827  void visit( const QgsSQLStatement::NodeSelect &n ) override;
828  void visit( const QgsSQLStatement::NodeJoin &n ) override;
829  void visit( const QgsSQLStatement::NodeColumnSorted &n ) override { n.column()->accept( *this ); }
830  void visit( const QgsSQLStatement::NodeCast &n ) override { n.node()->accept( *this ); }
831  };
832 
834  void acceptVisitor( QgsSQLStatement::Visitor &v ) const;
835 
836  protected:
837  QgsSQLStatement::Node *mRootNode = nullptr;
838  bool mAllowFragments = false;
839  QString mStatement;
841 
850  QgsSQLStatement( const QString &statement, bool allowFragments );
851 };
852 
854 
855 
860 class CORE_EXPORT QgsSQLStatementFragment : public QgsSQLStatement
861 {
862  public:
863 
867  QgsSQLStatementFragment( const QString &fragment );
868 
869 };
870 
871 
872 #endif // QGSSQLSTATEMENT_H
Class for parsing fragments of SQL statements, such as an expression or where clause.
'X BETWEEN y and z' operator
QgsSQLStatement::Node * maxVal() const
Maximum bound.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
bool isNotBetween() const
Whether this is a NOT BETWEEN operator.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::Node * node() const
Variable at the left of BETWEEN.
NodeBetweenOperator(QgsSQLStatement::Node *node, QgsSQLStatement::Node *minVal, QgsSQLStatement::Node *maxVal, bool notBetween=false)
Constructor.
QgsSQLStatement::Node * minVal() const
Minimum bound.
Binary logical/arithmetical operator (AND, OR, =, +, ...)
QgsSQLStatement::Node * opRight() const
Right operand.
QgsSQLStatement::Node * opLeft() const
Left operand.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeBinaryOperator(QgsSQLStatement::BinaryOperator op, QgsSQLStatement::Node *opLeft, QgsSQLStatement::Node *opRight)
Constructor.
QgsSQLStatement::BinaryOperator op() const
Operator.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
NodeCast(QgsSQLStatement::Node *node, const QString &type)
Constructor.
QgsSQLStatement::Node * node() const
Node that is referred to.
QString type() const
Type.
Reference to a column.
QString name() const
The name of the column.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
NodeColumnRef(const QString &name, bool star)
Constructor with column name only.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
bool star() const
Whether this is the * column.
NodeColumnRef(const QString &tableName, const QString &name, bool star)
Constructor with table and column name.
QString tableName() const
The name of the table. May be empty.
void setDistinct(bool distinct=true)
Sets whether this is prefixed by DISTINCT.
bool distinct() const
Whether this is prefixed by DISTINCT.
bool ascending() const
Whether the column is sorted in ascending order.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::NodeColumnRef * column() const
The name of the column.
NodeColumnSorted(QgsSQLStatement::NodeColumnRef *column, bool asc)
Constructor.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
Function with a name and arguments node.
NodeFunction(const QString &name, QgsSQLStatement::NodeList *args)
Constructor.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::NodeList * args() const
Returns arguments.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QString name() const
Returns function name.
bool isNotIn() const
Whether this is a NOT IN operator.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QgsSQLStatement::NodeList * list() const
Values list.
NodeInOperator(QgsSQLStatement::Node *node, QgsSQLStatement::NodeList *list, bool notin=false)
Constructor.
QgsSQLStatement::Node * node() const
Variable at the left of IN.
QgsSQLStatement::NodeTableDef * tableDef() const
Table definition.
NodeJoin(QgsSQLStatement::NodeTableDef *tabledef, QgsSQLStatement::Node *onExpr, QgsSQLStatement::JoinType type)
Constructor with table definition, ON expression.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QList< QString > usingColumns() const
Columns referenced by USING.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeJoin(QgsSQLStatement::NodeTableDef *tabledef, const QList< QString > &usingColumns, QgsSQLStatement::JoinType type)
Constructor with table definition and USING columns.
QgsSQLStatement::Node * onExpr() const
On expression. Will be nullptr if usingColumns() is not empty.
QgsSQLStatement::JoinType type() const
Join type.
NodeList()=default
Constructor.
void accept(QgsSQLStatement::Visitor &v) const
Accept visitor.
int count() const
Returns the number of nodes in the list.
QList< QgsSQLStatement::Node * > list()
Returns list.
void append(QgsSQLStatement::Node *node)
Takes ownership of the provided node.
Literal value (integer, integer64, double, string)
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
NodeLiteral(const QVariant &value)
Constructor.
QVariant value() const
The value of the literal.
QgsSQLStatement::Node * where() const
Returns the where clause.
NodeSelect(const QList< QgsSQLStatement::NodeTableDef * > &tableList, const QList< QgsSQLStatement::NodeSelectedColumn * > &columns, bool distinct)
Constructor.
void setJoins(const QList< QgsSQLStatement::NodeJoin * > &joins)
Sets joins.
void setWhere(QgsSQLStatement::Node *where)
Sets where clause.
bool distinct() const
Returns if the SELECT is DISTINCT.
void appendJoin(QgsSQLStatement::NodeJoin *join)
Append a join.
void setOrderBy(const QList< QgsSQLStatement::NodeColumnSorted * > &orderBy)
Sets order by columns.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QList< QgsSQLStatement::NodeSelectedColumn * > columns() const
Returns the list of columns.
QList< QgsSQLStatement::NodeColumnSorted * > orderBy() const
Returns the list of order by columns.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QList< QgsSQLStatement::NodeJoin * > joins() const
Returns the list of joins.
QList< QgsSQLStatement::NodeTableDef * > tables() const
Returns the list of tables.
NodeSelectedColumn(QgsSQLStatement::Node *node)
Constructor.
void setAlias(const QString &alias)
Sets alias name.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::Node * column() const
Column that is referred to.
QString alias() const
Alias name.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
QString name() const
Table name.
NodeTableDef(const QString &name)
Constructor with table name.
NodeTableDef(const QString &name, const QString &alias)
Constructor with table name and alias.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QString alias() const
Table alias.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
Unary logicial/arithmetical operator ( NOT, - )
NodeUnaryOperator(QgsSQLStatement::UnaryOperator op, QgsSQLStatement::Node *operand)
Constructor.
void accept(QgsSQLStatement::Visitor &v) const override
Support the visitor pattern.
QgsSQLStatement::Node * operand() const
Operand.
QgsSQLStatement::UnaryOperator op() const
Operator.
QgsSQLStatement::NodeType nodeType() const override
Abstract virtual that returns the type of this node.
Abstract node class.
virtual QString dump() const =0
Abstract virtual dump method.
virtual ~Node()=default
virtual QgsSQLStatement::NodeType nodeType() const =0
Abstract virtual that returns the type of this node.
virtual QgsSQLStatement::Node * clone() const =0
Generate a clone of this node.
virtual void accept(QgsSQLStatement::Visitor &v) const =0
Support the visitor pattern.
A visitor that recursively explores all children.
void visit(const QgsSQLStatement::NodeFunction &n) override
Visit NodeFunction.
void visit(const QgsSQLStatement::NodeSelectedColumn &n) override
Visit NodeSelectedColumn.
void visit(const QgsSQLStatement::NodeUnaryOperator &n) override
Visit NodeUnaryOperator.
void visit(const QgsSQLStatement::NodeLiteral &) override
Visit NodeLiteral.
RecursiveVisitor()=default
Constructor.
void visit(const QgsSQLStatement::NodeBetweenOperator &n) override
Visit NodeBetweenOperator.
void visit(const QgsSQLStatement::NodeBinaryOperator &n) override
Visit NodeBinaryOperator.
void visit(const QgsSQLStatement::NodeColumnRef &) override
Visit NodeColumnRef.
void visit(const QgsSQLStatement::NodeTableDef &) override
Visit NodeTableDef.
void visit(const QgsSQLStatement::NodeColumnSorted &n) override
Visit NodeColumnSorted.
void visit(const QgsSQLStatement::NodeInOperator &n) override
Visit NodeInOperator.
void visit(const QgsSQLStatement::NodeCast &n) override
Visit NodeCast.
Support for visitor pattern - algorithms dealing with the statement may be implemented without modify...
virtual void visit(const QgsSQLStatement::NodeBetweenOperator &n)=0
Visit NodeBetweenOperator.
virtual ~Visitor()=default
virtual void visit(const QgsSQLStatement::NodeFunction &n)=0
Visit NodeFunction.
virtual void visit(const QgsSQLStatement::NodeColumnRef &n)=0
Visit NodeColumnRef.
virtual void visit(const QgsSQLStatement::NodeBinaryOperator &n)=0
Visit NodeBinaryOperator.
virtual void visit(const QgsSQLStatement::NodeSelect &n)=0
Visit NodeSelect.
virtual void visit(const QgsSQLStatement::NodeCast &n)=0
Visit NodeCast.
virtual void visit(const QgsSQLStatement::NodeSelectedColumn &n)=0
Visit NodeSelectedColumn.
virtual void visit(const QgsSQLStatement::NodeJoin &n)=0
Visit NodeJoin.
virtual void visit(const QgsSQLStatement::NodeUnaryOperator &n)=0
Visit NodeUnaryOperator.
virtual void visit(const QgsSQLStatement::NodeInOperator &n)=0
Visit NodeInOperator.
virtual void visit(const QgsSQLStatement::NodeLiteral &n)=0
Visit NodeLiteral.
virtual void visit(const QgsSQLStatement::NodeColumnSorted &n)=0
Visit NodeColumnSorted.
virtual void visit(const QgsSQLStatement::NodeTableDef &n)=0
Visit NodeTableDef.
Class for parsing SQL statements.
JoinType
list of join types
BinaryOperator
list of binary operators
QString mParserErrorString
UnaryOperator
list of unary operators
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:194
Q_DECLARE_METATYPE(QgsMeshTimeSettings)