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