Skip to content
Permalink
Browse files
Nicer initialization of members in iterators/sources
  • Loading branch information
nyalldawson committed Apr 23, 2017
1 parent 706b5a8 commit 3584a5f9148d7a15abbbee5922053c4164f4ff05
@@ -39,9 +39,7 @@ QgsAfsProvider *QgsAfsFeatureSource::provider() const

QgsAfsFeatureIterator::QgsAfsFeatureIterator( QgsAfsFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsAfsFeatureSource>( source, ownSource, request )
{
mFeatureIterator = 0;
}
{}

QgsAfsFeatureIterator::~QgsAfsFeatureIterator()
{
@@ -47,7 +47,7 @@ class QgsAfsFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsAfs
bool fetchFeature( QgsFeature &f ) override;

private:
QgsFeatureId mFeatureIterator;
QgsFeatureId mFeatureIterator = 0;
};

#endif // QGSAFSFEATUREITERATOR_H
@@ -32,7 +32,6 @@ QgsDb2FeatureIterator::QgsDb2FeatureIterator( QgsDb2FeatureSource *source, bool
: QgsAbstractFeatureIteratorFromSource<QgsDb2FeatureSource>( source, ownSource, request )
{
mClosed = false;
mFetchCount = 0;

BuildStatement( request );

@@ -446,15 +445,14 @@ bool QgsDb2FeatureIterator::close()
QgsDb2FeatureSource::QgsDb2FeatureSource( const QgsDb2Provider *p )
: mFields( p->mAttributeFields )
, mFidColName( p->mFidColName )
, mSRId( p->mSRId )
, mGeometryColName( p->mGeometryColName )
, mGeometryColType( p->mGeometryColType )
, mSchemaName( p->mSchemaName )
, mTableName( p->mTableName )
, mConnInfo( p->mConnInfo )
, mSqlWhereClause( p->mSqlWhereClause )
{
mSRId = p->mSRId;
}
{}

QgsDb2FeatureSource::~QgsDb2FeatureSource()
{
@@ -99,7 +99,7 @@ class QgsDb2FeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsDb2
bool mExpressionCompiled;
bool mOrderByCompiled;

int mFetchCount;
int mFetchCount = 0;
};

#endif // QGSDB2FEATUREITERATOR_H
@@ -28,8 +28,7 @@

QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTextFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsDelimitedTextFeatureSource>( source, ownSource, request )
, mNextId( 0 )
, mTestGeometryExact( false )
, mTestSubset( mSource->mSubsetExpression )
{

// Determine mode to use based on request...
@@ -39,14 +38,6 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe
// load it.
bool hasGeometry = mSource->mGeomRep != QgsDelimitedTextProvider::GeomNone;

// Does the layer have an explicit or implicit subset (implicit subset is if we have geometry which can
// be invalid)

mTestSubset = mSource->mSubsetExpression;
mTestGeometry = false;

mMode = FileScan;

if ( !request.filterRect().isNull() && hasGeometry )
{
QgsDebugMsg( "Configuring for rectangle select" );
@@ -88,12 +88,12 @@ class QgsDelimitedTextFeatureIterator : public QgsAbstractFeatureIteratorFromSou
void fetchAttribute( QgsFeature &feature, int fieldIdx, const QStringList &tokens );

QList<QgsFeatureId> mFeatureIds;
IteratorMode mMode;
long mNextId;
bool mTestSubset;
bool mTestGeometry;
bool mTestGeometryExact;
bool mLoadGeometry;
IteratorMode mMode = FileScan;
long mNextId = 0;
bool mTestSubset = false;
bool mTestGeometry = false;
bool mTestGeometryExact = false;
bool mLoadGeometry = false;
};


@@ -27,7 +27,6 @@

QgsGPXFeatureIterator::QgsGPXFeatureIterator( QgsGPXFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsGPXFeatureSource>( source, ownSource, request )
, mFetchedFid( false )
{
rewind();
}
@@ -79,7 +79,7 @@ class QgsGPXFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsGPX
//! Current track iterator
QgsGPSData::TrackIterator mTrkIter;

bool mFetchedFid;
bool mFetchedFid = false;
};

#endif // QGSGPXFEATUREITERATOR_H
@@ -69,9 +69,6 @@ void copy_boxlist_and_destroy( struct boxlist *blist, struct ilist *list )

QgsGrassFeatureIterator::QgsGrassFeatureIterator( QgsGrassFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsGrassFeatureSource>( source, ownSource, request )
, mCanceled( false )
, mNextCidx( 0 )
, mNextLid( 1 )
{

// WARNING: the iterater cannot use mutex lock for its whole life, because QgsVectorLayerFeatureIterator is opening
@@ -136,18 +136,16 @@ class GRASS_LIB_EXPORT QgsGrassFeatureIterator : public QObject, public QgsAbstr
void setFeatureAttributes( int cat, QgsFeature *feature, const QgsAttributeList &attlist, QgsGrassVectorMap::TopoSymbol symbol );

//! Canceled -> close when possible
bool mCanceled;
bool mCanceled = false;

//! Selection array
QBitArray mSelection; // !UPDATE!

// Edit mode is using mNextLid + mNextCidx
// Next index in cidxFieldIndex to be read in standard mode or next index of line Cats in editing mode
int mNextCidx;
int mNextCidx = 0;
// Next topology line/node id to be read in topo mode or next line id in edit mode, starts from 1
int mNextLid;


int mNextLid = 1;

static QMutex sMutex;
};
@@ -25,8 +25,6 @@

QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsMemoryFeatureSource>( source, ownSource, request )
, mSelectRectGeom( nullptr )
, mSubsetExpression( nullptr )
{
if ( !mSource->mSubsetString.isEmpty() )
{
@@ -65,7 +65,7 @@ class QgsMemoryFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs

QgsGeometry mSelectRectGeom;
QgsFeatureMap::const_iterator mSelectIterator;
bool mUsingFeatureIdList;
bool mUsingFeatureIdList = false;
QList<QgsFeatureId> mFeatureIdList;
QList<QgsFeatureId>::const_iterator mFeatureIdListIterator;
QgsExpression *mSubsetExpression = nullptr;
@@ -28,8 +28,6 @@

QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsMssqlFeatureSource>( source, ownSource, request )
, mExpressionCompiled( false )
, mOrderByCompiled( false )
{
mClosed = false;

@@ -443,6 +441,8 @@ bool QgsMssqlFeatureIterator::close()
QgsMssqlFeatureSource::QgsMssqlFeatureSource( const QgsMssqlProvider *p )
: mFields( p->mAttributeFields )
, mFidColName( p->mFidColName )
, mSRId( p->mSRId )
, mIsGeography( p->mParser.IsGeography )
, mGeometryColName( p->mGeometryColName )
, mGeometryColType( p->mGeometryColType )
, mSchemaName( p->mSchemaName )
@@ -453,10 +453,7 @@ QgsMssqlFeatureSource::QgsMssqlFeatureSource( const QgsMssqlProvider *p )
, mDatabaseName( p->mDatabaseName )
, mHost( p->mHost )
, mSqlWhereClause( p->mSqlWhereClause )
{
mSRId = p->mSRId;
mIsGeography = p->mParser.IsGeography;
}
{}

QgsFeatureIterator QgsMssqlFeatureSource::getFeatures( const QgsFeatureRequest &request )
{
@@ -40,7 +40,7 @@ class QgsMssqlFeatureSource : public QgsAbstractFeatureSource
long mSRId;

/* sql geo type */
bool mIsGeography;
bool mIsGeography = false;

QString mGeometryColName;
QString mGeometryColType;
@@ -104,16 +104,16 @@ class QgsMssqlFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsM
QString mFallbackStatement;

// Field index of FID column
long mFidCol;
long mFidCol = -1;

// List of attribute indices to fetch with nextFeature calls
QgsAttributeList mAttributesToFetch;

// for parsing sql geometries
QgsMssqlGeometryParser mParser;

bool mExpressionCompiled;
bool mOrderByCompiled;
bool mExpressionCompiled = false;
bool mOrderByCompiled = false;
};

#endif // QGSMSSQLFEATUREITERATOR_H
@@ -353,18 +353,18 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature &feature )


QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider *p )
: mDataSource( p->dataSourceUri() )
, mLayerName( p->layerName() )
, mLayerIndex( p->layerIndex() )
, mSubsetString( p->mSubsetString )
, mEncoding( p->textEncoding() ) // no copying - this is a borrowed pointer from Qt
, mFields( p->mAttributeFields )
, mFirstFieldIsFid( p->mFirstFieldIsFid )
, mOgrGeometryTypeFilter( QgsOgrProvider::ogrWkbSingleFlatten( p->mOgrGeometryTypeFilter ) )
, mDriverName( p->ogrDriverName )
{
mDataSource = p->dataSourceUri();
mLayerName = p->layerName();
mLayerIndex = p->layerIndex();
mSubsetString = p->mSubsetString;
mEncoding = p->textEncoding(); // no copying - this is a borrowed pointer from Qt
mFields = p->mAttributeFields;
for ( int i = ( p->mFirstFieldIsFid ) ? 1 : 0; i < mFields.size(); i++ )
mFieldsWithoutFid.append( mFields.at( i ) );
mDriverName = p->ogrDriverName;
mFirstFieldIsFid = p->mFirstFieldIsFid;
mOgrGeometryTypeFilter = QgsOgrProvider::ogrWkbSingleFlatten( p->mOgrGeometryTypeFilter );
QgsOgrConnPool::instance()->ref( mDataSource );
}

@@ -799,6 +799,7 @@ void QgsPostgresFeatureIterator::getFeatureAttribute( int idx, QgsPostgresResult
QgsPostgresFeatureSource::QgsPostgresFeatureSource( const QgsPostgresProvider *p )
: mConnInfo( p->mUri.connectionInfo( false ) )
, mGeometryColumn( p->mGeometryColumn )
, mSqlWhereClause( p->filterWhereClause() )
, mFields( p->mAttributeFields )
, mSpatialColType( p->mSpatialColType )
, mRequestedSrid( p->mRequestedSrid )
@@ -811,8 +812,6 @@ QgsPostgresFeatureSource::QgsPostgresFeatureSource( const QgsPostgresProvider *p
, mQuery( p->mQuery )
, mShared( p->mShared )
{
mSqlWhereClause = p->filterWhereClause();

if ( mSqlWhereClause.startsWith( QLatin1String( " WHERE " ) ) )
mSqlWhereClause = mSqlWhereClause.mid( 7 );

0 comments on commit 3584a5f

Please sign in to comment.