Coverage Report

Created: 2025-06-13 06:18

/src/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h
Line
Count
Source (jump to first uncovered line)
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
    OGRLayerAttrIndex *GetIndex()
358
0
    {
359
0
        return m_poAttrIndex;
360
0
    }
361
362
    int GetGeomFieldFilter() const
363
0
    {
364
0
        return m_iGeomFieldFilter;
365
0
    }
366
367
    const char *GetAttrQueryString() const
368
0
    {
369
0
        return m_pszAttrQueryString;
370
0
    }
371
372
    //! @endcond
373
374
    /** Convert a OGRLayer* to a OGRLayerH.
375
     * @since GDAL 2.3
376
     */
377
    static inline OGRLayerH ToHandle(OGRLayer *poLayer)
378
0
    {
379
0
        return reinterpret_cast<OGRLayerH>(poLayer);
380
0
    }
381
382
    /** Convert a OGRLayerH to a OGRLayer*.
383
     * @since GDAL 2.3
384
     */
385
    static inline OGRLayer *FromHandle(OGRLayerH hLayer)
386
0
    {
387
0
        return reinterpret_cast<OGRLayer *>(hLayer);
388
0
    }
Unexecuted instantiation: OGRLayer::FromHandle(OGRLayerHS*)
Unexecuted instantiation: OGRLayer::FromHandle(void*)
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
        FieldDefnChange(std::unique_ptr<T> &&poFieldDefnIn, int iFieldIn,
429
                        FieldChangeType eChangeTypeIn,
430
                        const std::string &osSavepointNameIn = "")
431
            : poFieldDefn(std::move(poFieldDefnIn)), iField(iFieldIn),
432
              eChangeType(eChangeTypeIn), osSavepointName(osSavepointNameIn)
433
        {
434
        }
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
inline OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
468
0
{
469
0
    return poLayer->begin();
470
0
}
471
472
/** Return end of feature iterator.
473
 * @see OGRLayer::end()
474
 */
475
inline OGRLayer::FeatureIterator end(OGRLayer *poLayer)
476
0
{
477
0
    return poLayer->end();
478
0
}
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
    OGRFeature *GetNextFeature()
503
    {
504
        const auto poThis = static_cast<BaseLayer *>(this);
505
        while (true)
506
        {
507
            OGRFeature *poFeature = poThis->GetNextRawFeature();
508
            if (poFeature == nullptr)
509
                return nullptr;
510
511
            if ((poThis->m_poFilterGeom == nullptr ||
512
                 poThis->FilterGeometry(poFeature->GetGeometryRef())) &&
513
                (poThis->m_poAttrQuery == nullptr ||
514
                 poThis->m_poAttrQuery->Evaluate(poFeature)))
515
            {
516
                return poFeature;
517
            }
518
            else
519
                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
    ~OGRDataSource() override;
563
564
    //! @cond Doxygen_Suppress
565
    virtual const char *GetName()
566
        OGR_DEPRECATED("Use GDALDataset class instead") = 0;
567
568
    static void DestroyDataSource(OGRDataSource *)
569
        OGR_DEPRECATED("Use GDALDataset class instead");
570
    //! @endcond
571
};
572
573
/************************************************************************/
574
/*                             OGRSFDriver                              */
575
/************************************************************************/
576
577
/**
578
 * LEGACY class. Use GDALDriver in your new code ! This class may be
579
 * removed in a later release.
580
 *
581
 * Represents an operational format driver.
582
 *
583
 * One OGRSFDriver derived class will normally exist for each file format
584
 * registered for use, regardless of whether a file has or will be opened.
585
 * The list of available drivers is normally managed by the
586
 * OGRSFDriverRegistrar.
587
 *
588
 * NOTE: Starting with GDAL 2.0, it is *NOT* safe to cast the handle of
589
 * a C function that returns a OGRSFDriverH to a OGRSFDriver*. If a C++ object
590
 * is needed, the handle should be cast to GDALDriver*.
591
 *
592
 * @deprecated
593
 */
594
595
class CPL_DLL OGRSFDriver : public GDALDriver
596
{
597
  public:
598
    //! @cond Doxygen_Suppress
599
    virtual ~OGRSFDriver();
600
601
    virtual const char *GetName()
602
        OGR_DEPRECATED("Use GDALDriver class instead") = 0;
603
604
    virtual OGRDataSource *Open(const char *pszName, int bUpdate = FALSE)
605
        OGR_DEPRECATED("Use GDALDriver class instead") = 0;
606
607
    virtual int TestCapability(const char *pszCap)
608
        OGR_DEPRECATED("Use GDALDriver class instead") = 0;
609
610
    virtual OGRDataSource *CreateDataSource(const char *pszName,
611
                                            char ** = nullptr)
612
        OGR_DEPRECATED("Use GDALDriver class instead");
613
    virtual OGRErr DeleteDataSource(const char *pszName)
614
        OGR_DEPRECATED("Use GDALDriver class instead");
615
    //! @endcond
616
};
617
618
/************************************************************************/
619
/*                         OGRSFDriverRegistrar                         */
620
/************************************************************************/
621
622
/**
623
 * LEGACY class. Use GDALDriverManager in your new code ! This class may be
624
 * removed in a later release.
625
 *
626
 * Singleton manager for OGRSFDriver instances that will be used to try
627
 * and open datasources.  Normally the registrar is populated with
628
 * standard drivers using the OGRRegisterAll() function and does not need
629
 * to be directly accessed.  The driver registrar and all registered drivers
630
 * may be cleaned up on shutdown using OGRCleanupAll().
631
 *
632
 * @deprecated
633
 */
634
635
class CPL_DLL OGRSFDriverRegistrar
636
{
637
638
    OGRSFDriverRegistrar();
639
    ~OGRSFDriverRegistrar();
640
641
    static GDALDataset *OpenWithDriverArg(GDALDriver *poDriver,
642
                                          GDALOpenInfo *poOpenInfo);
643
    static GDALDataset *CreateVectorOnly(GDALDriver *poDriver,
644
                                         const char *pszName,
645
                                         char **papszOptions);
646
    static CPLErr DeleteDataSource(GDALDriver *poDriver, const char *pszName);
647
648
  public:
649
    //! @cond Doxygen_Suppress
650
    static OGRSFDriverRegistrar *GetRegistrar()
651
        OGR_DEPRECATED("Use GDALDriverManager class instead");
652
653
    CPPCHECK_STATIC void RegisterDriver(OGRSFDriver *poDriver)
654
        OGR_DEPRECATED("Use GDALDriverManager class instead");
655
656
    CPPCHECK_STATIC int GetDriverCount(void)
657
        OGR_DEPRECATED("Use GDALDriverManager class instead");
658
659
    CPPCHECK_STATIC GDALDriver *GetDriver(int iDriver)
660
        OGR_DEPRECATED("Use GDALDriverManager class instead");
661
662
    CPPCHECK_STATIC GDALDriver *GetDriverByName(const char *)
663
        OGR_DEPRECATED("Use GDALDriverManager class instead");
664
665
    CPPCHECK_STATIC int GetOpenDSCount()
666
        OGR_DEPRECATED("Use GDALDriverManager class instead");
667
668
    CPPCHECK_STATIC OGRDataSource *GetOpenDS(int)
669
        OGR_DEPRECATED("Use GDALDriverManager class instead");
670
    //! @endcond
671
};
672
673
/* -------------------------------------------------------------------- */
674
/*      Various available registration methods.                         */
675
/* -------------------------------------------------------------------- */
676
CPL_C_START
677
678
//! @cond Doxygen_Suppress
679
void OGRRegisterAllInternal();
680
681
void CPL_DLL RegisterOGRFileGDB();
682
void DeclareDeferredOGRFileGDBPlugin();
683
void CPL_DLL RegisterOGRShape();
684
void CPL_DLL RegisterOGRS57();
685
void CPL_DLL RegisterOGRTAB();
686
void CPL_DLL RegisterOGRMIF();
687
void CPL_DLL RegisterOGRODBC();
688
void DeclareDeferredOGRODBCPlugin();
689
void CPL_DLL RegisterOGRWAsP();
690
void CPL_DLL RegisterOGRPG();
691
void DeclareDeferredOGRPGPlugin();
692
void CPL_DLL RegisterOGRMSSQLSpatial();
693
void DeclareDeferredOGRMSSQLSpatialPlugin();
694
void CPL_DLL RegisterOGRMySQL();
695
void DeclareDeferredOGRMySQLPlugin();
696
void CPL_DLL RegisterOGROCI();
697
void DeclareDeferredOGROCIPlugin();
698
void CPL_DLL RegisterOGRDGN();
699
void CPL_DLL RegisterOGRGML();
700
void CPL_DLL RegisterOGRLIBKML();
701
void DeclareDeferredOGRLIBKMLPlugin();
702
void CPL_DLL RegisterOGRKML();
703
void CPL_DLL RegisterOGRFlatGeobuf();
704
void CPL_DLL RegisterOGRGeoJSON();
705
void CPL_DLL RegisterOGRGeoJSONSeq();
706
void CPL_DLL RegisterOGRESRIJSON();
707
void CPL_DLL RegisterOGRTopoJSON();
708
void CPL_DLL RegisterOGRAVCBin();
709
void CPL_DLL RegisterOGRAVCE00();
710
void CPL_DLL RegisterOGRVRT();
711
void CPL_DLL RegisterOGRSQLite();
712
void CPL_DLL RegisterOGRCSV();
713
void CPL_DLL RegisterOGRILI1();
714
void CPL_DLL RegisterOGRILI2();
715
void CPL_DLL RegisterOGRPGeo();
716
void CPL_DLL RegisterOGRDXF();
717
void CPL_DLL RegisterOGRCAD();
718
void DeclareDeferredOGRCADPlugin();
719
void CPL_DLL RegisterOGRDWG();
720
void CPL_DLL RegisterOGRDGNV8();
721
void DeclareDeferredOGRDWGPlugin();
722
void DeclareDeferredOGRDGNV8Plugin();
723
void CPL_DLL RegisterOGRIDB();
724
void DeclareDeferredOGRIDBPlugin();
725
void CPL_DLL RegisterOGRGMT();
726
void CPL_DLL RegisterOGRGPX();
727
void CPL_DLL RegisterOGRNAS();
728
void CPL_DLL RegisterOGRGeoRSS();
729
void CPL_DLL RegisterOGRVFK();
730
void DeclareDeferredOGRVFKPlugin();
731
void CPL_DLL RegisterOGRPGDump();
732
void CPL_DLL RegisterOGROSM();
733
void CPL_DLL RegisterOGRGPSBabel();
734
void CPL_DLL RegisterOGRPDS();
735
void CPL_DLL RegisterOGRWFS();
736
void CPL_DLL RegisterOGROAPIF();
737
void CPL_DLL RegisterOGRSOSI();
738
void DeclareDeferredOGRSOSIPlugin();
739
void CPL_DLL RegisterOGREDIGEO();
740
void CPL_DLL RegisterOGRIdrisi();
741
void CPL_DLL RegisterOGRXLS();
742
void DeclareDeferredOGRXLSPlugin();
743
void CPL_DLL RegisterOGRODS();
744
void CPL_DLL RegisterOGRXLSX();
745
void CPL_DLL RegisterOGRElastic();
746
void DeclareDeferredOGRElasticPlugin();
747
void CPL_DLL RegisterOGRGeoPackage();
748
void CPL_DLL RegisterOGRCarto();
749
void DeclareDeferredOGRCartoPlugin();
750
void CPL_DLL RegisterOGRAmigoCloud();
751
void CPL_DLL RegisterOGRSXF();
752
void CPL_DLL RegisterOGROpenFileGDB();
753
void DeclareDeferredOGROpenFileGDBPlugin();
754
void CPL_DLL RegisterOGRSelafin();
755
void CPL_DLL RegisterOGRJML();
756
void CPL_DLL RegisterOGRPLSCENES();
757
void DeclareDeferredOGRPLSCENESPlugin();
758
void CPL_DLL RegisterOGRCSW();
759
void CPL_DLL RegisterOGRMongoDBv3();
760
void DeclareDeferredOGRMongoDBv3Plugin();
761
void CPL_DLL RegisterOGRVDV();
762
void CPL_DLL RegisterOGRGMLAS();
763
void DeclareDeferredOGRGMLASPlugin();
764
void CPL_DLL RegisterOGRMVT();
765
void CPL_DLL RegisterOGRNGW();
766
void CPL_DLL RegisterOGRMapML();
767
void CPL_DLL RegisterOGRLVBAG();
768
void CPL_DLL RegisterOGRHANA();
769
void DeclareDeferredOGRHANAPlugin();
770
void CPL_DLL RegisterOGRParquet();
771
void DeclareDeferredOGRParquetPlugin();
772
void CPL_DLL RegisterOGRArrow();
773
void DeclareDeferredOGRArrowPlugin();
774
void CPL_DLL RegisterOGRGTFS();
775
void CPL_DLL RegisterOGRPMTiles();
776
void CPL_DLL RegisterOGRJSONFG();
777
void CPL_DLL RegisterOGRMiraMon();
778
void CPL_DLL RegisterOGRXODR();
779
void DeclareDeferredOGRXODRPlugin();
780
void CPL_DLL RegisterOGRADBC();
781
void DeclareDeferredOGRADBCPlugin();
782
void CPL_DLL RegisterOGRAIVector();
783
// @endcond
784
785
CPL_C_END
786
787
#endif /* ndef OGRSF_FRMTS_H_INCLUDED */