From 8ba442f14a23a004ac204a2308f335ea1f65bf05 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 7 Sep 2018 10:57:37 +0200 Subject: [PATCH] Const correctness for QgsGeometry::Error --- .../geometry/qgsgeometry.sip.in | 7 +++--- src/core/geometry/qgsgeometry.cpp | 15 +++++++++++ src/core/geometry/qgsgeometry.h | 25 ++++++++++--------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/python/core/auto_generated/geometry/qgsgeometry.sip.in b/python/core/auto_generated/geometry/qgsgeometry.sip.in index 5baa44181ff..4fdeda7a614 100644 --- a/python/core/auto_generated/geometry/qgsgeometry.sip.in +++ b/python/core/auto_generated/geometry/qgsgeometry.sip.in @@ -1481,9 +1481,10 @@ by calling `error()` on the returned geometry. explicit Error( const QString &m ); Error( const QString &m, const QgsPointXY &p ); - QString what(); - QgsPointXY where(); - bool hasWhere(); + QString what() const; + QgsPointXY where() const; + bool hasWhere() const; + }; enum ValidationMethod diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index 23db3272525..32b96e5f737 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -3288,3 +3288,18 @@ QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry ) return in; } + +QString QgsGeometry::Error::what() const +{ + return mMessage; +} + +QgsPointXY QgsGeometry::Error::where() const +{ + return mLocation; +} + +bool QgsGeometry::Error::hasWhere() const +{ + return mHasLocation; +} diff --git a/src/core/geometry/qgsgeometry.h b/src/core/geometry/qgsgeometry.h index f11585de1ee..3b4665391d2 100644 --- a/src/core/geometry/qgsgeometry.h +++ b/src/core/geometry/qgsgeometry.h @@ -1418,27 +1418,28 @@ class CORE_EXPORT QgsGeometry */ class CORE_EXPORT Error { - QString message; - QgsPointXY location; - bool hasLocation = false; - public: Error() - : message( QStringLiteral( "none" ) ) + : mMessage( QStringLiteral( "none" ) ) {} explicit Error( const QString &m ) - : message( m ) + : mMessage( m ) {} Error( const QString &m, const QgsPointXY &p ) - : message( m ) - , location( p ) - , hasLocation( true ) {} + : mMessage( m ) + , mLocation( p ) + , mHasLocation( true ) {} - QString what() { return message; } - QgsPointXY where() { return location; } - bool hasWhere() { return hasLocation; } + QString what() const; + QgsPointXY where() const; + bool hasWhere() const; + + private: + QString mMessage; + QgsPointXY mLocation; + bool mHasLocation = false; }; /**