OGR
Public Member Functions | List of all members
OGRSFDriver Class Referenceabstract

#include <ogrsf_frmts.h>

Public Member Functions

virtual const char * GetName ()=0
 Fetch name of driver (file format). This name should be relatively short (10-40 characters), and should reflect the underlying file format. For instance "ESRI Shapefile". More...
 
virtual OGRDataSourceOpen (const char *pszName, int bUpdate=FALSE)=0
 Attempt to open file with this driver. More...
 
virtual int TestCapability (const char *)=0
 Test if capability is available. More...
 
virtual OGRDataSourceCreateDataSource (const char *pszName, char **=NULL)
 This method attempts to create a new data source based on the passed driver. More...
 
virtual OGRErr DeleteDataSource (const char *pszName)
 Delete a datasource. More...
 
virtual OGRDataSourceCopyDataSource (OGRDataSource *poSrcDS, const char *pszNewName, char **papszOptions=NULL)
 This method creates a new datasource by copying all the layers from the source datasource. More...
 

Detailed Description

Represents an operational format driver.

One OGRSFDriver derived class will normally exist for each file format registered for use, regardless of whether a file has or will be opened. The list of available drivers is normally managed by the OGRSFDriverRegistrar.

Member Function Documentation

OGRDataSource * OGRSFDriver::CopyDataSource ( OGRDataSource poSrcDS,
const char *  pszNewName,
char **  papszOptions = NULL 
)
virtual

This method creates a new datasource by copying all the layers from the source datasource.

It is important to call OGRDataSource::DestroyDataSource() when the datasource is no longer used to ensure that all data has been properly flushed to disk.

This method is the same as the C function OGR_Dr_CopyDataSource().

Parameters
poSrcDSsource datasource
pszNewNamethe name for the new data source. UTF-8 encoded.
papszOptionsa StringList of name=value options. Options are driver specific, and driver information can be found at the following url: http://www.gdal.org/ogr/ogr_formats.html
Returns
NULL is returned on failure, or a new OGRDataSource handle on success.

References OGRDataSource::CopyLayer(), CPLError(), CreateDataSource(), OGRDataSource::GetDriver(), OGRDataSource::GetLayer(), OGRDataSource::GetLayerCount(), OGRLayer::GetLayerDefn(), OGRFeatureDefn::GetName(), GetName(), OGRDataSource::SetDriver(), and TestCapability().

OGRDataSource * OGRSFDriver::CreateDataSource ( const char *  pszName,
char **  papszOptions = NULL 
)
virtual

This method attempts to create a new data source based on the passed driver.

The papszOptions argument can be used to control driver specific creation options. These options are normally documented in the format specific documentation.

It is important to call OGRDataSource::DestroyDataSource() when the datasource is no longer used to ensure that all data has been properly flushed to disk.

This method is the same as the C function OGR_Dr_CreateDataSource().

Note
This method does NOT attach driver instance to the returned data source, so caller should expect that OGRDataSource::GetDriver() will return NULL pointer. In order to attach driver to the returned data source, it is required to use C function OGR_Dr_CreateDataSource. This behavior is related to fix of issue reported in Ticket #1233.
Parameters
pszNamethe name for the new data source. UTF-8 encoded.
papszOptionsa StringList of name=value options. Options are driver specific, and driver information can be found at the following url: http://www.gdal.org/ogr/ogr_formats.html
Returns
NULL is returned on failure, or a new OGRDataSource on success.

References CPLError().

Referenced by CopyDataSource(), and OGR_Dr_CreateDataSource().

OGRErr OGRSFDriver::DeleteDataSource ( const char *  pszDataSource)
virtual

Delete a datasource.

Delete (from the disk, in the database, ...) the named datasource. Normally it would be safest if the datasource was not open at the time.

Whether this is a supported operation on this driver case be tested using TestCapability() on ODrCDeleteDataSource.

This method is the same as the C function OGR_Dr_DeleteDataSource().

Parameters
pszDataSourcethe name of the datasource to delete.
Returns
OGRERR_NONE on success, and OGRERR_UNSUPPORTED_OPERATION if this is not supported by this driver.

References CPLError().

const char * OGRSFDriver::GetName ( )
pure virtual

Fetch name of driver (file format). This name should be relatively short (10-40 characters), and should reflect the underlying file format. For instance "ESRI Shapefile".

This method is the same as the C function OGR_Dr_GetName().

Returns
driver name. This is an internal string and should not be modified or freed.

Referenced by CopyDataSource(), OGRDataSource::ExecuteSQL(), OGRSFDriverRegistrar::Open(), and OGRSFDriverRegistrar::RegisterDriver().

OGRDataSource * OGRSFDriver::Open ( const char *  pszName,
int  bUpdate = FALSE 
)
pure virtual

Attempt to open file with this driver.

This method is what OGRSFDriverRegistrar uses to implement its Open() method. See it for more details.

Note, drivers do not normally set their own m_poDriver value, so a direct call to this method (instead of indirectly via OGRSFDriverRegistrar) will usually result in a datasource that does not know what driver it relates to if GetDriver() is called on the datasource. The application may directly call SetDriver() after opening with this method to avoid this problem.

For drivers supporting the VSI virtual file API, it is possible to open a file in a .zip archive (see VSIInstallZipFileHandler()), in a .tar/.tar.gz/.tgz archive (see VSIInstallTarFileHandler()) or on a HTTP / FTP server (see VSIInstallCurlFileHandler())

This method is the same as the C function OGR_Dr_Open().

Parameters
pszNamethe name of the file, or data source to try and open.
bUpdateTRUE if update access is required, otherwise FALSE (the default).
Returns
NULL on error or if the pass name is not supported by this driver, otherwise a pointer to an OGRDataSource. This OGRDataSource should be closed by deleting the object when it is no longer needed.

Referenced by OGRSFDriverRegistrar::Open().

int OGRSFDriver::TestCapability ( const char *  pszCapability)
pure virtual

Test if capability is available.

One of the following data source capability names can be passed into this method, and a TRUE or FALSE value will be returned indicating whether or not the capability is available for this object.

  • ODrCCreateDataSource: True if this driver can support creating data sources.

  • ODrCDeleteDataSource: True if this driver supports deleting data sources.

The #define macro forms of the capability names should be used in preference to the strings themselves to avoid mispelling.

This method is the same as the C function OGR_Dr_TestCapability().

Parameters
pszCapabilitythe capability to test.
Returns
TRUE if capability available otherwise FALSE.

Referenced by CopyDataSource().


The documentation for this class was generated from the following files:

Generated for GDAL by doxygen 1.8.11.