QGIS API Documentation
3.0.2-Girona (307d082)
|
Generic expression compiler for translation to provider specific SQL WHERE clauses. More...
#include <qgssqlexpressioncompiler.h>
Public Types | |
enum | Flag { CaseInsensitiveStringMatch = 1, LikeIsCaseInsensitive = 1 << 1, NoNullInBooleanLogic = 1 << 2, NoUnaryMinus = 1 << 3, IntegerDivisionResultsInInteger = 1 << 4 } |
Enumeration of flags for how provider handles SQL clauses. More... | |
enum | Result { None, Complete, Partial, Fail } |
Possible results from expression compilation. More... | |
Public Member Functions | |
QgsSqlExpressionCompiler (const QgsFields &fields, QgsSqlExpressionCompiler::Flags flags=Flags()) | |
Constructor for expression compiler. More... | |
virtual | ~QgsSqlExpressionCompiler ()=default |
virtual Result | compile (const QgsExpression *exp) |
Compiles an expression and returns the result of the compilation. More... | |
virtual QString | result () |
Returns the compiled expression string for use by the provider. More... | |
Protected Member Functions | |
virtual QString | castToInt (const QString &value) const |
Casts a value to a integer result. More... | |
virtual QString | castToReal (const QString &value) const |
Casts a value to a real result. More... | |
virtual Result | compileNode (const QgsExpressionNode *node, QString &str) |
Compiles an expression node and returns the result of the compilation. More... | |
virtual QString | quotedIdentifier (const QString &identifier) |
Returns a quoted column identifier, in the format expected by the provider. More... | |
virtual QString | quotedValue (const QVariant &value, bool &ok) |
Returns a quoted attribute value, in the format expected by the provider. More... | |
virtual QStringList | sqlArgumentsFromFunctionName (const QString &fnName, const QStringList &fnArgs) const |
Return the Arguments for SQL function for the expression function. More... | |
virtual QString | sqlFunctionFromFunctionName (const QString &fnName) const |
Return the SQL function for the expression function. More... | |
Protected Attributes | |
QgsFields | mFields |
QString | mResult |
Generic expression compiler for translation to provider specific SQL WHERE clauses.
This class is designed to be overridden by providers to take advantage of expression compilation, so that feature requests can take advantage of the provider's native filtering support.
Definition at line 39 of file qgssqlexpressioncompiler.h.
Enumeration of flags for how provider handles SQL clauses.
Enumerator | |
---|---|
CaseInsensitiveStringMatch | Provider performs case-insensitive string matching for all strings. |
LikeIsCaseInsensitive | Provider treats LIKE as case-insensitive. |
NoNullInBooleanLogic | Provider does not support using NULL with boolean logic, e.g., "(...) OR NULL". |
NoUnaryMinus | Provider does not unary minus, e.g., " -( 100 * 2 ) = ...". |
IntegerDivisionResultsInInteger | Dividing int by int results in int on provider. Subclass must implement the castToReal() function to allow compilation of division. |
Definition at line 55 of file qgssqlexpressioncompiler.h.
Possible results from expression compilation.
Definition at line 44 of file qgssqlexpressioncompiler.h.
|
explicit |
Constructor for expression compiler.
fields | fields from provider |
flags | flags which control how expression is compiled |
Definition at line 21 of file qgssqlexpressioncompiler.cpp.
|
virtualdefault |
|
protectedvirtual |
Casts a value to a integer result.
Subclasses must reimplement this to cast a numeric value to a integer type value so that integer division results in a integer value result instead of real.
Definition at line 412 of file qgssqlexpressioncompiler.cpp.
|
protectedvirtual |
Casts a value to a real result.
Subclasses which indicate the IntegerDivisionResultsInInteger flag must reimplement this to cast a numeric value to a real type value so that division results in a real value result instead of integer.
Definition at line 406 of file qgssqlexpressioncompiler.cpp.
|
virtual |
Compiles an expression and returns the result of the compilation.
Definition at line 28 of file qgssqlexpressioncompiler.cpp.
|
protectedvirtual |
Compiles an expression node and returns the result of the compilation.
node | expression node to compile |
str | string representing compiled node should be stored in this parameter |
Definition at line 77 of file qgssqlexpressioncompiler.cpp.
|
protectedvirtual |
Returns a quoted column identifier, in the format expected by the provider.
Derived classes should override this if special handling of column identifiers is required.
Definition at line 41 of file qgssqlexpressioncompiler.cpp.
|
protectedvirtual |
Returns a quoted attribute value, in the format expected by the provider.
Derived classes should override this if special handling of attribute values is required.
value | value to quote |
ok | wil be set to true if value can be compiled |
Definition at line 49 of file qgssqlexpressioncompiler.cpp.
|
virtual |
Returns the compiled expression string for use by the provider.
Definition at line 36 of file qgssqlexpressioncompiler.cpp.
|
protectedvirtual |
Return the Arguments for SQL function for the expression function.
Derived classes should override this to help compile functions
fnName | expression function name |
fnArgs | arguments from expression |
Definition at line 400 of file qgssqlexpressioncompiler.cpp.
|
protectedvirtual |
Return the SQL function for the expression function.
Derived classes should override this to help compile functions
fnName | expression function name |
Definition at line 394 of file qgssqlexpressioncompiler.cpp.
|
protected |
Definition at line 143 of file qgssqlexpressioncompiler.h.
|
protected |
Definition at line 142 of file qgssqlexpressioncompiler.h.