本文整理汇总了C++中TABINDFile::CreateIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ TABINDFile::CreateIndex方法的具体用法?C++ TABINDFile::CreateIndex怎么用?C++ TABINDFile::CreateIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TABINDFile
的用法示例。
在下文中一共展示了TABINDFile::CreateIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateIndex
OGRErr OGRMILayerAttrIndex::CreateIndex( int iField )
{
/* -------------------------------------------------------------------- */
/* Do we have an open .ID file yet? If not, create it now. */
/* -------------------------------------------------------------------- */
if( poINDFile == NULL )
{
poINDFile = new TABINDFile();
if( poINDFile->Open( pszMIINDFilename, "w+" ) != 0 )
{
delete poINDFile;
poINDFile = NULL;
CPLError( CE_Failure, CPLE_OpenFailed,
"Failed to create %s.",
pszMIINDFilename );
return OGRERR_FAILURE;
}
}
/* -------------------------------------------------------------------- */
/* Do we have this field indexed already? */
/* -------------------------------------------------------------------- */
int i;
OGRFieldDefn *poFldDefn=poLayer->GetLayerDefn()->GetFieldDefn(iField);
for( i = 0; i < nIndexCount; i++ )
{
if( papoIndexList[i]->iField == iField )
{
CPLError( CE_Failure, CPLE_AppDefined,
"It seems we already have an index for field %d/%s\n"
"of layer %s.",
poFldDefn->GetNameRef(),
poLayer->GetLayerDefn()->GetName() );
return OGRERR_FAILURE;
}
}
/* -------------------------------------------------------------------- */
/* What is the corresponding field type in TAB? Note that we */
/* don't allow indexing of any of the list types. */
/* -------------------------------------------------------------------- */
TABFieldType eTABFT;
int nFieldWidth = 0;
switch( poFldDefn->GetType() )
{
case OFTInteger:
eTABFT = TABFInteger;
break;
case OFTReal:
eTABFT = TABFFloat;
break;
case OFTString:
eTABFT = TABFChar;
if( poFldDefn->GetWidth() > 0 )
nFieldWidth = poFldDefn->GetWidth();
else
nFieldWidth = 64;
break;
default:
CPLError( CE_Failure, CPLE_AppDefined,
"Indexing not support for the field type of field %s.",
poFldDefn->GetNameRef() );
return OGRERR_FAILURE;
}
/* -------------------------------------------------------------------- */
/* Create the index. */
/* -------------------------------------------------------------------- */
int iINDIndex;
iINDIndex = poINDFile->CreateIndex( eTABFT, nFieldWidth );
// CreateIndex() reports it's own errors.
if( iINDIndex < 0 )
return OGRERR_FAILURE;
AddAttrInd( iField, iINDIndex );
/* -------------------------------------------------------------------- */
/* Save the new configuration. */
/* -------------------------------------------------------------------- */
return SaveConfigToXML();
}