Coverage Report

Created: 2025-11-16 06:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h
Line
Count
Source
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
    ~OGRLayer() override;
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
     */
195
    FeatureIterator begin();
196
197
    /** Return end of feature iterator. */
198
    FeatureIterator end();
199
200
    virtual OGRGeometry *GetSpatialFilter();
201
202
    OGRErr SetSpatialFilter(const OGRGeometry *);
203
    OGRErr SetSpatialFilterRect(double dfMinX, double dfMinY, double dfMaxX,
204
                                double dfMaxY);
205
206
    OGRErr SetSpatialFilter(int iGeomField, const OGRGeometry *);
207
    OGRErr SetSpatialFilterRect(int iGeomField, double dfMinX, double dfMinY,
208
                                double dfMaxX, double dfMaxY);
209
210
    virtual OGRErr SetAttributeFilter(const char *);
211
212
    virtual void ResetReading() = 0;
213
    virtual OGRFeature *GetNextFeature() CPL_WARN_UNUSED_RESULT = 0;
214
    virtual OGRErr SetNextByIndex(GIntBig nIndex);
215
    virtual OGRFeature *GetFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT;
216
217
    virtual GDALDataset *GetDataset();
218
    virtual bool GetArrowStream(struct ArrowArrayStream *out_stream,
219
                                CSLConstList papszOptions = nullptr);
220
    virtual bool IsArrowSchemaSupported(const struct ArrowSchema *schema,
221
                                        CSLConstList papszOptions,
222
                                        std::string &osErrorMsg) const;
223
    virtual bool
224
    CreateFieldFromArrowSchema(const struct ArrowSchema *schema,
225
                               CSLConstList papszOptions = nullptr);
226
    virtual bool WriteArrowBatch(const struct ArrowSchema *schema,
227
                                 struct ArrowArray *array,
228
                                 CSLConstList papszOptions = nullptr);
229
230
    OGRErr SetFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
231
    OGRErr CreateFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
232
    OGRErr UpsertFeature(OGRFeature *poFeature) CPL_WARN_UNUSED_RESULT;
233
    OGRErr UpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
234
                         const int *panUpdatedFieldsIdx,
235
                         int nUpdatedGeomFieldsCount,
236
                         const int *panUpdatedGeomFieldsIdx,
237
                         bool bUpdateStyleString) CPL_WARN_UNUSED_RESULT;
238
239
    virtual OGRErr DeleteFeature(GIntBig nFID) CPL_WARN_UNUSED_RESULT;
240
241
    virtual const char *GetName() const;
242
    virtual OGRwkbGeometryType GetGeomType() const;
243
    virtual const OGRFeatureDefn *GetLayerDefn() const = 0;
244
245
    OGRFeatureDefn *GetLayerDefn()
246
0
    {
247
0
        return const_cast<OGRFeatureDefn *>(
248
0
            const_cast<const OGRLayer *>(this)->GetLayerDefn());
249
0
    }
250
251
    virtual int FindFieldIndex(const char *pszFieldName, int bExactMatch);
252
253
    virtual const OGRSpatialReference *GetSpatialRef() const;
254
255
    /** Return type of OGRLayer::GetSupportedSRSList() */
256
    typedef std::vector<
257
        std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser>>
258
        GetSupportedSRSListRetType;
259
    virtual const GetSupportedSRSListRetType &
260
    GetSupportedSRSList(int iGeomField);
261
    virtual OGRErr SetActiveSRS(int iGeomField,
262
                                const OGRSpatialReference *poSRS);
263
264
    virtual GIntBig GetFeatureCount(int bForce = TRUE);
265
266
    OGRErr GetExtent(OGREnvelope *psExtent,
267
                     bool bForce = true) CPL_WARN_UNUSED_RESULT;
268
    OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
269
                     bool bForce = true) CPL_WARN_UNUSED_RESULT;
270
271
    OGRErr GetExtent3D(int iGeomField, OGREnvelope3D *psExtent,
272
                       bool bForce = true) CPL_WARN_UNUSED_RESULT;
273
274
    virtual int TestCapability(const char *) const = 0;
275
276
    virtual OGRErr Rename(const char *pszNewName) CPL_WARN_UNUSED_RESULT;
277
278
    virtual OGRErr CreateField(const OGRFieldDefn *poField,
279
                               int bApproxOK = TRUE) CPL_WARN_UNUSED_RESULT;
280
    virtual OGRErr DeleteField(int iField);
281
    virtual OGRErr ReorderFields(int *panMap);
282
    virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
283
                                  int nFlagsIn);
284
    virtual OGRErr
285
    AlterGeomFieldDefn(int iGeomField,
286
                       const OGRGeomFieldDefn *poNewGeomFieldDefn,
287
                       int nFlagsIn);
288
289
    virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
290
                                   int bApproxOK = TRUE);
291
292
    virtual OGRErr SyncToDisk();
293
294
    virtual OGRStyleTable *GetStyleTable();
295
    virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
296
297
    virtual void SetStyleTable(OGRStyleTable *poStyleTable);
298
299
    virtual OGRErr StartTransaction() CPL_WARN_UNUSED_RESULT;
300
    virtual OGRErr CommitTransaction() CPL_WARN_UNUSED_RESULT;
301
    virtual OGRErr RollbackTransaction();
302
303
    //! @cond Doxygen_Suppress
304
    // Keep field definitions in sync with transactions
305
    virtual void PrepareStartTransaction();
306
    // Rollback TO SAVEPOINT if osSavepointName is not empty, otherwise ROLLBACK
307
    virtual void FinishRollbackTransaction(const std::string &osSavepointName);
308
    //! @endcond
309
310
    virtual const char *GetFIDColumn() const;
311
    virtual const char *GetGeometryColumn() const;
312
313
    virtual OGRErr SetIgnoredFields(CSLConstList papszFields);
314
315
    virtual OGRGeometryTypeCounter *
316
    GetGeometryTypes(int iGeomField, int nFlagsGGT, int &nEntryCountOut,
317
                     GDALProgressFunc pfnProgress, void *pProgressData);
318
319
    OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
320
                        char **papszOptions = nullptr,
321
                        GDALProgressFunc pfnProgress = nullptr,
322
                        void *pProgressArg = nullptr);
323
    OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
324
                 char **papszOptions = nullptr,
325
                 GDALProgressFunc pfnProgress = nullptr,
326
                 void *pProgressArg = nullptr);
327
    OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
328
                         char **papszOptions, GDALProgressFunc pfnProgress,
329
                         void *pProgressArg);
330
    OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
331
                    char **papszOptions = nullptr,
332
                    GDALProgressFunc pfnProgress = nullptr,
333
                    void *pProgressArg = nullptr);
334
    OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
335
                  char **papszOptions = nullptr,
336
                  GDALProgressFunc pfnProgress = nullptr,
337
                  void *pProgressArg = nullptr);
338
    OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
339
                char **papszOptions = nullptr,
340
                GDALProgressFunc pfnProgress = nullptr,
341
                void *pProgressArg = nullptr);
342
    OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
343
                 char **papszOptions = nullptr,
344
                 GDALProgressFunc pfnProgress = nullptr,
345
                 void *pProgressArg = nullptr);
346
347
    int Reference();
348
    int Dereference();
349
    int GetRefCount() const;
350
    //! @cond Doxygen_Suppress
351
    GIntBig GetFeaturesRead();
352
    //! @endcond
353
354
    /* non virtual : convenience wrapper for ReorderFields() */
355
    OGRErr ReorderField(int iOldFieldPos, int iNewFieldPos);
356
357
    //! @cond Doxygen_Suppress
358
    int AttributeFilterEvaluationNeedsGeometry();
359
360
    /* consider these private */
361
    OGRErr InitializeIndexSupport(const char *);
362
363
    OGRLayerAttrIndex *GetIndex()
364
0
    {
365
0
        return m_poAttrIndex;
366
0
    }
367
368
    int GetGeomFieldFilter() const
369
0
    {
370
0
        return m_iGeomFieldFilter;
371
0
    }
372
373
    const char *GetAttrQueryString() const
374
0
    {
375
0
        return m_pszAttrQueryString;
376
0
    }
377
378
    //! @endcond
379
380
    /** Convert a OGRLayer* to a OGRLayerH.
381
     */
382
    static inline OGRLayerH ToHandle(OGRLayer *poLayer)
383
0
    {
384
0
        return reinterpret_cast<OGRLayerH>(poLayer);
385
0
    }
386
387
    /** Convert a OGRLayerH to a OGRLayer*.
388
     */
389
    static inline OGRLayer *FromHandle(OGRLayerH hLayer)
390
0
    {
391
0
        return reinterpret_cast<OGRLayer *>(hLayer);
392
0
    }
Unexecuted instantiation: OGRLayer::FromHandle(OGRLayerHS*)
Unexecuted instantiation: OGRLayer::FromHandle(void*)
393
394
    //! @cond Doxygen_Suppress
395
    bool FilterWKBGeometry(const GByte *pabyWKB, size_t nWKBSize,
396
                           bool bEnvelopeAlreadySet,
397
                           OGREnvelope &sEnvelope) const;
398
399
    static bool FilterWKBGeometry(const GByte *pabyWKB, size_t nWKBSize,
400
                                  bool bEnvelopeAlreadySet,
401
                                  OGREnvelope &sEnvelope,
402
                                  const OGRGeometry *poFilterGeom,
403
                                  bool bFilterIsEnvelope,
404
                                  const OGREnvelope &sFilterEnvelope,
405
                                  OGRPreparedGeometry *&poPreparedFilterGeom);
406
    //! @endcond
407
408
    /** Field name used by GetArrowSchema() for a FID column when
409
     * GetFIDColumn() is not set.
410
     */
411
    static constexpr const char *DEFAULT_ARROW_FID_NAME = "OGC_FID";
412
413
    /** Field name used by GetArrowSchema() for the name of the (single)
414
     * geometry column (returned by GetGeometryColumn()) is not set.
415
     */
416
    static constexpr const char *DEFAULT_ARROW_GEOMETRY_NAME = "wkb_geometry";
417
418
  protected:
419
    //! @cond Doxygen_Suppress
420
421
    enum class FieldChangeType : char
422
    {
423
        ADD_FIELD,
424
        ALTER_FIELD,
425
        DELETE_FIELD
426
    };
427
428
    // Store changes to the fields that happened inside a transaction
429
    template <typename T> struct FieldDefnChange
430
    {
431
432
        FieldDefnChange(std::unique_ptr<T> &&poFieldDefnIn, int iFieldIn,
433
                        FieldChangeType eChangeTypeIn,
434
                        const std::string &osSavepointNameIn = "")
435
            : poFieldDefn(std::move(poFieldDefnIn)), iField(iFieldIn),
436
              eChangeType(eChangeTypeIn), osSavepointName(osSavepointNameIn)
437
        {
438
        }
439
440
        std::unique_ptr<T> poFieldDefn;
441
        int iField;
442
        FieldChangeType eChangeType;
443
        std::string osSavepointName;
444
    };
445
446
    std::vector<FieldDefnChange<OGRFieldDefn>> m_apoFieldDefnChanges{};
447
    std::vector<FieldDefnChange<OGRGeomFieldDefn>> m_apoGeomFieldDefnChanges{};
448
449
    OGRStyleTable *m_poStyleTable;
450
    OGRFeatureQuery *m_poAttrQuery;
451
    char *m_pszAttrQueryString;
452
    OGRLayerAttrIndex *m_poAttrIndex;
453
454
    int m_nRefCount;
455
456
    GIntBig m_nFeaturesRead;
457
    //! @endcond
458
};
459
460
/** Return begin of feature iterator.
461
 *
462
 * Using this iterator for standard range-based loops is safe, but
463
 * due to implementation limitations, you shouldn't try to access
464
 * (dereference) more than one iterator step at a time, since the
465
 * std::unique_ptr&lt;OGRFeature&gt; reference is reused.
466
 *
467
 * Only one iterator per layer can be active at a time.
468
 * @see OGRLayer::begin()
469
 */
470
inline OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
471
0
{
472
0
    return poLayer->begin();
473
0
}
474
475
/** Return end of feature iterator.
476
 * @see OGRLayer::end()
477
 */
478
inline OGRLayer::FeatureIterator end(OGRLayer *poLayer)
479
0
{
480
0
    return poLayer->end();
481
0
}
482
483
/** Unique pointer type for OGRLayer.
484
 * @since GDAL 3.2
485
 */
486
using OGRLayerUniquePtr = std::unique_ptr<OGRLayer>;
487
488
/************************************************************************/
489
/*                     OGRGetNextFeatureThroughRaw                      */
490
/************************************************************************/
491
492
/** Template class offering a GetNextFeature() implementation relying on
493
 * GetNextRawFeature().
494
 * OGRGetNextFeatureThroughRaw::GetNextFeature() calls GetNextRawFeature()
495
 * and takes care of applying the spatial and attribute filters, making
496
 * their taking into account in GetNextRawFeature() unnecessary.
497
 *
498
 * @since GDAL 3.2
499
 */
500
template <class BaseLayer> class OGRGetNextFeatureThroughRaw
501
{
502
  protected:
503
    ~OGRGetNextFeatureThroughRaw() = default;
504
505
  public:
506
    /** Implement OGRLayer::GetNextFeature(), relying on
507
     * BaseLayer::GetNextRawFeature() */
508
    OGRFeature *GetNextFeature()
509
    {
510
        const auto poThis = static_cast<BaseLayer *>(this);
511
        while (true)
512
        {
513
            OGRFeature *poFeature = poThis->GetNextRawFeature();
514
            if (poFeature == nullptr)
515
                return nullptr;
516
517
            if ((poThis->m_poFilterGeom == nullptr ||
518
                 poThis->FilterGeometry(poFeature->GetGeometryRef())) &&
519
                (poThis->m_poAttrQuery == nullptr ||
520
                 poThis->m_poAttrQuery->Evaluate(poFeature)))
521
            {
522
                return poFeature;
523
            }
524
            else
525
                delete poFeature;
526
        }
527
    }
528
};
529
530
/** Utility macro to define GetNextFeature() through GetNextRawFeature() */
531
#define DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(BaseLayer)                         \
532
  private:                                                                     \
533
    friend class OGRGetNextFeatureThroughRaw<BaseLayer>;                       \
534
                                                                               \
535
  public:                                                                      \
536
    OGRFeature *GetNextFeature() override                                      \
537
    {                                                                          \
538
        return OGRGetNextFeatureThroughRaw<BaseLayer>::GetNextFeature();       \
539
    }
540
541
/************************************************************************/
542
/*                            OGRDataSource                             */
543
/************************************************************************/
544
545
/**
546
 * LEGACY class. Use GDALDataset in your new code ! This class may be
547
 * removed in a later release.
548
 *
549
 * This class represents a data source.  A data source potentially
550
 * consists of many layers (OGRLayer).  A data source normally consists
551
 * of one, or a related set of files, though the name doesn't have to be
552
 * a real item in the file system.
553
 *
554
 * When an OGRDataSource is destroyed, all its associated OGRLayers objects
555
 * are also destroyed.
556
 *
557
 * NOTE: It is *NOT* safe to cast the handle of
558
 * a C function that returns a OGRDataSourceH to a OGRDataSource*. If a C++
559
 * object is needed, the handle should be cast to GDALDataset*.
560
 *
561
 * @deprecated
562
 */
563
564
class CPL_DLL OGRDataSource : public GDALDataset
565
{
566
  public:
567
    OGRDataSource();
568
    ~OGRDataSource() override;
569
570
    //! @cond Doxygen_Suppress
571
    virtual const char *GetName()
572
        OGR_DEPRECATED("Use GDALDataset class instead") = 0;
573
574
    static void DestroyDataSource(OGRDataSource *)
575
        OGR_DEPRECATED("Use GDALDataset class instead");
576
    //! @endcond
577
};
578
579
/************************************************************************/
580
/*                             OGRSFDriver                              */
581
/************************************************************************/
582
583
/**
584
 * LEGACY class. Use GDALDriver in your new code ! This class may be
585
 * removed in a later release.
586
 *
587
 * Represents an operational format driver.
588
 *
589
 * One OGRSFDriver derived class will normally exist for each file format
590
 * registered for use, regardless of whether a file has or will be opened.
591
 * The list of available drivers is normally managed by the
592
 * OGRSFDriverRegistrar.
593
 *
594
 * NOTE: It is *NOT* safe to cast the handle of
595
 * a C function that returns a OGRSFDriverH to a OGRSFDriver*. If a C++ object
596
 * is needed, the handle should be cast to GDALDriver*.
597
 *
598
 * @deprecated
599
 */
600
601
class CPL_DLL OGRSFDriver : public GDALDriver
602
{
603
  public:
604
    //! @cond Doxygen_Suppress
605
    ~OGRSFDriver() override;
606
607
    virtual const char *GetName()
608
        OGR_DEPRECATED("Use GDALDriver class instead") = 0;
609
610
    virtual OGRDataSource *Open(const char *pszName, int bUpdate = FALSE)
611
        OGR_DEPRECATED("Use GDALDriver class instead") = 0;
612
613
    virtual int TestCapability(const char *pszCap)
614
        OGR_DEPRECATED("Use GDALDriver class instead") = 0;
615
616
    virtual OGRDataSource *CreateDataSource(const char *pszName,
617
                                            char ** = nullptr)
618
        OGR_DEPRECATED("Use GDALDriver class instead");
619
    virtual OGRErr DeleteDataSource(const char *pszName)
620
        OGR_DEPRECATED("Use GDALDriver class instead");
621
    //! @endcond
622
};
623
624
/************************************************************************/
625
/*                         OGRSFDriverRegistrar                         */
626
/************************************************************************/
627
628
/**
629
 * LEGACY class. Use GDALDriverManager in your new code ! This class may be
630
 * removed in a later release.
631
 *
632
 * Singleton manager for OGRSFDriver instances that will be used to try
633
 * and open datasources.  Normally the registrar is populated with
634
 * standard drivers using the OGRRegisterAll() function and does not need
635
 * to be directly accessed.  The driver registrar and all registered drivers
636
 * may be cleaned up on shutdown using OGRCleanupAll().
637
 *
638
 * @deprecated
639
 */
640
641
class CPL_DLL OGRSFDriverRegistrar
642
{
643
644
    OGRSFDriverRegistrar();
645
    ~OGRSFDriverRegistrar();
646
647
    static GDALDataset *OpenWithDriverArg(GDALDriver *poDriver,
648
                                          GDALOpenInfo *poOpenInfo);
649
    static GDALDataset *CreateVectorOnly(GDALDriver *poDriver,
650
                                         const char *pszName,
651
                                         char **papszOptions);
652
    static CPLErr DeleteDataSource(GDALDriver *poDriver, const char *pszName);
653
654
  public:
655
    //! @cond Doxygen_Suppress
656
    static OGRSFDriverRegistrar *GetRegistrar()
657
        OGR_DEPRECATED("Use GDALDriverManager class instead");
658
659
    CPPCHECK_STATIC void RegisterDriver(OGRSFDriver *poDriver)
660
        OGR_DEPRECATED("Use GDALDriverManager class instead");
661
662
    CPPCHECK_STATIC int GetDriverCount(void)
663
        OGR_DEPRECATED("Use GDALDriverManager class instead");
664
665
    CPPCHECK_STATIC GDALDriver *GetDriver(int iDriver)
666
        OGR_DEPRECATED("Use GDALDriverManager class instead");
667
668
    CPPCHECK_STATIC GDALDriver *GetDriverByName(const char *)
669
        OGR_DEPRECATED("Use GDALDriverManager class instead");
670
671
    CPPCHECK_STATIC int GetOpenDSCount()
672
        OGR_DEPRECATED("Use GDALDriverManager class instead");
673
674
    CPPCHECK_STATIC OGRDataSource *GetOpenDS(int)
675
        OGR_DEPRECATED("Use GDALDriverManager class instead");
676
    //! @endcond
677
};
678
679
/* -------------------------------------------------------------------- */
680
/*      Various available registration methods.                         */
681
/* -------------------------------------------------------------------- */
682
CPL_C_START
683
684
//! @cond Doxygen_Suppress
685
void OGRRegisterAllInternal();
686
687
void CPL_DLL RegisterOGRFileGDB();
688
void DeclareDeferredOGRFileGDBPlugin();
689
void CPL_DLL RegisterOGRShape();
690
void CPL_DLL RegisterOGRS57();
691
void CPL_DLL RegisterOGRTAB();
692
void CPL_DLL RegisterOGRMIF();
693
void CPL_DLL RegisterOGRODBC();
694
void DeclareDeferredOGRODBCPlugin();
695
void CPL_DLL RegisterOGRWAsP();
696
void CPL_DLL RegisterOGRPG();
697
void DeclareDeferredOGRPGPlugin();
698
void CPL_DLL RegisterOGRMSSQLSpatial();
699
void DeclareDeferredOGRMSSQLSpatialPlugin();
700
void CPL_DLL RegisterOGRMySQL();
701
void DeclareDeferredOGRMySQLPlugin();
702
void CPL_DLL RegisterOGROCI();
703
void DeclareDeferredOGROCIPlugin();
704
void CPL_DLL RegisterOGRDGN();
705
void CPL_DLL RegisterOGRGML();
706
void CPL_DLL RegisterOGRLIBKML();
707
void DeclareDeferredOGRLIBKMLPlugin();
708
void CPL_DLL RegisterOGRKML();
709
void CPL_DLL RegisterOGRFlatGeobuf();
710
void CPL_DLL RegisterOGRGeoJSON();
711
void CPL_DLL RegisterOGRGeoJSONSeq();
712
void CPL_DLL RegisterOGRESRIJSON();
713
void CPL_DLL RegisterOGRTopoJSON();
714
void CPL_DLL RegisterOGRAVCBin();
715
void CPL_DLL RegisterOGRAVCE00();
716
void CPL_DLL RegisterOGRVRT();
717
void CPL_DLL RegisterOGRSQLite();
718
void CPL_DLL RegisterOGRCSV();
719
void CPL_DLL RegisterOGRILI1();
720
void CPL_DLL RegisterOGRILI2();
721
void CPL_DLL RegisterOGRPGeo();
722
void CPL_DLL RegisterOGRDXF();
723
void CPL_DLL RegisterOGRCAD();
724
void DeclareDeferredOGRCADPlugin();
725
void CPL_DLL RegisterOGRDWG();
726
void CPL_DLL RegisterOGRDGNV8();
727
void DeclareDeferredOGRDWGPlugin();
728
void DeclareDeferredOGRDGNV8Plugin();
729
void CPL_DLL RegisterOGRIDB();
730
void DeclareDeferredOGRIDBPlugin();
731
void CPL_DLL RegisterOGRGMT();
732
void CPL_DLL RegisterOGRGPX();
733
void CPL_DLL RegisterOGRNAS();
734
void CPL_DLL RegisterOGRGeoRSS();
735
void CPL_DLL RegisterOGRVFK();
736
void DeclareDeferredOGRVFKPlugin();
737
void CPL_DLL RegisterOGRPGDump();
738
void CPL_DLL RegisterOGROSM();
739
void CPL_DLL RegisterOGRGPSBabel();
740
void CPL_DLL RegisterOGRPDS();
741
void CPL_DLL RegisterOGRWFS();
742
void CPL_DLL RegisterOGROAPIF();
743
void CPL_DLL RegisterOGRSOSI();
744
void DeclareDeferredOGRSOSIPlugin();
745
void CPL_DLL RegisterOGREDIGEO();
746
void CPL_DLL RegisterOGRIdrisi();
747
void CPL_DLL RegisterOGRXLS();
748
void DeclareDeferredOGRXLSPlugin();
749
void CPL_DLL RegisterOGRODS();
750
void CPL_DLL RegisterOGRXLSX();
751
void CPL_DLL RegisterOGRElastic();
752
void DeclareDeferredOGRElasticPlugin();
753
void CPL_DLL RegisterOGRGeoPackage();
754
void CPL_DLL RegisterOGRCarto();
755
void DeclareDeferredOGRCartoPlugin();
756
void CPL_DLL RegisterOGRAmigoCloud();
757
void CPL_DLL RegisterOGRSXF();
758
void CPL_DLL RegisterOGROpenFileGDB();
759
void DeclareDeferredOGROpenFileGDBPlugin();
760
void CPL_DLL RegisterOGRSelafin();
761
void CPL_DLL RegisterOGRJML();
762
void CPL_DLL RegisterOGRPLSCENES();
763
void DeclareDeferredOGRPLSCENESPlugin();
764
void CPL_DLL RegisterOGRCSW();
765
void CPL_DLL RegisterOGRMongoDBv3();
766
void DeclareDeferredOGRMongoDBv3Plugin();
767
void CPL_DLL RegisterOGRVDV();
768
void CPL_DLL RegisterOGRGMLAS();
769
void DeclareDeferredOGRGMLASPlugin();
770
void CPL_DLL RegisterOGRMVT();
771
void CPL_DLL RegisterOGRNGW();
772
void CPL_DLL RegisterOGRMapML();
773
void CPL_DLL RegisterOGRLVBAG();
774
void CPL_DLL RegisterOGRHANA();
775
void DeclareDeferredOGRHANAPlugin();
776
void CPL_DLL RegisterOGRParquet();
777
void DeclareDeferredOGRParquetPlugin();
778
void CPL_DLL RegisterOGRArrow();
779
void DeclareDeferredOGRArrowPlugin();
780
void CPL_DLL RegisterOGRGTFS();
781
void CPL_DLL RegisterOGRPMTiles();
782
void CPL_DLL RegisterOGRJSONFG();
783
void CPL_DLL RegisterOGRMiraMon();
784
void CPL_DLL RegisterOGRXODR();
785
void DeclareDeferredOGRXODRPlugin();
786
void CPL_DLL RegisterOGRADBC();
787
void DeclareDeferredOGRADBCPlugin();
788
void CPL_DLL RegisterOGRAIVector();
789
// @endcond
790
791
CPL_C_END
792
793
#endif /* ndef OGRSF_FRMTS_H_INCLUDED */