| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: OpenGIS Simple Features Reference Implementation |
| 4 | * Purpose: The OGRSFDriverRegistrar class implementation. |
| 5 | * Author: Frank Warmerdam, [email protected] |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 1999, Les Technologies SoftMap Inc. |
| 9 | * Copyright (c) 2008-2012, Even Rouault <even dot rouault at spatialys.com> |
| 10 | * |
| 11 | * SPDX-License-Identifier: MIT |
| 12 | ****************************************************************************/ |
| 13 | |
| 14 | #include "ogrsf_frmts.h"cxx . . $ `<file>/ogr/ogrsf_frmts/ogrsf_frmts.h`/ |
| 15 | #include "ogr_api.h"cxx . . $ `<file>/ogr/ogr_api.h`/ |
| 16 | #include "ograpispy.h"cxx . . $ `<file>/ogr/ograpispy.h`/ |
| 17 | |
| 18 | /************************************************************************/ |
| 19 | /* OGRSFDriverRegistrar */ |
| 20 | /************************************************************************/ |
| 21 | |
| 22 | /** |
| 23 | * \brief Constructor |
| 24 | * |
| 25 | * Normally the driver registrar is constructed by the |
| 26 | * OGRSFDriverRegistrar::GetRegistrar() accessor which ensures singleton |
| 27 | * status. |
| 28 | */ |
| 29 | |
| 30 | OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#OGRSFDriverRegistrar(49f6e7a06ebc5aa8).() |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | /************************************************************************/ |
| 35 | /* ~OGRSFDriverRegistrar() */ |
| 36 | /************************************************************************/ |
| 37 | |
| 38 | OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::~cxx . . $ OGRSFDriverRegistrar#`~OGRSFDriverRegistrar`(ced63f7c635d850d).OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#() |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | //! @cond Doxygen_Suppress |
| 43 | /************************************************************************/ |
| 44 | /* GetRegistrar() */ |
| 45 | /************************************************************************/ |
| 46 | |
| 47 | OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar# *OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetRegistrarcxx . . $ OGRSFDriverRegistrar#GetRegistrar(4e9952cdeba0aa35).() |
| 48 | { |
| 49 | static OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar# oSingletoncxx . . $ OGRSFDriverRegistrar#OGRSFDriverRegistrar(49f6e7a06ebc5aa8).; |
| 50 | return &oSingleton; |
| 51 | } |
| 52 | |
| 53 | //! @endcond |
| 54 | |
| 55 | /************************************************************************/ |
| 56 | /* OGRCleanupAll() */ |
| 57 | /************************************************************************/ |
| 58 | |
| 59 | /** |
| 60 | * \brief Cleanup all OGR related resources. |
| 61 | * |
| 62 | * \see GDALDestroy() |
| 63 | * \deprecated Use GDALDestroy() instead |
| 64 | */ |
| 65 | void OGRCleanupAllcxx . . $ OGRCleanupAll(49f6e7a06ebc5aa8).() |
| 66 | |
| 67 | { |
| 68 | GDALDestroyDriverManager(); |
| 69 | } |
| 70 | |
| 71 | /************************************************************************/ |
| 72 | /* OGROpen() */ |
| 73 | /************************************************************************/ |
| 74 | |
| 75 | /** |
| 76 | \brief Open a file / data source with one of the registered drivers. |
| 77 | |
| 78 | This function loops through all the drivers registered with the driver |
| 79 | manager trying each until one succeeds with the given data source. |
| 80 | |
| 81 | If this function fails, CPLGetLastErrorMsg() can be used to check if there |
| 82 | is an error message explaining why. |
| 83 | |
| 84 | For drivers supporting the VSI virtual file API, it is possible to open |
| 85 | a file in a .zip archive (see VSIInstallZipFileHandler()), in a .tar/.tar.gz/.tgz archive |
| 86 | (see VSIInstallTarFileHandler()) or on a HTTP / FTP server (see VSIInstallCurlFileHandler()) |
| 87 | |
| 88 | NOTE: It is *NOT* safe to cast the returned handle to |
| 89 | OGRDataSource*. If a C++ object is needed, the handle should be cast to GDALDataset*. |
| 90 | Similarly, the returned OGRSFDriverH handle should be cast to GDALDriver*, and |
| 91 | *NOT* OGRSFDriver*. |
| 92 | |
| 93 | @deprecated Use GDALOpenEx() |
| 94 | |
| 95 | @param pszName the name of the file, or data source to open. |
| 96 | @param bUpdate FALSE for read-only access (the default) or TRUE for |
| 97 | read-write access. |
| 98 | @param pahDriverList if non-NULL, this argument will be updated with a |
| 99 | pointer to the driver which was used to open the data source. |
| 100 | |
| 101 | @return NULL on error or if the pass name is not supported by this driver, |
| 102 | otherwise a handle to a GDALDataset. This GDALDataset should be |
| 103 | closed by deleting the object when it is no longer needed. |
| 104 | |
| 105 | Example: |
| 106 | |
| 107 | \code{.cpp} |
| 108 | OGRDataSourceH hDS; |
| 109 | OGRSFDriverH *pahDriver; |
| 110 | |
| 111 | hDS = OGROpen( "polygon.shp", 0, pahDriver ); |
| 112 | if( hDS == NULL ) |
| 113 | { |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | ... use the data source ... |
| 118 | |
| 119 | OGRReleaseDataSource( hDS ); |
| 120 | \endcode |
| 121 | |
| 122 | */ |
| 123 | |
| 124 | OGRDataSourceH OGROpencxx . . $ OGROpen(bb73f28ea08d3406).(const char *pszName, int bUpdate, |
| 125 | OGRSFDriverH *pahDriverList) |
| 126 | |
| 127 | { |
| 128 | VALIDATE_POINTER1cxx . . $ `port/cpl_error.h:493:9`!(pszName, "OGROpen", nullptr); |
| 129 | |
| 130 | GDALDatasetH hDS = |
| 131 | GDALOpenExcxx . . $ GDALOpenEx(5f20ed644b617ec0).(pszName, GDAL_OF_VECTORcxx . . $ `gcore/gdal.h:1130:9`! | ((bUpdate) ? GDAL_OF_UPDATEcxx . . $ `gcore/gdal.h:1115:9`! : 0), |
| 132 | nullptr, nullptr, nullptr); |
| 133 | if (hDS != nullptr && pahDriverList != nullptr) |
| 134 | *pahDriverList = |
| 135 | reinterpret_cast<OGRSFDriverH>(GDALGetDatasetDriver(hDS)); |
| 136 | |
| 137 | return reinterpret_cast<OGRDataSourceH>(hDS); |
| 138 | } |
| 139 | |
| 140 | /************************************************************************/ |
| 141 | /* OGROpenShared() */ |
| 142 | /************************************************************************/ |
| 143 | |
| 144 | /** |
| 145 | \brief Open a file / data source with one of the registered drivers if not |
| 146 | already opened, or increment reference count of already opened data source |
| 147 | previously opened with OGROpenShared() |
| 148 | |
| 149 | This function loops through all the drivers registered with the driver |
| 150 | manager trying each until one succeeds with the given data source. |
| 151 | |
| 152 | If this function fails, CPLGetLastErrorMsg() can be used to check if there |
| 153 | is an error message explaining why. |
| 154 | |
| 155 | NOTE: It is *NOT* safe to cast the returned handle to |
| 156 | OGRDataSource*. If a C++ object is needed, the handle should be cast to GDALDataset*. |
| 157 | Similarly, the returned OGRSFDriverH handle should be cast to GDALDriver*, and |
| 158 | *NOT* OGRSFDriver*. |
| 159 | |
| 160 | @deprecated Use GDALOpenEx() |
| 161 | |
| 162 | @param pszName the name of the file, or data source to open. |
| 163 | @param bUpdate FALSE for read-only access (the default) or TRUE for |
| 164 | read-write access. |
| 165 | @param pahDriverList if non-NULL, this argument will be updated with a |
| 166 | pointer to the driver which was used to open the data source. |
| 167 | |
| 168 | @return NULL on error or if the pass name is not supported by this driver, |
| 169 | otherwise a handle to a GDALDataset. This GDALDataset should be |
| 170 | closed by deleting the object when it is no longer needed. |
| 171 | |
| 172 | Example: |
| 173 | |
| 174 | \code{.cpp} |
| 175 | OGRDataSourceH hDS; |
| 176 | OGRSFDriverH *pahDriver; |
| 177 | |
| 178 | hDS = OGROpenShared( "polygon.shp", 0, pahDriver ); |
| 179 | if( hDS == NULL ) |
| 180 | { |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | ... use the data source ... |
| 185 | |
| 186 | OGRReleaseDataSource( hDS ); |
| 187 | \endcode |
| 188 | |
| 189 | */ |
| 190 | OGRDataSourceH OGROpenSharedcxx . . $ OGROpenShared(bb73f28ea08d3406).(const char *pszName, int bUpdate, |
| 191 | OGRSFDriverH *pahDriverList) |
| 192 | |
| 193 | { |
| 194 | VALIDATE_POINTER1cxx . . $ `port/cpl_error.h:493:9`!(pszName, "OGROpenShared", nullptr); |
| 195 | |
| 196 | GDALDatasetH hDS = GDALOpenExcxx . . $ GDALOpenEx(5f20ed644b617ec0).( |
| 197 | pszName, |
| 198 | GDAL_OF_VECTORcxx . . $ `gcore/gdal.h:1130:9`! | ((bUpdate) ? GDAL_OF_UPDATEcxx . . $ `gcore/gdal.h:1115:9`! : 0) | GDAL_OF_SHAREDcxx . . $ `gcore/gdal.h:1150:9`!, |
| 199 | nullptr, nullptr, nullptr); |
| 200 | if (hDS != nullptr && pahDriverList != nullptr) |
| 201 | *pahDriverList = |
| 202 | reinterpret_cast<OGRSFDriverH>(GDALGetDatasetDriver(hDS)); |
| 203 | return reinterpret_cast<OGRDataSourceH>(hDS); |
| 204 | } |
| 205 | |
| 206 | /************************************************************************/ |
| 207 | /* OGRReleaseDataSource() */ |
| 208 | /************************************************************************/ |
| 209 | |
| 210 | /** |
| 211 | \brief Drop a reference to this datasource, and if the reference count drops to zero close (destroy) the datasource. |
| 212 | |
| 213 | Internally this actually calls |
| 214 | the OGRSFDriverRegistrar::ReleaseDataSource() method. This method is |
| 215 | essentially a convenient alias. |
| 216 | |
| 217 | @deprecated Use GDALClose() |
| 218 | |
| 219 | @param hDS handle to the data source to release |
| 220 | |
| 221 | @return OGRERR_NONE on success or an error code. |
| 222 | */ |
| 223 | |
| 224 | OGRErr OGRReleaseDataSourcecxx . . $ OGRReleaseDataSource(dedf1e9b1c614a07).(OGRDataSourceH hDS) |
| 225 | |
| 226 | { |
| 227 | VALIDATE_POINTER1cxx . . $ `port/cpl_error.h:493:9`!(hDS, "OGRReleaseDataSource", OGRERR_INVALID_HANDLEcxx . . $ `ogr/ogr_core.h:398:9`!); |
| 228 | |
| 229 | GDALClosecxx . . $ GDALClose(3d5aeed3fac2555e).(reinterpret_cast<GDALDatasetH>(hDS)); |
| 230 | |
| 231 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 232 | } |
| 233 | |
| 234 | //! @cond Doxygen_Suppress |
| 235 | /************************************************************************/ |
| 236 | /* GetOpenDSCount() */ |
| 237 | /************************************************************************/ |
| 238 | |
| 239 | int OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetOpenDSCountcxx . . $ OGRSFDriverRegistrar#GetOpenDSCount(b126dc7c1de90089).() |
| 240 | { |
| 241 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Stub implementation"); |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /************************************************************************/ |
| 246 | /* OGRGetOpenDSCount() */ |
| 247 | /************************************************************************/ |
| 248 | |
| 249 | int OGRGetOpenDSCountcxx . . $ OGRGetOpenDSCount(b126dc7c1de90089).() |
| 250 | |
| 251 | { |
| 252 | return OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetRegistrarcxx . . $ OGRSFDriverRegistrar#GetRegistrar(4e9952cdeba0aa35).()->GetOpenDSCountcxx . . $ OGRSFDriverRegistrar#GetOpenDSCount(b126dc7c1de90089).(); |
| 253 | } |
| 254 | |
| 255 | /************************************************************************/ |
| 256 | /* GetOpenDS() */ |
| 257 | /************************************************************************/ |
| 258 | |
| 259 | OGRDataSourcecxx . . $ OGRDataSource# *OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetOpenDScxx . . $ OGRSFDriverRegistrar#GetOpenDS(39563d358a8fcffe).(CPL_UNUSEDcxx . . $ `port/cpl_port.h:1040:9`! int iDS) |
| 260 | { |
| 261 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Stub implementation"); |
| 262 | return nullptr; |
| 263 | } |
| 264 | |
| 265 | /************************************************************************/ |
| 266 | /* OGRGetOpenDS() */ |
| 267 | /************************************************************************/ |
| 268 | |
| 269 | OGRDataSourceH OGRGetOpenDScxx . . $ OGRGetOpenDS(d1680a912d714170).(int iDS) |
| 270 | |
| 271 | { |
| 272 | return reinterpret_cast<OGRDataSourceH>( |
| 273 | OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetRegistrarcxx . . $ OGRSFDriverRegistrar#GetRegistrar(4e9952cdeba0aa35).()->GetOpenDScxx . . $ OGRSFDriverRegistrar#GetOpenDS(39563d358a8fcffe).(iDS)); |
| 274 | } |
| 275 | |
| 276 | /************************************************************************/ |
| 277 | /* OpenWithDriverArg() */ |
| 278 | /************************************************************************/ |
| 279 | |
| 280 | GDALDatasetcxx . . $ GDALDataset# *OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::OpenWithDriverArgcxx . . $ OGRSFDriverRegistrar#OpenWithDriverArg(f9890e633aec3cf0).(GDALDrivercxx . . $ GDALDriver# *poDriver, |
| 281 | GDALOpenInfocxx . . $ GDALOpenInfo# *poOpenInfo) |
| 282 | { |
| 283 | OGRDataSourcecxx . . $ OGRDataSource# *poDS = reinterpret_cast<OGRDataSourcecxx . . $ OGRDataSource# *>( |
| 284 | reinterpret_cast<OGRSFDrivercxx . . $ OGRSFDriver# *>(poDriver)->Opencxx . . $ OGRSFDriver#Open(6b9edc3c59132364).( |
| 285 | poOpenInfo->pszFilenamecxx . . $ GDALOpenInfo#pszFilename., poOpenInfo->eAccesscxx . . $ GDALOpenInfo#eAccess. == GA_Update)); |
| 286 | if (poDS != nullptr) |
| 287 | poDS->SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(poDS->GetNamecxx . . $ OGRDataSource#GetName(33a1f659e94feb42).()); |
| 288 | return poDS; |
| 289 | } |
| 290 | |
| 291 | /************************************************************************/ |
| 292 | /* CreateVectorOnly() */ |
| 293 | /************************************************************************/ |
| 294 | |
| 295 | GDALDatasetcxx . . $ GDALDataset# *OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::CreateVectorOnlycxx . . $ OGRSFDriverRegistrar#CreateVectorOnly(ba7123152ad11905).(GDALDrivercxx . . $ GDALDriver# *poDriver, |
| 296 | const char *pszName, |
| 297 | CSLConstListcxx . . $ CSLConstList# papszOptions) |
| 298 | { |
| 299 | OGRDataSourcecxx . . $ OGRDataSource# *poDS = reinterpret_cast<OGRDataSourcecxx . . $ OGRDataSource# *>( |
| 300 | reinterpret_cast<OGRSFDrivercxx . . $ OGRSFDriver# *>(poDriver)->CreateDataSourcecxx . . $ OGRSFDriver#CreateDataSource(27e7bf0e21e5a239).( |
| 301 | pszName, const_cast<char **>(papszOptions))); |
| 302 | if (poDS != nullptr && poDS->GetNamecxx . . $ OGRDataSource#GetName(33a1f659e94feb42).() != nullptr) |
| 303 | poDS->SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(poDS->GetNamecxx . . $ OGRDataSource#GetName(33a1f659e94feb42).()); |
| 304 | return poDS; |
| 305 | } |
| 306 | |
| 307 | /************************************************************************/ |
| 308 | /* DeleteDataSource() */ |
| 309 | /************************************************************************/ |
| 310 | |
| 311 | CPLErr OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::DeleteDataSourcecxx . . $ OGRSFDriverRegistrar#DeleteDataSource(90c7497c194347e1).(GDALDrivercxx . . $ GDALDriver# *poDriver, |
| 312 | const char *pszName) |
| 313 | { |
| 314 | if (reinterpret_cast<OGRSFDrivercxx . . $ OGRSFDriver# *>(poDriver)->DeleteDataSourcecxx . . $ OGRSFDriver#DeleteDataSource(5c4306d8553b3696).(pszName) == |
| 315 | OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!) |
| 316 | return CE_None; |
| 317 | else |
| 318 | return CE_Failure; |
| 319 | } |
| 320 | |
| 321 | /************************************************************************/ |
| 322 | /* RegisterDriver() */ |
| 323 | /************************************************************************/ |
| 324 | |
| 325 | void OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::RegisterDrivercxx . . $ OGRSFDriverRegistrar#RegisterDriver(b2b7219744bff566).(OGRSFDrivercxx . . $ OGRSFDriver# *poDriver) |
| 326 | |
| 327 | { |
| 328 | GDALDrivercxx . . $ GDALDriver# *poGDALDriver = |
| 329 | GDALDrivercxx . . $ GDALDriver#::FromHandlecxx . . $ GDALDriver#FromHandle(605f5c792cfb013b).(GDALGetDriverByName(poDriver->GetNamecxx . . $ OGRSFDriver#GetName(33a1f659e94feb42).())); |
| 330 | if (poGDALDriver == nullptr) |
| 331 | { |
| 332 | poDriver->SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(poDriver->GetNamecxx . . $ OGRSFDriver#GetName(33a1f659e94feb42).()); |
| 333 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).("OGR_DRIVER", "YES"); |
| 334 | |
| 335 | if (poDriver->GetMetadataItemcxx . . $ GDALDriver#GetMetadataItem(1320557f0feba62c).(GDAL_DMD_LONGNAMEcxx . . $ `gcore/gdal.h:443:9`!) == nullptr) |
| 336 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DMD_LONGNAMEcxx . . $ `gcore/gdal.h:443:9`!, poDriver->GetNamecxx . . $ OGRSFDriver#GetName(33a1f659e94feb42).()); |
| 337 | |
| 338 | poDriver->pfnOpenWithDriverArgcxx . . $ GDALDriver#pfnOpenWithDriverArg. = OpenWithDriverArgcxx . . $ OGRSFDriverRegistrar#OpenWithDriverArg(f9890e633aec3cf0).; |
| 339 | |
| 340 | if (poDriver->TestCapabilitycxx . . $ OGRSFDriver#TestCapability(5c4306d8553b3696).(ODrCCreateDataSourcecxx . . $ `ogr/ogr_core.h:1078:9`!)) |
| 341 | { |
| 342 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_CREATEcxx . . $ `gcore/gdal.h:607:9`!, "YES"); |
| 343 | poDriver->pfnCreateVectorOnlycxx . . $ GDALDriver#pfnCreateVectorOnly. = CreateVectorOnlycxx . . $ OGRSFDriverRegistrar#CreateVectorOnly(ba7123152ad11905).; |
| 344 | } |
| 345 | if (poDriver->TestCapabilitycxx . . $ OGRSFDriver#TestCapability(5c4306d8553b3696).(ODrCDeleteDataSourcecxx . . $ `ogr/ogr_core.h:1080:9`!)) |
| 346 | { |
| 347 | poDriver->pfnDeleteDataSourcecxx . . $ GDALDriver#pfnDeleteDataSource. = DeleteDataSourcecxx . . $ OGRSFDriverRegistrar#DeleteDataSource(90c7497c194347e1).; |
| 348 | } |
| 349 | |
| 350 | poDriver->SetMetadataItemcxx . . $ GDALDriver#SetMetadataItem(216fc8eb9053a851).(GDAL_DCAP_VECTORcxx . . $ `gcore/gdal.h:682:9`!, "YES"); |
| 351 | |
| 352 | GetGDALDriverManager()->RegisterDrivercxx . . $ GDALDriverManager#RegisterDriver(ed1dabcc01594d64).(poDriver); |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | if (poGDALDriver->GetMetadataItemcxx . . $ GDALDriver#GetMetadataItem(1320557f0feba62c).("OGR_DRIVER") == nullptr) |
| 357 | { |
| 358 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 359 | "A non OGR driver is registered with the same name: %s", |
| 360 | poDriver->GetNamecxx . . $ OGRSFDriver#GetName(33a1f659e94feb42).()); |
| 361 | } |
| 362 | delete poDriver; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /************************************************************************/ |
| 367 | /* OGRRegisterDriver() */ |
| 368 | /************************************************************************/ |
| 369 | |
| 370 | void OGRRegisterDrivercxx . . $ OGRRegisterDriver(5d22bdacc48458e8).(OGRSFDriverH hDriver) |
| 371 | |
| 372 | { |
| 373 | VALIDATE_POINTER0cxx . . $ `port/cpl_error.h:480:9`!(hDriver, "OGRRegisterDriver"); |
| 374 | |
| 375 | GetGDALDriverManager()->RegisterDrivercxx . . $ GDALDriverManager#RegisterDriver(ed1dabcc01594d64).(GDALDrivercxx . . $ GDALDriver#::FromHandlecxx . . $ GDALDriver#FromHandle(605f5c792cfb013b).(hDriver)); |
| 376 | } |
| 377 | |
| 378 | /************************************************************************/ |
| 379 | /* OGRDeregisterDriver() */ |
| 380 | /************************************************************************/ |
| 381 | |
| 382 | void OGRDeregisterDrivercxx . . $ OGRDeregisterDriver(5d22bdacc48458e8).(OGRSFDriverH hDriver) |
| 383 | |
| 384 | { |
| 385 | VALIDATE_POINTER0cxx . . $ `port/cpl_error.h:480:9`!(hDriver, "OGRDeregisterDriver"); |
| 386 | |
| 387 | GetGDALDriverManager()->DeregisterDrivercxx . . $ GDALDriverManager#DeregisterDriver(5cd378c39fe5659d).(GDALDrivercxx . . $ GDALDriver#::FromHandlecxx . . $ GDALDriver#FromHandle(605f5c792cfb013b).(hDriver)); |
| 388 | } |
| 389 | |
| 390 | /************************************************************************/ |
| 391 | /* GetDriverCount() */ |
| 392 | /************************************************************************/ |
| 393 | |
| 394 | int OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetDriverCountcxx . . $ OGRSFDriverRegistrar#GetDriverCount(b126dc7c1de90089).() |
| 395 | |
| 396 | { |
| 397 | /* We must be careful only to return drivers that are actual OGRSFDriver* */ |
| 398 | GDALDriverManagercxx . . $ GDALDriverManager# *poDriverManager = GetGDALDriverManager(); |
| 399 | int nTotal = poDriverManager->GetDriverCountcxx . . $ GDALDriverManager#GetDriverCount(455f465bc33b4cdf).(); |
| 400 | int nOGRDriverCount = 0; |
| 401 | for (int i = 0; i < nTotal; i++) |
| 402 | { |
| 403 | GDALDrivercxx . . $ GDALDriver# *poDriver = poDriverManager->GetDrivercxx . . $ GDALDriverManager#GetDriver(a7127e2e3a935015).(i); |
| 404 | if (poDriver->GetMetadataItemcxx . . $ GDALDriver#GetMetadataItem(1320557f0feba62c).(GDAL_DCAP_VECTORcxx . . $ `gcore/gdal.h:682:9`!) != nullptr) |
| 405 | nOGRDriverCount++; |
| 406 | } |
| 407 | return nOGRDriverCount; |
| 408 | } |
| 409 | |
| 410 | //! @endcond |
| 411 | |
| 412 | /************************************************************************/ |
| 413 | /* OGRGetDriverCount() */ |
| 414 | /************************************************************************/ |
| 415 | |
| 416 | /** |
| 417 | \brief Fetch the number of registered drivers. |
| 418 | |
| 419 | @deprecated Use GDALGetDriverCount() |
| 420 | |
| 421 | @return the drivers count. |
| 422 | |
| 423 | */ |
| 424 | int OGRGetDriverCountcxx . . $ OGRGetDriverCount(b126dc7c1de90089).() |
| 425 | |
| 426 | { |
| 427 | return OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetRegistrarcxx . . $ OGRSFDriverRegistrar#GetRegistrar(4e9952cdeba0aa35).()->GetDriverCountcxx . . $ OGRSFDriverRegistrar#GetDriverCount(b126dc7c1de90089).(); |
| 428 | } |
| 429 | |
| 430 | /************************************************************************/ |
| 431 | /* GetDriver() */ |
| 432 | /************************************************************************/ |
| 433 | |
| 434 | //! @cond Doxygen_Suppress |
| 435 | GDALDrivercxx . . $ GDALDriver# *OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetDrivercxx . . $ OGRSFDriverRegistrar#GetDriver(a7127e2e3a935015).(int iDriver) |
| 436 | |
| 437 | { |
| 438 | /* We must be careful only to return drivers that are actual OGRSFDriver* */ |
| 439 | GDALDriverManagercxx . . $ GDALDriverManager# *poDriverManager = GetGDALDriverManager(); |
| 440 | int nTotal = poDriverManager->GetDriverCountcxx . . $ GDALDriverManager#GetDriverCount(455f465bc33b4cdf).(); |
| 441 | int nOGRDriverCount = 0; |
| 442 | for (int i = 0; i < nTotal; i++) |
| 443 | { |
| 444 | GDALDrivercxx . . $ GDALDriver# *poDriver = poDriverManager->GetDrivercxx . . $ GDALDriverManager#GetDriver(a7127e2e3a935015).(i); |
| 445 | if (poDriver->GetMetadataItemcxx . . $ GDALDriver#GetMetadataItem(1320557f0feba62c).(GDAL_DCAP_VECTORcxx . . $ `gcore/gdal.h:682:9`!) != nullptr) |
| 446 | { |
| 447 | if (nOGRDriverCount == iDriver) |
| 448 | return poDriver; |
| 449 | nOGRDriverCount++; |
| 450 | } |
| 451 | } |
| 452 | return nullptr; |
| 453 | } |
| 454 | |
| 455 | //! @endcond |
| 456 | |
| 457 | /************************************************************************/ |
| 458 | /* OGRGetDriver() */ |
| 459 | /************************************************************************/ |
| 460 | |
| 461 | /** |
| 462 | \brief Fetch the indicated driver. |
| 463 | |
| 464 | NOTE: It is *NOT* safe to cast the returned handle to |
| 465 | OGRSFDriver*. If a C++ object is needed, the handle should be cast to GDALDriver*. |
| 466 | |
| 467 | @deprecated Use GDALGetDriver() |
| 468 | |
| 469 | @param iDriver the driver index, from 0 to GetDriverCount()-1. |
| 470 | |
| 471 | @return handle to the driver, or NULL if iDriver is out of range. |
| 472 | |
| 473 | */ |
| 474 | |
| 475 | OGRSFDriverH OGRGetDrivercxx . . $ OGRGetDriver(d1680a912d714170).(int iDriver) |
| 476 | |
| 477 | { |
| 478 | return reinterpret_cast<OGRSFDriverH>( |
| 479 | OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetRegistrarcxx . . $ OGRSFDriverRegistrar#GetRegistrar(4e9952cdeba0aa35).()->GetDrivercxx . . $ OGRSFDriverRegistrar#GetDriver(a7127e2e3a935015).(iDriver)); |
| 480 | } |
| 481 | |
| 482 | /************************************************************************/ |
| 483 | /* GetDriverByName() */ |
| 484 | /************************************************************************/ |
| 485 | |
| 486 | //! @cond Doxygen_Suppress |
| 487 | GDALDrivercxx . . $ GDALDriver# *OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetDriverByNamecxx . . $ OGRSFDriverRegistrar#GetDriverByName(715d9ac900aae6d5).(const char *pszName) |
| 488 | |
| 489 | { |
| 490 | GDALDriverManagercxx . . $ GDALDriverManager# *poDriverManager = GetGDALDriverManager(); |
| 491 | GDALDrivercxx . . $ GDALDriver# *poGDALDriver = |
| 492 | poDriverManager->GetDriverByNamecxx . . $ GDALDriverManager#GetDriverByName(715d9ac900aae6d5).(CPLSPrintf("OGR_%s", pszName)); |
| 493 | if (poGDALDriver == nullptr) |
| 494 | poGDALDriver = poDriverManager->GetDriverByNamecxx . . $ GDALDriverManager#GetDriverByName(715d9ac900aae6d5).(pszName); |
| 495 | if (poGDALDriver == nullptr || |
| 496 | poGDALDriver->GetMetadataItemcxx . . $ GDALDriver#GetMetadataItem(1320557f0feba62c).(GDAL_DCAP_VECTORcxx . . $ `gcore/gdal.h:682:9`!) == nullptr) |
| 497 | return nullptr; |
| 498 | return poGDALDriver; |
| 499 | } |
| 500 | |
| 501 | //! @endcond |
| 502 | |
| 503 | /************************************************************************/ |
| 504 | /* OGRGetDriverByName() */ |
| 505 | /************************************************************************/ |
| 506 | |
| 507 | /** |
| 508 | \brief Fetch the indicated driver. |
| 509 | |
| 510 | NOTE: It is *NOT* safe to cast the returned handle to |
| 511 | OGRSFDriver*. If a C++ object is needed, the handle should be cast to GDALDriver*. |
| 512 | |
| 513 | @deprecated Use GDALGetDriverByName() |
| 514 | |
| 515 | @param pszName the driver name |
| 516 | |
| 517 | @return the driver, or NULL if no driver with that name is found |
| 518 | */ |
| 519 | |
| 520 | OGRSFDriverH OGRGetDriverByNamecxx . . $ OGRGetDriverByName(42228c1987407501).(const char *pszName) |
| 521 | |
| 522 | { |
| 523 | VALIDATE_POINTER1cxx . . $ `port/cpl_error.h:493:9`!(pszName, "OGRGetDriverByName", nullptr); |
| 524 | |
| 525 | return reinterpret_cast<OGRSFDriverH>( |
| 526 | OGRSFDriverRegistrarcxx . . $ OGRSFDriverRegistrar#::GetRegistrarcxx . . $ OGRSFDriverRegistrar#GetRegistrar(4e9952cdeba0aa35).()->GetDriverByNamecxx . . $ OGRSFDriverRegistrar#GetDriverByName(715d9ac900aae6d5).(pszName)); |
| 527 | } |