Add lazy evaluation support to expression functions and if function

Adds lazy evaluation support for functions to QgsExpression. Lazy functions are passed the expression node rather than the result. Functions can decide what to do with each node it is given. 

Also add `if(cond, true, false)` function using lazy evaluation feature. Each branch of the `if` is evaluate as needed rather than up front.
Yep no worries will do.

On Sat, 13 Dec 2014 1:15 pm Martin Dobias <notifications@github.com> wrote:

> In src/core/qgsexpression.cpp
> <https://github.com/qgis/QGIS/pull/1733#discussion-diff-21785572>:
>
> > +{
> > +  QgsExpression::Node* node = getNode( values.at( 0 ), parent );
> > +  ENSURE_NO_EVAL_ERROR;
> > +  QVariant value = node->eval( parent, f );
> > +  if ( value.toBool() ) {
> > +    node = getNode( values.at( 1 ), parent );
> > +    ENSURE_NO_EVAL_ERROR;
> > +    value = node->eval( parent, f );
> > +  }
> > +  else {
> > +    node = getNode( values.at( 2 ), parent );
> > +    ENSURE_NO_EVAL_ERROR;
> > +    value = node->eval( parent, f );
> > +  }
> > +  return value;
> > +}
>
> I think there should be ENSURE_NO_EVAL_ERROR also after node->eval() calls.
> Otherwise the PR looks good to me.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/qgis/QGIS/pull/1733/files#r21785572>.
>