Skip to content

Commit

Permalink
Return expression string from QgsExpression::expression(). Don't use …
Browse files Browse the repository at this point in the history
…::dump()
  • Loading branch information
NathanW2 committed Nov 13, 2013
1 parent 4153ef9 commit e890e14
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/core/qgsexpression.cpp
Expand Up @@ -1619,6 +1619,7 @@ QgsExpression::QgsExpression( const QString& expr )
: mRowNumber( 0 )
, mScale( 0 )
, mCalc( 0 )
, mExp( expr )
{
mRootNode = ::parseExpression( expr, mParserErrorString );

Expand Down
9 changes: 6 additions & 3 deletions src/core/qgsexpression.h
Expand Up @@ -151,10 +151,12 @@ class CORE_EXPORT QgsExpression

int scale() {return mScale; }

//! Alias for {@link dump()}
const QString expression() const { return dump(); }
//! Return the expression string that was given when created.
const QString expression() const { return mExp; }

//! Return the parsed expression as a string - useful for debugging
//! Return the a debugging string of the expression.
//! This can be used for debugging. Use {@link expression()}
//! if you need the full expression string.
QString dump() const;

//! Return calculator used for distance and area calculations
Expand Down Expand Up @@ -608,6 +610,7 @@ class CORE_EXPORT QgsExpression

int mRowNumber;
double mScale;
QString mExp;

static QMap<QString, QVariant> gmSpecialColumns;
QgsDistanceArea *mCalc;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsfeaturerequest.cpp
Expand Up @@ -44,7 +44,7 @@ QgsFeatureRequest::QgsFeatureRequest( const QgsRectangle& rect )

QgsFeatureRequest::QgsFeatureRequest( const QgsExpression& expr )
: mFilter( FilterExpression )
, mFilterExpression( new QgsExpression( expr.dump() ) )
, mFilterExpression( new QgsExpression( expr.expression() ) )
, mFlags( 0 )
{
}
Expand All @@ -63,7 +63,7 @@ QgsFeatureRequest& QgsFeatureRequest::operator=( const QgsFeatureRequest & rh )
mFilterFids = rh.mFilterFids;
if ( rh.mFilterExpression )
{
mFilterExpression = new QgsExpression( rh.mFilterExpression->dump() );
mFilterExpression = new QgsExpression( rh.mFilterExpression->expression() );
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Expand Up @@ -308,15 +308,15 @@ void QgsEllipseSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElement &el
{

if ( rotationExpression )
angleFunc = rotationExpression->dump();
angleFunc = rotationExpression->expression();
else if ( !qgsDoubleNear( mAngle, 0.0 ) )
angleFunc = QString::number( mAngle );
}
else if ( rotationExpression )
{
// the symbol has an angle and the symbol layer have a rotation
// property set
angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( rotationExpression->dump() );
angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( rotationExpression->expression() );
}
else if ( !qgsDoubleNear( mAngle, 0.0 ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Expand Up @@ -627,7 +627,7 @@ QgsRuleBasedRendererV2::Rule* QgsRuleBasedRendererV2::Rule::createFromSld( QDomE
}
else
{
filterExp = filter->dump();
filterExp = filter->expression();
}
delete filter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgssymbollayerv2utils.cpp
Expand Up @@ -2259,7 +2259,7 @@ bool QgsSymbolLayerV2Utils::functionFromSldElement( QDomElement &element, QStrin
}
else
{
function = expr->dump();
function = expr->expression();
}

delete expr;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsexpression.cpp
Expand Up @@ -100,7 +100,7 @@ class TestQgsExpression: public QObject
if ( exp.hasParserError() )
qDebug() << "Parser error: " << exp.parserErrorString();
else
qDebug() << "Parsed string: " << exp.dump();
qDebug() << "Parsed string: " << exp.expression();

QCOMPARE( !exp.hasParserError(), valid );
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/testqgsogcutils.cpp
Expand Up @@ -204,13 +204,13 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter()
QVERIFY( expr );

qDebug( "OGC XML : %s", xmlText.toAscii().data() );
qDebug( "EXPR-DUMP: %s", expr->dump().toAscii().data() );
qDebug( "EXPR-DUMP: %s", expr->expression().toAscii().data() );

if ( expr->hasParserError() )
qDebug( "ERROR: %s ", expr->parserErrorString().toAscii().data() );
QVERIFY( !expr->hasParserError() );

QCOMPARE( dumpText, expr->dump() );
QCOMPARE( dumpText, expr->expression() );

delete expr;
}
Expand All @@ -234,7 +234,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilter()

doc.appendChild( filterElem );

qDebug( "EXPR: %s", exp.dump().toAscii().data() );
qDebug( "EXPR: %s", exp.expression().toAscii().data() );
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );

QCOMPARE( xmlText, doc.toString( -1 ) );
Expand Down

0 comments on commit e890e14

Please sign in to comment.