Skip to content
Permalink
Browse files

Return expression string from QgsExpression::expression(). Don't use …

…::dump()
  • Loading branch information
NathanW2 committed Nov 13, 2013
1 parent 4153ef9 commit e890e14938439148c77d2cf5a4b8fc69fc371261
@@ -1619,6 +1619,7 @@ QgsExpression::QgsExpression( const QString& expr )
: mRowNumber( 0 )
, mScale( 0 )
, mCalc( 0 )
, mExp( expr )
{
mRootNode = ::parseExpression( expr, mParserErrorString );

@@ -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
@@ -608,6 +610,7 @@ class CORE_EXPORT QgsExpression

int mRowNumber;
double mScale;
QString mExp;

static QMap<QString, QVariant> gmSpecialColumns;
QgsDistanceArea *mCalc;
@@ -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 )
{
}
@@ -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
{
@@ -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 ) )
{
@@ -627,7 +627,7 @@ QgsRuleBasedRendererV2::Rule* QgsRuleBasedRendererV2::Rule::createFromSld( QDomE
}
else
{
filterExp = filter->dump();
filterExp = filter->expression();
}
delete filter;
}
@@ -2259,7 +2259,7 @@ bool QgsSymbolLayerV2Utils::functionFromSldElement( QDomElement &element, QStrin
}
else
{
function = expr->dump();
function = expr->expression();
}

delete expr;
@@ -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 );
}
@@ -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;
}
@@ -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 ) );

0 comments on commit e890e14

Please sign in to comment.
You can’t perform that action at this time.