QGIS API Documentation  2.14.0-Essen
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  };
53  Q_DECLARE_FLAGS( Flags, Flag )
54 
55 
59  explicit QgsSqlExpressionCompiler( const QgsFields& fields, const Flags& flags = Flags() );
60  virtual ~QgsSqlExpressionCompiler();
61 
64  virtual Result compile( const QgsExpression* exp );
65 
68  virtual QString result() { return mResult; }
69 
70  protected:
71 
77  virtual QString quotedIdentifier( const QString& identifier );
78 
85  virtual QString quotedValue( const QVariant& value, bool &ok );
86 
92  virtual Result compileNode( const QgsExpression::Node* node, QString& str );
93 
96 
97  private:
98 
99  Flags mFlags;
100 
101 };
102 
103 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSqlExpressionCompiler::Flags )
104 
105 #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.