QGIS API Documentation  2.14.11-Essen
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  };
54  Q_DECLARE_FLAGS( Flags, Flag )
55 
56 
60  explicit QgsSqlExpressionCompiler( const QgsFields& fields, const Flags& flags = Flags() );
61  virtual ~QgsSqlExpressionCompiler();
62 
65  virtual Result compile( const QgsExpression* exp );
66 
69  virtual QString result() { return mResult; }
70 
71  protected:
72 
78  virtual QString quotedIdentifier( const QString& identifier );
79 
86  virtual QString quotedValue( const QVariant& value, bool &ok );
87 
93  virtual Result compileNode( const QgsExpression::Node* node, QString& str );
94 
97 
98  private:
99 
100  Flags mFlags;
101 
102  bool nodeIsNullLiteral( const QgsExpression::Node* node ) const;
103 
104 };
105 
106 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSqlExpressionCompiler::Flags )
107 
108 #endif // QGSSQLEXPRESSIONCOMPILER_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Container of fields for a vector layer.
Definition: qgsfield.h:187
Flag
Enumeration of flags for how provider handles SQL clauses.
Generic expression compiler for translation to provider specific SQL WHERE clauses.
Result
Possible results from expression compilation.