OGRSFDriver Class Reference

#include <ogrsf_frmts.h>

List of all members.

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".
virtual OGRDataSourceOpen (const char *pszName, int bUpdate=FALSE)=0
 Attempt to open file with this driver.
virtual int TestCapability (const char *)=0
 Test if capability is available.
virtual OGRDataSourceCreateDataSource (const char *pszName, char **=NULL)
 This method attempts to create a new data source based on the passed driver.
virtual OGRErr DeleteDataSource (const char *pszName)
 Delete a datasource.
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.


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:
poSrcDS source datasource
pszNewName the name for the new data source.
papszOptions a 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(), CreateDataSource(), OGRDataSource::GetLayer(), OGRDataSource::GetLayerCount(), OGRLayer::GetLayerDefn(), OGRFeatureDefn::GetName(), GetName(), 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 soruce, it is required to use C function OGR_Dr_CreateDataSource. This behavior is related to fix of issue reported in Ticket #1233.
Parameters:
pszName the name for the new data source.
papszOptions a 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.

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:
pszDataSource the name of the datasource to delete.
Returns:
OGRERR_NONE on success, and OGRERR_UNSUPPORTED_OPERATION if this is not supported by this driver.

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(), 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.

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

Parameters:
pszName the name of the file, or data source to try and open.
bUpdate TRUE 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:
pszCapability the 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.5.7.1.