/usr/include/qgis/qgsfeatureiterator.h is in libqgis-dev 2.0.1-2build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | /***************************************************************************
qgsfeatureiterator.h
---------------------
begin : Juli 2012
copyright : (C) 2012 by Martin Dobias
email : wonder dot sk at gmail 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 QGSFEATUREITERATOR_H
#define QGSFEATUREITERATOR_H
#include "qgsfeaturerequest.h"
/** \ingroup core
* Internal feature iterator to be implemented within data providers
*/
class CORE_EXPORT QgsAbstractFeatureIterator
{
public:
//! base class constructor - stores the iteration parameters
QgsAbstractFeatureIterator( const QgsFeatureRequest& request );
//! destructor makes sure that the iterator is closed properly
virtual ~QgsAbstractFeatureIterator();
//! fetch next feature, return true on success
virtual bool nextFeature( QgsFeature& f ) = 0;
//! reset the iterator to the starting position
virtual bool rewind() = 0;
//! end of iterating: free the resources / lock
virtual bool close() = 0;
protected:
QgsFeatureRequest mRequest;
bool mClosed;
// reference counting (to allow seamless copying of QgsFeatureIterator instances)
int refs;
void ref(); // add reference
void deref(); // remove reference, delete if refs == 0
friend class QgsFeatureIterator;
};
/**
* \ingroup core
* Wrapper for iterator of features from vector data provider or vector layer
*/
class CORE_EXPORT QgsFeatureIterator
{
public:
//! construct invalid iterator
QgsFeatureIterator();
//! construct a valid iterator
QgsFeatureIterator( QgsAbstractFeatureIterator* iter );
//! copy constructor copies the iterator, increases ref.count
QgsFeatureIterator( const QgsFeatureIterator& fi );
//! destructor deletes the iterator if it has no more references
~QgsFeatureIterator();
QgsFeatureIterator& operator=( const QgsFeatureIterator& other );
bool nextFeature( QgsFeature& f );
bool rewind();
bool close();
//! find out whether the iterator is still valid or closed already
bool isClosed() const;
friend bool operator== ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 );
friend bool operator!= ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 );
protected:
QgsAbstractFeatureIterator* mIter;
};
////////
inline QgsFeatureIterator::QgsFeatureIterator()
: mIter( NULL )
{
}
inline QgsFeatureIterator::QgsFeatureIterator( QgsAbstractFeatureIterator* iter )
: mIter( iter )
{
if ( iter )
iter->ref();
}
inline QgsFeatureIterator::QgsFeatureIterator( const QgsFeatureIterator& fi )
: mIter( fi.mIter )
{
if ( mIter )
mIter->ref();
}
inline QgsFeatureIterator::~QgsFeatureIterator()
{
if ( mIter )
mIter->deref();
}
inline bool QgsFeatureIterator::nextFeature( QgsFeature& f )
{
return mIter ? mIter->nextFeature( f ) : false;
}
inline bool QgsFeatureIterator::rewind()
{
return mIter ? mIter->rewind() : false;
}
inline bool QgsFeatureIterator::close()
{
return mIter ? mIter->close() : false;
}
inline bool QgsFeatureIterator::isClosed() const
{
return mIter ? mIter->mClosed : true;
}
inline bool operator== ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 )
{
return ( fi1.mIter == fi2.mIter );
}
inline bool operator!= ( const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2 )
{
return !( fi1 == fi2 );
}
#endif // QGSFEATUREITERATOR_H
|