QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgssqlexpressioncompiler.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssqlexpressioncompiler.h
3  --------------------------
4  begin : November 2015
5  copyright : (C) 2015 Nyall Dawson
6  email : nyall dot dawson 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 QGSSQLEXPRESSIONCOMPILER_H
17 #define QGSSQLEXPRESSIONCOMPILER_H
18 
19 #include "qgsexpression.h"
20 #include "qgsfield.h"
21 
33 class CORE_EXPORT QgsSqlExpressionCompiler
34 {
35  public:
36 
38  enum Result
39  {
40  None,
43  Fail
44  };
45 
48  enum Flag
49  {
50  CaseInsensitiveStringMatch = 0x01,
51  LikeIsCaseInsensitive = 0x02,
52  NoNullInBooleanLogic = 0x04,
53  NoUnaryMinus = 0x08,
54  };
55  Q_DECLARE_FLAGS( Flags, Flag )
56 
57 
61  explicit QgsSqlExpressionCompiler( const QgsFields& fields, const Flags& flags = Flags() );
62  virtual ~QgsSqlExpressionCompiler();
63 
66  virtual Result compile( const QgsExpression* exp );
67 
70  virtual QString result() { return mResult; }
71 
72  protected:
73 
79  virtual QString quotedIdentifier( const QString& identifier );
80 
87  virtual QString quotedValue( const QVariant& value, bool &ok );
88 
94  virtual Result compileNode( const QgsExpression::Node* node, QString& str );
95 
98 
99  private:
100 
101  Flags mFlags;
102 
103  bool nodeIsNullLiteral( const QgsExpression::Node* node ) const;
104 
105 };
106 
107 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSqlExpressionCompiler::Flags )
108 
109 #endif // QGSSQLEXPRESSIONCOMPILER_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Container of fields for a vector layer.
Definition: qgsfield.h:252
Flag
Enumeration of flags for how provider handles SQL clauses.
virtual QString result()
Returns the compiled expression string for use by the provider.
Generic expression compiler for translation to provider specific SQL WHERE clauses.
Result
Possible results from expression compilation.