This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqgsvirtuallayerfeatureiterator.h
71 lines (53 loc) · 2.45 KB
/
qgsvirtuallayerfeatureiterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***************************************************************************
qgsvirtuallayerfeatureiterator.h
Feature iterator for the virtual layer provider
begin : Feb 2015
copyright : (C) 2015 Hugo Mercier, Oslandia
email : hugo dot mercier at oslandia dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSVIRTUALLAYER_FEATURE_ITERATOR_H
#define QGSVIRTUALLAYER_FEATURE_ITERATOR_H
#include <qgsvirtuallayerprovider.h>
#include <qgsfeatureiterator.h>
class QgsVirtualLayerFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsVirtualLayerFeatureSource( const QgsVirtualLayerProvider* p );
~QgsVirtualLayerFeatureSource();
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) override;
const QgsVirtualLayerProvider* provider() const { return mProvider; }
private:
const QgsVirtualLayerProvider* mProvider;
};
class QgsVirtualLayerFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsVirtualLayerFeatureSource>
{
public:
QgsVirtualLayerFeatureIterator( QgsVirtualLayerFeatureSource* source, bool ownSource, const QgsFeatureRequest& request );
~QgsVirtualLayerFeatureIterator();
//! reset the iterator to the starting position
virtual bool rewind() override;
//! end of iterating: free the resources / lock
virtual bool close() override;
protected:
//! fetch next feature, return true on success
virtual bool fetchFeature( QgsFeature& feature ) override;
QScopedPointer<Sqlite::Query> mQuery;
QgsFeatureId mFid;
QString mPath;
QgsScopedSqlite mSqlite;
QgsVirtualLayerDefinition mDefinition;
QgsFields mFields;
QString mSqlQuery;
// Index of the id column, -1 if none
int mUidColumn;
QgsAttributeList mAttributes;
};
#endif