File Geodatabase API
FileGDBAPI::Geodatabase Class Reference

A class representing a File Geodatabase. More...

List of all members.

Public Member Functions

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

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)

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 
)

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 
)

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 
)

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 
)

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 
)

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 
)

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::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 samlples\XMLsamples\FC_GCS_LineMin.xml for an example. Domain assignment in a table defintion will be ignored. Use Table.AlterField to asssign 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-Table
XML-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]tableAn 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::GetDomains ( std::vector< std::wstring > &  domainNames)

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 
)

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 
)

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 
)

Executes a SQL statement on the geodatabase.

This may or may not return a result set. 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.