Skip to content

Commit

Permalink
Add uuid function for expression engine
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Oct 10, 2013
1 parent 2cd8938 commit 6242025
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/qgsexpression.cpp
Expand Up @@ -21,6 +21,7 @@
#include <QDate>
#include <QRegExp>
#include <QColor>
#include <QUuid>

#include <math.h>
#include <limits>
Expand Down Expand Up @@ -696,6 +697,11 @@ static QVariant fcnRegexpSubstr( const QVariantList& values, const QgsFeature* ,
}
}

static QVariant fcnUuid( const QVariantList& values, const QgsFeature* , QgsExpression* parent )
{
return QUuid::createUuid().toString();
}

static QVariant fcnSubstr( const QVariantList& values, const QgsFeature* , QgsExpression* parent )
{
QString str = getStringValue( values.at( 0 ), parent );
Expand Down Expand Up @@ -1532,6 +1538,7 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
<< new StaticFunction( "$rownum", 0, fcnRowNumber, "Record" )
<< new StaticFunction( "$id", 0, fcnFeatureId, "Record" )
<< new StaticFunction( "$scale", 0, fcnScale, "Record" )
<< new StaticFunction( "$uuid", 0, fcnUuid, "Record" )
<< new StaticFunction( "_specialcol_", 1, fcnSpecialColumn, "Special" )
;
}
Expand Down

0 comments on commit 6242025

Please sign in to comment.