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

Generated by: LCOV version 1.14