File Geodatabase API
FileGDBAPI::Geodatabase Class Reference

A class representing a File Geodatabase. More...

Public Member Functions

Schema browsing
fgdbError GetDatasetTypes (std::vector< std::wstring > &datasetTypes) const
 Gets a list of the dataset types in the geodatabase. More...
 
fgdbError GetDatasetRelationshipTypes (std::vector< std::wstring > &relationshipTypes) const
 Gets a list of relationship types in the geodatabase. More...
 
fgdbError GetChildDatasets (const std::wstring &parentPath, const std::wstring &datasetType, std::vector< std::wstring > &childDatasets) const
 Gets the child datasets for a particular dataset, if any. More...
 
fgdbError GetRelatedDatasets (const std::wstring &path, const std::wstring &relType, const std::wstring &datasetType, std::vector< std::wstring > &relatedDatasets) const
 Gets the related datasets for a particular dataset, if any. More...
 
Schema definition
fgdbError GetDatasetDefinition (const std::wstring &path, const std::wstring &datasetType, std::string &datasetDef) const
 Gets the definition of a dataset as an XML document. More...
 
fgdbError GetChildDatasetDefinitions (const std::wstring &parentPath, const std::wstring &datasetType, std::vector< std::string > &childDatasetDefs) const
 Gets the definitions of child datasets as a collection of XML documents. More...
 
fgdbError GetRelatedDatasetDefinitions (const std::wstring &path, const std::wstring &relType, const std::wstring &datasetType, std::vector< std::string > &relatedDatasetDefs) const
 Gets the definitions of related datasets as a collection of XML documents. More...
 
fgdbError GetDatasetDocumentation (const std::wstring &path, const std::wstring &datasetType, std::string &documentation) const
 Gets the metadata of a dataset as XML. More...
 
Datasets
fgdbError CreateFeatureDataset (const std::string &featureDatasetDef)
 Creates a new feature dataset. More...
 
fgdbError CreateFeatureDataset (const std::wstring &path, const SpatialReference &spatialReference)
 Creates a new feature dataset. More...
 
fgdbError CreateTable (const std::string &tableDef, const std::wstring &parent, Table &table)
 Creates a new table. More...
 
fgdbError CreateTable (const std::wstring &path, const std::vector< FieldDef > &fieldDefs, const std::wstring &configurationKeyword, Table &table)
 
fgdbError OpenTable (const std::wstring &path, Table &table)
 Opens a table. More...
 
fgdbError CloseTable (Table &table)
 Closes a table that has been previously created or opened. More...
 
fgdbError Rename (const std::wstring &path, const std::wstring &datasetType, const std::wstring &newName)
 Renames a dataset. More...
 
fgdbError Move (const std::wstring &path, const std::wstring &newParentPath)
 Moves a dataset from one container to another. More...
 
fgdbError Delete (const std::wstring &path, const std::wstring &datasetType)
 Deletes a dataset. More...
 
fgdbError CompactDatabase ()
 Compacts the geodatabase. More...
 
Domains
fgdbError GetDomains (std::vector< std::wstring > &domainNames) const
 Gets the names of all domains, if any. More...
 
fgdbError CreateDomain (const std::string &domainDef)
 Creates a domain. More...
 
fgdbError AlterDomain (const std::string &domainDef)
 Modifies the properties of an existing domain. More...
 
fgdbError DeleteDomain (const std::wstring &domainName)
 Deletes the specified domain. More...
 
fgdbError GetDomainDefinition (const std::wstring &domainName, std::string &domainDef) const
 Gets the definition of the specified domain. More...
 
SQL
fgdbError GetQueryName (const std::wstring &path, std::wstring &queryName) const
 Gets the query name (the name to use in SQL statements) of a table based on its path. More...
 
fgdbError ExecuteSQL (const std::wstring &sqlStmt, bool recycling, EnumRows &rows) const
 Executes a SQL statement on the geodatabase. More...
 
Constructors and Destructors
 Geodatabase ()
 The class constructor.
 
 ~Geodatabase ()
 The class destructor.
 

Detailed Description

A class representing a File Geodatabase.

Member Function Documentation

fgdbError FileGDBAPI::Geodatabase::GetDatasetTypes ( std::vector< std::wstring > &  datasetTypes) const

Gets a list of the dataset types in the geodatabase.

Parameters
[out]datasetTypesThe dataset types in the geodatabase.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetDatasetRelationshipTypes ( std::vector< std::wstring > &  relationshipTypes) const

Gets a list of relationship types in the geodatabase.

Parameters
[out]relationshipTypesThe relationship types in the geodatabase.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetChildDatasets ( const std::wstring &  parentPath,
const std::wstring &  datasetType,
std::vector< std::wstring > &  childDatasets 
) const

Gets the child datasets for a particular dataset, if any.

If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.

Parameters
[in]parentPathThe dataset to find the children of, e.g. "\usa".
[in]datasetTypeThe child dataset type as a wstring, e.g. "Feature Class". Passing in an empty string will return all child datasets. DatasetType
[out]childDatasetsThe children of the parent dataset, if any.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetRelatedDatasets ( const std::wstring &  path,
const std::wstring &  relType,
const std::wstring &  datasetType,
std::vector< std::wstring > &  relatedDatasets 
) const

Gets the related datasets for a particular dataset, if any.

If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.

Parameters
[in]pathThe path of the dataset to find related datasets for, e.g. "\usa\streets_topology".
[in]relTypeThe relationship type to filter return values with, e.g. "DatasetInFeatureDataset". Passing in an empty string will return all related datasets. RelationshipType
[in]datasetTypeThe type of the dataset to find related datasets for. DatasetType
[out]relatedDatasetsThe origin dataset's related datasets, if any.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetDatasetDefinition ( const std::wstring &  path,
const std::wstring &  datasetType,
std::string &  datasetDef 
) const

Gets the definition of a dataset as an XML document.

If the dataset does not exist, this will fail with an error code of -2147220655 (The table was not found). If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.

Parameters
[in]pathThe requested dataset's path. e.g. "\usa\city_anno"
[in]datasetTypeThe requested dataset's type as a string, e.g. "Table". DatasetType
[out]datasetDefThe dataset's definition as an XML document.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetChildDatasetDefinitions ( const std::wstring &  parentPath,
const std::wstring &  datasetType,
std::vector< std::string > &  childDatasetDefs 
) const

Gets the definitions of child datasets as a collection of XML documents.

If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.

Parameters
[in]parentPathThe parent dataset's path, e.g. "\usa".
[in]datasetTypeThe parent dataset's type as a string, e.g. "Feature Dataset". Passing in an empty string will return all child datasets. DatasetType
[out]childDatasetDefsA collection of child dataset definitions, if any.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetRelatedDatasetDefinitions ( const std::wstring &  path,
const std::wstring &  relType,
const std::wstring &  datasetType,
std::vector< std::string > &  relatedDatasetDefs 
) const

Gets the definitions of related datasets as a collection of XML documents.

If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.

Parameters
[in]pathThe origin dataset's path, e.g. "\usa\streets_topology"
[in]relTypeThe relationship type to filter return values with, e.g. "DatasetInFeatureDataset". RelationshipType
[in]datasetTypeThe origin dataset's type as a string, e.g. "Relationship Class". Passing in an empty string will return all related datasets. DatasetType
[out]relatedDatasetDefsA collection of related dataset definitions, if any.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetDatasetDocumentation ( const std::wstring &  path,
const std::wstring &  datasetType,
std::string &  documentation 
) const

Gets the metadata of a dataset as XML.

If a non-existent path is provided, a -2147211775 (The item was not found) error will be returned.

Parameters
[in]pathThe requested dataset's path. e.g. "\address_list"
[in]datasetTypeThe requested dataset's type as a string, e.g. "Table". DatasetType
[out]documentationThe dataset's metadata as XML.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CreateFeatureDataset ( const std::string &  featureDatasetDef)

Creates a new feature dataset.

If the feature dataset already exists, a -2147220733 (The dataset already exists) error will be returned.
If the feature dataset name is missing from the XML, a -2147220645 (INVALID_NAME) error will be returned.
If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
XML

Parameters
[in]featureDatasetDefThe XML definition of the feature dataset to be created.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CreateFeatureDataset ( const std::wstring &  path,
const SpatialReference spatialReference 
)

Creates a new feature dataset.

If the feature dataset already exists, a -2147220733 (The dataset already exists) error will be returned.

Parameters
[in]pathThe name of the feature dataset to be created.
[in]spatialReferenceThe spatial reference of the feature dataset to be created.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CreateTable ( const std::string &  tableDef,
const std::wstring &  parent,
Table table 
)

Creates a new table.

This can either be a table or a feature class. If a geometry is to support Zs or Ms (measures), HasZ and or HasM must be set to true in the GeometryDef in the XML. The ZOrigin, MOrigin, ZScale and MScale must also be set in the SpatialReferences in the XML. These do not default. See the samples\XMLsamples\FC_GCS_LineMin.xml for an example. Domain definitions in the table XML definition will be ignored. Use Table.AlterField to assign a domain. If the table already exists, a -2147220653 (The table already exists) error will be returned.
If the table name is missing from the XML, a -2147220654 (The table name is invalid) error will be returned.
If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
XML-TableXML-Feature Class XML-Feature Class with the minimum spatial reference definition XML-Feature Class to be created in a feature dataset

Parameters
[in]tableDefThe XML definition of the table to be created.
[in]parentThe location where the table will be created. Pass an empty string if you want to create a table or feature class at the root. If you want to create a feature class in an existing feature dataset use the path "\USA".
[out]tableA Table instance for the newly created table.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CreateTable ( const std::wstring &  path,
const std::vector< FieldDef > &  fieldDefs,
const std::wstring &  configurationKeyword,
Table table 
)
Parameters
[in]pathThe path of the table to create. If creating a table or feature class at the root make sure to include "\". If creating a feature class in a feature dataset include the feature dataset name in the path "\USA\counties".
[in]fieldDefsThe field definitions of the table to be created.
[in]configurationKeywordThe configuration keyword of the table to be created. If a empty string or unknown keyword is entered, the DEFAULTS keyword is used. Configuration Keywords
[out]tableA Table instance for the newly created table.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::OpenTable ( const std::wstring &  path,
Table table 
)

Opens a table.

This can also be used to open attributed and M:N relationship class tables. If the table does not exist, a -2147220655 (The table was not found) error will be returned. Attempting to open a compressed file is not supported and a -2147220109 (FileGDB compression is not installed.) error will be returned.

Parameters
[in]pathThe path of the table to open. Opening a table or feature class at the root make sure to include "\". If opening a feature class in a feature dataset include the feature dataset name in the path "\USA\counties".
[out]tableAn Table instance for the opened table.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CloseTable ( Table table)

Closes a table that has been previously created or opened.

Parameters
[in]tableThe table to close.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::Rename ( const std::wstring &  path,
const std::wstring &  datasetType,
const std::wstring &  newName 
)

Renames a dataset.

Parameters
[in]pathThe path of the dataset, e.g. "\Landbase\Parcels".
[in]datasetTypeThe requested dataset's type as a string, e.g. "Table". DatasetType
[in]newNameThe name to apply to the dataset, e.g. "Parcels2".
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::Move ( const std::wstring &  path,
const std::wstring &  newParentPath 
)

Moves a dataset from one container to another.

Parameters
[in]pathThe path of the dataset to move, e.g. "\Landbase\Parcels".
[in]newParentPathThe path of the container the dataset will be moved to, e.g. "\LandUse".
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::Delete ( const std::wstring &  path,
const std::wstring &  datasetType 
)

Deletes a dataset.

If a the dataset does not exist, this will fail with an error code of -2147219118 (A requested row object could not be located).
If you do not have delete access to the dataset, this will fail with an error code of E_FAIL.

Parameters
[in]pathThe path of the dataset to delete, e.g. "\Owners".
[in]datasetTypeThe requested dataset's type as a string, e.g. "Table". DatasetType
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CompactDatabase ( )

Compacts the geodatabase.

Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetDomains ( std::vector< std::wstring > &  domainNames) const

Gets the names of all domains, if any.

Parameters
[out]domainNamesThe domains.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::CreateDomain ( const std::string &  domainDef)

Creates a domain.

If the XML is not UTF-8, create will fail with an error code of -2147024809 (Invalid function arguments).
If the domain name already exists, a -2147209212 (Domain name already in use) error will be returned.
XML - Coded Value Domain XML - Range Domain

Parameters
[in]domainDefThe XML definition of the domain to be created.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::AlterDomain ( const std::string &  domainDef)

Modifies the properties of an existing domain.

If the XML is not UTF-8, create will fail with an error code of -2147024809 (Invalid function arguments).

Parameters
[in]domainDefThe modified XML definition of the domain.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::DeleteDomain ( const std::wstring &  domainName)

Deletes the specified domain.

If the domain does not exist, this will fail with an error code of -2147209215 (The domain was not found).

Parameters
[in]domainNameThe name of the domain to delete.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetDomainDefinition ( const std::wstring &  domainName,
std::string &  domainDef 
) const

Gets the definition of the specified domain.

Parameters
[in]domainNameThe name of the domain.
[out]domainDefThe XML definition of the domain.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::GetQueryName ( const std::wstring &  path,
std::wstring &  queryName 
) const

Gets the query name (the name to use in SQL statements) of a table based on its path.

Parameters
[in]pathThe path of the dataset that will be queried.
[out]queryNameThe name that should be used for the table in SQL statements.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Geodatabase::ExecuteSQL ( const std::wstring &  sqlStmt,
bool  recycling,
EnumRows rows 
) const

Executes a SQL statement on the geodatabase.

This may or may not return a result set. A DELETE without a WHERE clause will result in a truncate. If the SQL statement is invalid, an -2147220985 (An invalid SQL statement was used) error will be returned.

Parameters
[in]sqlStmtThe SQL statement to be executed.
[in]recyclingIndicates whether the row enumerator should recycle memory.
[out]rowsAn enumerator of rows or a null value.
Returns
Error code indicating whether the method finished successfully.