LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts - ogrsf_frmts.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 30 30 100.0 %
Date: 2025-03-28 11:40:40 Functions: 37 39 94.9 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  OpenGIS Simple Features Reference Implementation
       4             :  * Purpose:  Classes related to format registration, and file opening.
       5             :  * Author:   Frank Warmerdam, warmerda@home.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 1999,  Les Technologies SoftMap Inc.
       9             :  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #ifndef OGRSF_FRMTS_H_INCLUDED
      15             : #define OGRSF_FRMTS_H_INCLUDED
      16             : 
      17             : #include "cpl_progress.h"
      18             : #include "ogr_feature.h"
      19             : #include "ogr_featurestyle.h"
      20             : #include "gdal_priv.h"
      21             : 
      22             : #include <memory>
      23             : #include <deque>
      24             : 
      25             : /**
      26             :  * \file ogrsf_frmts.h
      27             :  *
      28             :  * Classes related to registration of format support, and opening datasets.
      29             :  */
      30             : 
      31             : //! @cond Doxygen_Suppress
      32             : #if !defined(GDAL_COMPILATION) && !defined(SUPPRESS_DEPRECATION_WARNINGS)
      33             : #define OGR_DEPRECATED(x) CPL_WARN_DEPRECATED(x)
      34             : #else
      35             : #define OGR_DEPRECATED(x)
      36             : #endif
      37             : //! @endcond
      38             : 
      39             : class OGRLayerAttrIndex;
      40             : class OGRSFDriver;
      41             : 
      42             : struct ArrowArrayStream;
      43             : 
      44             : /************************************************************************/
      45             : /*                               OGRLayer                               */
      46             : /************************************************************************/
      47             : 
      48             : /**
      49             :  * This class represents a layer of simple features, with access methods.
      50             :  *
      51             :  */
      52             : 
      53             : /* Note: any virtual method added to this class must also be added in the */
      54             : /* OGRLayerDecorator and OGRMutexedLayer classes. */
      55             : 
      56             : class CPL_DLL OGRLayer : public GDALMajorObject
      57             : {
      58             :   private:
      59             :     struct Private;
      60             :     std::unique_ptr<Private> m_poPrivate;
      61             : 
      62             :     void ConvertGeomsIfNecessary(OGRFeature *poFeature);
      63             : 
      64             :     class CPL_DLL FeatureIterator
      65             :     {
      66             :         struct Private;
      67             :         std::unique_ptr<Private> m_poPrivate;
      68             : 
      69             :       public:
      70             :         FeatureIterator(OGRLayer *poLayer, bool bStart);
      71             :         FeatureIterator(
      72             :             FeatureIterator &&oOther) noexcept;  // declared but not defined.
      73             :                                                  // Needed for gcc 5.4 at least
      74             :         ~FeatureIterator();
      75             :         OGRFeatureUniquePtr &operator*();
      76             :         FeatureIterator &operator++();
      77             :         bool operator!=(const FeatureIterator &it) const;
      78             :     };
      79             : 
      80             :     friend inline FeatureIterator begin(OGRLayer *poLayer);
      81             :     friend inline FeatureIterator end(OGRLayer *poLayer);
      82             : 
      83             :     CPL_DISALLOW_COPY_ASSIGN(OGRLayer)
      84             : 
      85             :   protected:
      86             :     //! @cond Doxygen_Suppress
      87             :     int m_bFilterIsEnvelope;
      88             :     OGRGeometry *m_poFilterGeom;
      89             :     OGRPreparedGeometry *m_pPreparedFilterGeom; /* m_poFilterGeom compiled as a
      90             :                                                    prepared geometry */
      91             :     OGREnvelope m_sFilterEnvelope;
      92             :     int m_iGeomFieldFilter;  // specify the index on which the spatial
      93             :                              // filter is active.
      94             : 
      95             :     int FilterGeometry(const OGRGeometry *);
      96             :     // int          FilterGeometry( OGRGeometry *, OGREnvelope*
      97             :     // psGeometryEnvelope);
      98             :     int InstallFilter(const OGRGeometry *);
      99             :     bool
     100             :     ValidateGeometryFieldIndexForSetSpatialFilter(int iGeomField,
     101             :                                                   const OGRGeometry *poGeomIn,
     102             :                                                   bool bIsSelectLayer = false);
     103             :     //! @endcond
     104             : 
     105             :     virtual OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
     106             :                               bool bForce) CPL_WARN_UNUSED_RESULT;
     107             : 
     108             :     virtual OGRErr IGetExtent3D(int iGeomField, OGREnvelope3D *psExtent3D,
     109             :                                 bool bForce) CPL_WARN_UNUSED_RESULT;
     110             : 
     111             :     virtual OGRErr ISetSpatialFilter(int iGeomField, const OGRGeometry *);
     112             : 
     113             :     virtual OGRErr ISetFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
     114             :     virtual OGRErr ICreateFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
     115             :     virtual OGRErr IUpsertFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
     116             :     virtual OGRErr
     117             :     IUpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
     118             :                    const int *panUpdatedFieldsIdx, int nUpdatedGeomFieldsCount,
     119             :                    const int *panUpdatedGeomFieldsIdx,
     120             :                    bool bUpdateStyleString) CPL_WARN_UNUSED_RESULT;
     121             : 
     122             :     //! @cond Doxygen_Suppress
     123             :     CPLStringList m_aosArrowArrayStreamOptions{};
     124             : 
     125             :     friend struct OGRGenSQLResultsLayerArrowStreamPrivateData;
     126             : 
     127             :     struct ArrowArrayStreamPrivateData
     128             :     {
     129             :         bool m_bArrowArrayStreamInProgress = false;
     130             :         bool m_bEOF = false;
     131             :         OGRLayer *m_poLayer = nullptr;
     132             :         std::vector<GIntBig> m_anQueriedFIDs{};
     133             :         size_t m_iQueriedFIDS = 0;
     134             :         std::deque<std::unique_ptr<OGRFeature>> m_oFeatureQueue{};
     135             :     };
     136             : 
     137             :     std::shared_ptr<ArrowArrayStreamPrivateData>
     138             :         m_poSharedArrowArrayStreamPrivateData{};
     139             : 
     140             :     struct ArrowArrayStreamPrivateDataSharedDataWrapper
     141             :     {
     142             :         std::shared_ptr<ArrowArrayStreamPrivateData> poShared{};
     143             :     };
     144             :     //! @endcond
     145             : 
     146             :     friend class OGRArrowArrayHelper;
     147             :     friend class OGRGenSQLResultsLayer;
     148             :     static void ReleaseArray(struct ArrowArray *array);
     149             :     static void ReleaseSchema(struct ArrowSchema *schema);
     150             :     static void ReleaseStream(struct ArrowArrayStream *stream);
     151             :     virtual int GetArrowSchema(struct ArrowArrayStream *,
     152             :                                struct ArrowSchema *out_schema);
     153             :     virtual int GetNextArrowArray(struct ArrowArrayStream *,
     154             :                                   struct ArrowArray *out_array);
     155             :     static int StaticGetArrowSchema(struct ArrowArrayStream *,
     156             :                                     struct ArrowSchema *out_schema);
     157             :     static int StaticGetNextArrowArray(struct ArrowArrayStream *,
     158             :                                        struct ArrowArray *out_array);
     159             :     static const char *GetLastErrorArrowArrayStream(struct ArrowArrayStream *);
     160             : 
     161             :     static struct ArrowSchema *
     162             :     CreateSchemaForWKBGeometryColumn(const OGRGeomFieldDefn *poFieldDefn,
     163             :                                      const char *pszArrowFormat,
     164             :                                      const char *pszExtensionName);
     165             : 
     166             :     virtual bool
     167             :     CanPostFilterArrowArray(const struct ArrowSchema *schema) const;
     168             :     void PostFilterArrowArray(const struct ArrowSchema *schema,
     169             :                               struct ArrowArray *array,
     170             :                               CSLConstList papszOptions) const;
     171             : 
     172             :     //! @cond Doxygen_Suppress
     173             :     bool CreateFieldFromArrowSchemaInternal(const struct ArrowSchema *schema,
     174             :                                             const std::string &osFieldPrefix,
     175             :                                             CSLConstList papszOptions);
     176             :     //! @endcond
     177             : 
     178             :   public:
     179             :     OGRLayer();
     180             :     virtual ~OGRLayer();
     181             : 
     182             :     /** Return begin of feature iterator.
     183             :      *
     184             :      * Using this iterator for standard range-based loops is safe, but
     185             :      * due to implementation limitations, you shouldn't try to access
     186             :      * (dereference) more than one iterator step at a time, since the
     187             :      * OGRFeatureUniquePtr reference is reused.
     188             :      *
     189             :      * Only one iterator per layer can be active at a time.
     190             :      * @since GDAL 2.3
     191             :      */
     192             :     FeatureIterator begin();
     193             : 
     194             :     /** Return end of feature iterator. */
     195             :     FeatureIterator end();
     196             : 
     197             :     virtual OGRGeometry *GetSpatialFilter();
     198             : 
     199             :     OGRErr SetSpatialFilter(const OGRGeometry *);
     200             :     OGRErr SetSpatialFilterRect(double dfMinX, double dfMinY, double dfMaxX,
     201             :                                 double dfMaxY);
     202             : 
     203             :     OGRErr SetSpatialFilter(int iGeomField, const OGRGeometry *);
     204             :     OGRErr SetSpatialFilterRect(int iGeomField, double dfMinX, double dfMinY,
     205             :                                 double dfMaxX, double dfMaxY);
     206             : 
     207             :     virtual OGRErr SetAttributeFilter(const char *);
     208             : 
     209             :     virtual void ResetReading() = 0;
     210             :     virtual OGRFeature *GetNextFeature() CPL_WARN_UNUSED_RESULT = 0;
     211             :     virtual OGRErr SetNextByIndex(GIntBig nIndex);
     212             :     virtual OGRFeature *GetFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT;
     213             : 
     214             :     virtual GDALDataset *GetDataset();
     215             :     virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
     216             :                                 CSLConstList papszOptions = nullptr);
     217             :     virtual bool IsArrowSchemaSupported(const struct ArrowSchema *schema,
     218             :                                         CSLConstList papszOptions,
     219             :                                         std::string &osErrorMsg) const;
     220             :     virtual bool
     221             :     CreateFieldFromArrowSchema(const struct ArrowSchema *schema,
     222             :                                CSLConstList papszOptions = nullptr);
     223             :     virtual bool WriteArrowBatch(const struct ArrowSchema *schema,
     224             :                                  struct ArrowArray *array,
     225             :                                  CSLConstList papszOptions = nullptr);
     226             : 
     227             :     OGRErr SetFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
     228             :     OGRErr CreateFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
     229             :     OGRErr UpsertFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
     230             :     OGRErr UpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
     231             :                          const int *panUpdatedFieldsIdx,
     232             :                          int nUpdatedGeomFieldsCount,
     233             :                          const int *panUpdatedGeomFieldsIdx,
     234             :                          bool bUpdateStyleString) CPL_WARN_UNUSED_RESULT;
     235             : 
     236             :     virtual OGRErr DeleteFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT;
     237             : 
     238             :     virtual const char *GetName();
     239             :     virtual OGRwkbGeometryType GetGeomType();
     240             :     virtual OGRFeatureDefn *GetLayerDefn() = 0;
     241             :     virtual int FindFieldIndex(const char *pszFieldName, int bExactMatch);
     242             : 
     243             :     virtual OGRSpatialReference *GetSpatialRef();
     244             : 
     245             :     /** Return type of OGRLayer::GetSupportedSRSList() */
     246             :     typedef std::vector<
     247             :         std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser>>
     248             :         GetSupportedSRSListRetType;
     249             :     virtual const GetSupportedSRSListRetType &
     250             :     GetSupportedSRSList(int iGeomField);
     251             :     virtual OGRErr SetActiveSRS(int iGeomField,
     252             :                                 const OGRSpatialReference *poSRS);
     253             : 
     254             :     virtual GIntBig GetFeatureCount(int bForce = TRUE);
     255             : 
     256             :     OGRErr GetExtent(OGREnvelope *psExtent,
     257             :                      bool bForce = true) CPL_WARN_UNUSED_RESULT;
     258             :     OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
     259             :                      bool bForce = true) CPL_WARN_UNUSED_RESULT;
     260             : 
     261             :     OGRErr GetExtent3D(int iGeomField, OGREnvelope3D *psExtent,
     262             :                        bool bForce = true) CPL_WARN_UNUSED_RESULT;
     263             : 
     264             :     virtual int TestCapability(const char *) = 0;
     265             : 
     266             :     virtual OGRErr Rename(const char *pszNewName) CPL_WARN_UNUSED_RESULT;
     267             : 
     268             :     virtual OGRErr CreateField(const OGRFieldDefn *poField,
     269             :                                int bApproxOK = TRUE);
     270             :     virtual OGRErr DeleteField(int iField);
     271             :     virtual OGRErr ReorderFields(int *panMap);
     272             :     virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
     273             :                                   int nFlagsIn);
     274             :     virtual OGRErr
     275             :     AlterGeomFieldDefn(int iGeomField,
     276             :                        const OGRGeomFieldDefn *poNewGeomFieldDefn,
     277             :                        int nFlagsIn);
     278             : 
     279             :     virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
     280             :                                    int bApproxOK = TRUE);
     281             : 
     282             :     virtual OGRErr SyncToDisk();
     283             : 
     284             :     virtual OGRStyleTable *GetStyleTable();
     285             :     virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
     286             : 
     287             :     virtual void SetStyleTable(OGRStyleTable *poStyleTable);
     288             : 
     289             :     virtual OGRErr StartTransaction() CPL_WARN_UNUSED_RESULT;
     290             :     virtual OGRErr CommitTransaction() CPL_WARN_UNUSED_RESULT;
     291             :     virtual OGRErr RollbackTransaction();
     292             : 
     293             :     //! @cond Doxygen_Suppress
     294             :     // Keep field definitions in sync with transactions
     295             :     virtual void PrepareStartTransaction();
     296             :     // Rollback TO SAVEPOINT if osSavepointName is not empty, otherwise ROLLBACK
     297             :     virtual void FinishRollbackTransaction(const std::string &osSavepointName);
     298             :     //! @endcond
     299             : 
     300             :     virtual const char *GetFIDColumn();
     301             :     virtual const char *GetGeometryColumn();
     302             : 
     303             :     virtual OGRErr SetIgnoredFields(CSLConstList papszFields);
     304             : 
     305             :     virtual OGRGeometryTypeCounter *
     306             :     GetGeometryTypes(int iGeomField, int nFlagsGGT, int &nEntryCountOut,
     307             :                      GDALProgressFunc pfnProgress, void *pProgressData);
     308             : 
     309             :     OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     310             :                         char **papszOptions = nullptr,
     311             :                         GDALProgressFunc pfnProgress = nullptr,
     312             :                         void *pProgressArg = nullptr);
     313             :     OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     314             :                  char **papszOptions = nullptr,
     315             :                  GDALProgressFunc pfnProgress = nullptr,
     316             :                  void *pProgressArg = nullptr);
     317             :     OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     318             :                          char **papszOptions, GDALProgressFunc pfnProgress,
     319             :                          void *pProgressArg);
     320             :     OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     321             :                     char **papszOptions = nullptr,
     322             :                     GDALProgressFunc pfnProgress = nullptr,
     323             :                     void *pProgressArg = nullptr);
     324             :     OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     325             :                   char **papszOptions = nullptr,
     326             :                   GDALProgressFunc pfnProgress = nullptr,
     327             :                   void *pProgressArg = nullptr);
     328             :     OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     329             :                 char **papszOptions = nullptr,
     330             :                 GDALProgressFunc pfnProgress = nullptr,
     331             :                 void *pProgressArg = nullptr);
     332             :     OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
     333             :                  char **papszOptions = nullptr,
     334             :                  GDALProgressFunc pfnProgress = nullptr,
     335             :                  void *pProgressArg = nullptr);
     336             : 
     337             :     int Reference();
     338             :     int Dereference();
     339             :     int GetRefCount() const;
     340             :     //! @cond Doxygen_Suppress
     341             :     GIntBig GetFeaturesRead();
     342             :     //! @endcond
     343             : 
     344             :     /* non virtual : convenience wrapper for ReorderFields() */
     345             :     OGRErr ReorderField(int iOldFieldPos, int iNewFieldPos);
     346             : 
     347             :     //! @cond Doxygen_Suppress
     348             :     int AttributeFilterEvaluationNeedsGeometry();
     349             : 
     350             :     /* consider these private */
     351             :     OGRErr InitializeIndexSupport(const char *);
     352             : 
     353        5779 :     OGRLayerAttrIndex *GetIndex()
     354             :     {
     355        5779 :         return m_poAttrIndex;
     356             :     }
     357             : 
     358          13 :     int GetGeomFieldFilter() const
     359             :     {
     360          13 :         return m_iGeomFieldFilter;
     361             :     }
     362             : 
     363          13 :     const char *GetAttrQueryString() const
     364             :     {
     365          13 :         return m_pszAttrQueryString;
     366             :     }
     367             : 
     368             :     //! @endcond
     369             : 
     370             :     /** Convert a OGRLayer* to a OGRLayerH.
     371             :      * @since GDAL 2.3
     372             :      */
     373       28658 :     static inline OGRLayerH ToHandle(OGRLayer *poLayer)
     374             :     {
     375       28658 :         return reinterpret_cast<OGRLayerH>(poLayer);
     376             :     }
     377             : 
     378             :     /** Convert a OGRLayerH to a OGRLayer*.
     379             :      * @since GDAL 2.3
     380             :      */
     381      703629 :     static inline OGRLayer *FromHandle(OGRLayerH hLayer)
     382             :     {
     383      703629 :         return reinterpret_cast<OGRLayer *>(hLayer);
     384             :     }
     385             : 
     386             :     //! @cond Doxygen_Suppress
     387             :     bool FilterWKBGeometry(const GByte *pabyWKB, size_t nWKBSize,
     388             :                            bool bEnvelopeAlreadySet,
     389             :                            OGREnvelope &sEnvelope) const;
     390             : 
     391             :     static bool FilterWKBGeometry(const GByte *pabyWKB, size_t nWKBSize,
     392             :                                   bool bEnvelopeAlreadySet,
     393             :                                   OGREnvelope &sEnvelope,
     394             :                                   const OGRGeometry *poFilterGeom,
     395             :                                   bool bFilterIsEnvelope,
     396             :                                   const OGREnvelope &sFilterEnvelope,
     397             :                                   OGRPreparedGeometry *&poPreparedFilterGeom);
     398             :     //! @endcond
     399             : 
     400             :     /** Field name used by GetArrowSchema() for a FID column when
     401             :      * GetFIDColumn() is not set.
     402             :      */
     403             :     static constexpr const char *DEFAULT_ARROW_FID_NAME = "OGC_FID";
     404             : 
     405             :     /** Field name used by GetArrowSchema() for the name of the (single)
     406             :      * geometry column (returned by GetGeometryColumn()) is not set.
     407             :      */
     408             :     static constexpr const char *DEFAULT_ARROW_GEOMETRY_NAME = "wkb_geometry";
     409             : 
     410             :   protected:
     411             :     //! @cond Doxygen_Suppress
     412             : 
     413             :     enum class FieldChangeType : char
     414             :     {
     415             :         ADD_FIELD,
     416             :         ALTER_FIELD,
     417             :         DELETE_FIELD
     418             :     };
     419             : 
     420             :     // Store changes to the fields that happened inside a transaction
     421             :     template <typename T> struct FieldDefnChange
     422             :     {
     423             : 
     424        1295 :         FieldDefnChange(std::unique_ptr<T> &&poFieldDefnIn, int iFieldIn,
     425             :                         FieldChangeType eChangeTypeIn,
     426             :                         const std::string &osSavepointNameIn = "")
     427        1295 :             : poFieldDefn(std::move(poFieldDefnIn)), iField(iFieldIn),
     428        1295 :               eChangeType(eChangeTypeIn), osSavepointName(osSavepointNameIn)
     429             :         {
     430        1295 :         }
     431             : 
     432             :         std::unique_ptr<T> poFieldDefn;
     433             :         int iField;
     434             :         FieldChangeType eChangeType;
     435             :         std::string osSavepointName;
     436             :     };
     437             : 
     438             :     std::vector<FieldDefnChange<OGRFieldDefn>> m_apoFieldDefnChanges{};
     439             :     std::vector<FieldDefnChange<OGRGeomFieldDefn>> m_apoGeomFieldDefnChanges{};
     440             : 
     441             :     OGRStyleTable *m_poStyleTable;
     442             :     OGRFeatureQuery *m_poAttrQuery;
     443             :     char *m_pszAttrQueryString;
     444             :     OGRLayerAttrIndex *m_poAttrIndex;
     445             : 
     446             :     int m_nRefCount;
     447             : 
     448             :     GIntBig m_nFeaturesRead;
     449             :     //! @endcond
     450             : };
     451             : 
     452             : /** Return begin of feature iterator.
     453             :  *
     454             :  * Using this iterator for standard range-based loops is safe, but
     455             :  * due to implementation limitations, you shouldn't try to access
     456             :  * (dereference) more than one iterator step at a time, since the
     457             :  * std::unique_ptr&lt;OGRFeature&gt; reference is reused.
     458             :  *
     459             :  * Only one iterator per layer can be active at a time.
     460             :  * @since GDAL 2.3
     461             :  * @see OGRLayer::begin()
     462             :  */
     463        2322 : inline OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
     464             : {
     465        2322 :     return poLayer->begin();
     466             : }
     467             : 
     468             : /** Return end of feature iterator.
     469             :  * @see OGRLayer::end()
     470             :  */
     471        2322 : inline OGRLayer::FeatureIterator end(OGRLayer *poLayer)
     472             : {
     473        2322 :     return poLayer->end();
     474             : }
     475             : 
     476             : /** Unique pointer type for OGRLayer.
     477             :  * @since GDAL 3.2
     478             :  */
     479             : using OGRLayerUniquePtr = std::unique_ptr<OGRLayer>;
     480             : 
     481             : /************************************************************************/
     482             : /*                     OGRGetNextFeatureThroughRaw                      */
     483             : /************************************************************************/
     484             : 
     485             : /** Template class offering a GetNextFeature() implementation relying on
     486             :  * GetNextRawFeature()
     487             :  *
     488             :  * @since GDAL 3.2
     489             :  */
     490             : template <class BaseLayer> class OGRGetNextFeatureThroughRaw
     491             : {
     492             :   protected:
     493             :     ~OGRGetNextFeatureThroughRaw() = default;
     494             : 
     495             :   public:
     496             :     /** Implement OGRLayer::GetNextFeature(), relying on
     497             :      * BaseLayer::GetNextRawFeature() */
     498       49081 :     OGRFeature *GetNextFeature()
     499             :     {
     500       49081 :         const auto poThis = static_cast<BaseLayer *>(this);
     501       15620 :         while (true)
     502             :         {
     503       64701 :             OGRFeature *poFeature = poThis->GetNextRawFeature();
     504       64701 :             if (poFeature == nullptr)
     505        3847 :                 return nullptr;
     506             : 
     507       13325 :             if ((poThis->m_poFilterGeom == nullptr ||
     508      121708 :                  poThis->FilterGeometry(poFeature->GetGeometryRef())) &&
     509       66238 :                 (poThis->m_poAttrQuery == nullptr ||
     510       14338 :                  poThis->m_poAttrQuery->Evaluate(poFeature)))
     511             :             {
     512       45234 :                 return poFeature;
     513             :             }
     514             :             else
     515       15620 :                 delete poFeature;
     516             :         }
     517             :     }
     518             : };
     519             : 
     520             : /** Utility macro to define GetNextFeature() through GetNextRawFeature() */
     521             : #define DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(BaseLayer)                         \
     522             :   private:                                                                     \
     523             :     friend class OGRGetNextFeatureThroughRaw<BaseLayer>;                       \
     524             :                                                                                \
     525             :   public:                                                                      \
     526             :     OGRFeature *GetNextFeature() override                                      \
     527             :     {                                                                          \
     528             :         return OGRGetNextFeatureThroughRaw<BaseLayer>::GetNextFeature();       \
     529             :     }
     530             : 
     531             : /************************************************************************/
     532             : /*                            OGRDataSource                             */
     533             : /************************************************************************/
     534             : 
     535             : /**
     536             :  * LEGACY class. Use GDALDataset in your new code ! This class may be
     537             :  * removed in a later release.
     538             :  *
     539             :  * This class represents a data source.  A data source potentially
     540             :  * consists of many layers (OGRLayer).  A data source normally consists
     541             :  * of one, or a related set of files, though the name doesn't have to be
     542             :  * a real item in the file system.
     543             :  *
     544             :  * When an OGRDataSource is destroyed, all its associated OGRLayers objects
     545             :  * are also destroyed.
     546             :  *
     547             :  * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of
     548             :  * a C function that returns a OGRDataSourceH to a OGRDataSource*. If a C++
     549             :  * object is needed, the handle should be cast to GDALDataset*.
     550             :  *
     551             :  * @deprecated
     552             :  */
     553             : 
     554             : class CPL_DLL OGRDataSource : public GDALDataset
     555             : {
     556             :   public:
     557             :     OGRDataSource();
     558             :     //! @cond Doxygen_Suppress
     559             :     virtual const char *GetName()
     560             :         OGR_DEPRECATED("Use GDALDataset class instead") = 0;
     561             : 
     562             :     static void DestroyDataSource(OGRDataSource *)
     563             :         OGR_DEPRECATED("Use GDALDataset class instead");
     564             :     //! @endcond
     565             : };
     566             : 
     567             : /************************************************************************/
     568             : /*                             OGRSFDriver                              */
     569             : /************************************************************************/
     570             : 
     571             : /**
     572             :  * LEGACY class. Use GDALDriver in your new code ! This class may be
     573             :  * removed in a later release.
     574             :  *
     575             :  * Represents an operational format driver.
     576             :  *
     577             :  * One OGRSFDriver derived class will normally exist for each file format
     578             :  * registered for use, regardless of whether a file has or will be opened.
     579             :  * The list of available drivers is normally managed by the
     580             :  * OGRSFDriverRegistrar.
     581             :  *
     582             :  * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of
     583             :  * a C function that returns a OGRSFDriverH to a OGRSFDriver*. If a C++ object
     584             :  * is needed, the handle should be cast to GDALDriver*.
     585             :  *
     586             :  * @deprecated
     587             :  */
     588             : 
     589             : class CPL_DLL OGRSFDriver : public GDALDriver
     590             : {
     591             :   public:
     592             :     //! @cond Doxygen_Suppress
     593             :     virtual ~OGRSFDriver();
     594             : 
     595             :     virtual const char *GetName()
     596             :         OGR_DEPRECATED("Use GDALDriver class instead") = 0;
     597             : 
     598             :     virtual OGRDataSource *Open(const char *pszName, int bUpdate = FALSE)
     599             :         OGR_DEPRECATED("Use GDALDriver class instead") = 0;
     600             : 
     601             :     virtual int TestCapability(const char *pszCap)
     602             :         OGR_DEPRECATED("Use GDALDriver class instead") = 0;
     603             : 
     604             :     virtual OGRDataSource *CreateDataSource(const char *pszName,
     605             :                                             char ** = nullptr)
     606             :         OGR_DEPRECATED("Use GDALDriver class instead");
     607             :     virtual OGRErr DeleteDataSource(const char *pszName)
     608             :         OGR_DEPRECATED("Use GDALDriver class instead");
     609             :     //! @endcond
     610             : };
     611             : 
     612             : /************************************************************************/
     613             : /*                         OGRSFDriverRegistrar                         */
     614             : /************************************************************************/
     615             : 
     616             : /**
     617             :  * LEGACY class. Use GDALDriverManager in your new code ! This class may be
     618             :  * removed in a later release.
     619             :  *
     620             :  * Singleton manager for OGRSFDriver instances that will be used to try
     621             :  * and open datasources.  Normally the registrar is populated with
     622             :  * standard drivers using the OGRRegisterAll() function and does not need
     623             :  * to be directly accessed.  The driver registrar and all registered drivers
     624             :  * may be cleaned up on shutdown using OGRCleanupAll().
     625             :  *
     626             :  * @deprecated
     627             :  */
     628             : 
     629             : class CPL_DLL OGRSFDriverRegistrar
     630             : {
     631             : 
     632             :     OGRSFDriverRegistrar();
     633             :     ~OGRSFDriverRegistrar();
     634             : 
     635             :     static GDALDataset *OpenWithDriverArg(GDALDriver *poDriver,
     636             :                                           GDALOpenInfo *poOpenInfo);
     637             :     static GDALDataset *CreateVectorOnly(GDALDriver *poDriver,
     638             :                                          const char *pszName,
     639             :                                          char **papszOptions);
     640             :     static CPLErr DeleteDataSource(GDALDriver *poDriver, const char *pszName);
     641             : 
     642             :   public:
     643             :     //! @cond Doxygen_Suppress
     644             :     static OGRSFDriverRegistrar *GetRegistrar()
     645             :         OGR_DEPRECATED("Use GDALDriverManager class instead");
     646             : 
     647             :     // cppcheck-suppress functionStatic
     648             :     void RegisterDriver(OGRSFDriver *poDriver)
     649             :         OGR_DEPRECATED("Use GDALDriverManager class instead");
     650             : 
     651             :     // cppcheck-suppress functionStatic
     652             :     int GetDriverCount(void)
     653             :         OGR_DEPRECATED("Use GDALDriverManager class instead");
     654             :     // cppcheck-suppress functionStatic
     655             :     GDALDriver *GetDriver(int iDriver)
     656             :         OGR_DEPRECATED("Use GDALDriverManager class instead");
     657             :     // cppcheck-suppress functionStatic
     658             :     GDALDriver *GetDriverByName(const char *)
     659             :         OGR_DEPRECATED("Use GDALDriverManager class instead");
     660             : 
     661             :     // cppcheck-suppress functionStatic
     662             :     int GetOpenDSCount() OGR_DEPRECATED("Use GDALDriverManager class instead");
     663             :     // cppcheck-suppress functionStatic
     664             :     OGRDataSource *GetOpenDS(int)
     665             :         OGR_DEPRECATED("Use GDALDriverManager class instead");
     666             :     //! @endcond
     667             : };
     668             : 
     669             : /* -------------------------------------------------------------------- */
     670             : /*      Various available registration methods.                         */
     671             : /* -------------------------------------------------------------------- */
     672             : CPL_C_START
     673             : 
     674             : //! @cond Doxygen_Suppress
     675             : void OGRRegisterAllInternal();
     676             : 
     677             : void CPL_DLL RegisterOGRFileGDB();
     678             : void DeclareDeferredOGRFileGDBPlugin();
     679             : void CPL_DLL RegisterOGRShape();
     680             : void CPL_DLL RegisterOGRS57();
     681             : void CPL_DLL RegisterOGRTAB();
     682             : void CPL_DLL RegisterOGRMIF();
     683             : void CPL_DLL RegisterOGRODBC();
     684             : void DeclareDeferredOGRODBCPlugin();
     685             : void CPL_DLL RegisterOGRWAsP();
     686             : void CPL_DLL RegisterOGRPG();
     687             : void DeclareDeferredOGRPGPlugin();
     688             : void CPL_DLL RegisterOGRMSSQLSpatial();
     689             : void DeclareDeferredOGRMSSQLSpatialPlugin();
     690             : void CPL_DLL RegisterOGRMySQL();
     691             : void DeclareDeferredOGRMySQLPlugin();
     692             : void CPL_DLL RegisterOGROCI();
     693             : void DeclareDeferredOGROCIPlugin();
     694             : void CPL_DLL RegisterOGRDGN();
     695             : void CPL_DLL RegisterOGRGML();
     696             : void CPL_DLL RegisterOGRLIBKML();
     697             : void DeclareDeferredOGRLIBKMLPlugin();
     698             : void CPL_DLL RegisterOGRKML();
     699             : void CPL_DLL RegisterOGRFlatGeobuf();
     700             : void CPL_DLL RegisterOGRGeoJSON();
     701             : void CPL_DLL RegisterOGRGeoJSONSeq();
     702             : void CPL_DLL RegisterOGRESRIJSON();
     703             : void CPL_DLL RegisterOGRTopoJSON();
     704             : void CPL_DLL RegisterOGRAVCBin();
     705             : void CPL_DLL RegisterOGRAVCE00();
     706             : void CPL_DLL RegisterOGRMEM();
     707             : void CPL_DLL RegisterOGRVRT();
     708             : void CPL_DLL RegisterOGRSQLite();
     709             : void CPL_DLL RegisterOGRCSV();
     710             : void CPL_DLL RegisterOGRILI1();
     711             : void CPL_DLL RegisterOGRILI2();
     712             : void CPL_DLL RegisterOGRPGeo();
     713             : void CPL_DLL RegisterOGRDXF();
     714             : void CPL_DLL RegisterOGRCAD();
     715             : void DeclareDeferredOGRCADPlugin();
     716             : void CPL_DLL RegisterOGRDWG();
     717             : void CPL_DLL RegisterOGRDGNV8();
     718             : void DeclareDeferredOGRDWGPlugin();
     719             : void DeclareDeferredOGRDGNV8Plugin();
     720             : void CPL_DLL RegisterOGRIDB();
     721             : void DeclareDeferredOGRIDBPlugin();
     722             : void CPL_DLL RegisterOGRGMT();
     723             : void CPL_DLL RegisterOGRGPX();
     724             : void CPL_DLL RegisterOGRNAS();
     725             : void CPL_DLL RegisterOGRGeoRSS();
     726             : void CPL_DLL RegisterOGRVFK();
     727             : void DeclareDeferredOGRVFKPlugin();
     728             : void CPL_DLL RegisterOGRPGDump();
     729             : void CPL_DLL RegisterOGROSM();
     730             : void CPL_DLL RegisterOGRGPSBabel();
     731             : void CPL_DLL RegisterOGRPDS();
     732             : void CPL_DLL RegisterOGRWFS();
     733             : void CPL_DLL RegisterOGROAPIF();
     734             : void CPL_DLL RegisterOGRSOSI();
     735             : void DeclareDeferredOGRSOSIPlugin();
     736             : void CPL_DLL RegisterOGREDIGEO();
     737             : void CPL_DLL RegisterOGRIdrisi();
     738             : void CPL_DLL RegisterOGRXLS();
     739             : void DeclareDeferredOGRXLSPlugin();
     740             : void CPL_DLL RegisterOGRODS();
     741             : void CPL_DLL RegisterOGRXLSX();
     742             : void CPL_DLL RegisterOGRElastic();
     743             : void DeclareDeferredOGRElasticPlugin();
     744             : void CPL_DLL RegisterOGRGeoPackage();
     745             : void CPL_DLL RegisterOGRCarto();
     746             : void DeclareDeferredOGRCartoPlugin();
     747             : void CPL_DLL RegisterOGRAmigoCloud();
     748             : void CPL_DLL RegisterOGRSXF();
     749             : void CPL_DLL RegisterOGROpenFileGDB();
     750             : void DeclareDeferredOGROpenFileGDBPlugin();
     751             : void CPL_DLL RegisterOGRSelafin();
     752             : void CPL_DLL RegisterOGRJML();
     753             : void CPL_DLL RegisterOGRPLSCENES();
     754             : void DeclareDeferredOGRPLSCENESPlugin();
     755             : void CPL_DLL RegisterOGRCSW();
     756             : void CPL_DLL RegisterOGRMongoDBv3();
     757             : void DeclareDeferredOGRMongoDBv3Plugin();
     758             : void CPL_DLL RegisterOGRVDV();
     759             : void CPL_DLL RegisterOGRGMLAS();
     760             : void DeclareDeferredOGRGMLASPlugin();
     761             : void CPL_DLL RegisterOGRMVT();
     762             : void CPL_DLL RegisterOGRNGW();
     763             : void CPL_DLL RegisterOGRMapML();
     764             : void CPL_DLL RegisterOGRLVBAG();
     765             : void CPL_DLL RegisterOGRHANA();
     766             : void DeclareDeferredOGRHANAPlugin();
     767             : void CPL_DLL RegisterOGRParquet();
     768             : void DeclareDeferredOGRParquetPlugin();
     769             : void CPL_DLL RegisterOGRArrow();
     770             : void DeclareDeferredOGRArrowPlugin();
     771             : void CPL_DLL RegisterOGRGTFS();
     772             : void CPL_DLL RegisterOGRPMTiles();
     773             : void CPL_DLL RegisterOGRJSONFG();
     774             : void CPL_DLL RegisterOGRMiraMon();
     775             : void CPL_DLL RegisterOGRXODR();
     776             : void DeclareDeferredOGRXODRPlugin();
     777             : void CPL_DLL RegisterOGRADBC();
     778             : void DeclareDeferredOGRADBCPlugin();
     779             : void CPL_DLL RegisterOGRAIVector();
     780             : // @endcond
     781             : 
     782             : CPL_C_END
     783             : 
     784             : #endif /* ndef OGRSF_FRMTS_H_INCLUDED */

Generated by: LCOV version 1.14