本文整理汇总了C++中DDFFieldDefn::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ DDFFieldDefn::Initialize方法的具体用法?C++ DDFFieldDefn::Initialize怎么用?C++ DDFFieldDefn::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDFFieldDefn
的用法示例。
在下文中一共展示了DDFFieldDefn::Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Open
//.........这里部分代码省略.........
}
}
/* -------------------------------------------------------------------- */
/* If the header is invalid, then clean up, report the error */
/* and return. */
/* -------------------------------------------------------------------- */
if( !bValid )
{
CPL_IGNORE_RET_VAL(VSIFCloseL( fpDDF ));
fpDDF = NULL;
if( !bFailQuietly )
CPLError( CE_Failure, CPLE_AppDefined,
"File `%s' does not appear to have\n"
"a valid ISO 8211 header.\n",
pszFilename );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Read the whole record info memory. */
/* -------------------------------------------------------------------- */
char *pachRecord = (char *) CPLMalloc(_recLength);
memcpy( pachRecord, achLeader, nLeaderSize );
if( (int)VSIFReadL( pachRecord+nLeaderSize, 1, _recLength-nLeaderSize, fpDDF )
!= _recLength - nLeaderSize )
{
if( !bFailQuietly )
CPLError( CE_Failure, CPLE_FileIO,
"Header record is short on DDF file `%s'.",
pszFilename );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* First make a pass counting the directory entries. */
/* -------------------------------------------------------------------- */
int nFieldEntryWidth, nFDCount = 0;
nFieldEntryWidth = _sizeFieldLength + _sizeFieldPos + _sizeFieldTag;
for( i = nLeaderSize; i < _recLength; i += nFieldEntryWidth )
{
if( pachRecord[i] == DDF_FIELD_TERMINATOR )
break;
nFDCount++;
}
/* -------------------------------------------------------------------- */
/* Allocate, and read field definitions. */
/* -------------------------------------------------------------------- */
for( i = 0; i < nFDCount; i++ )
{
char szTag[128];
int nEntryOffset = nLeaderSize + i*nFieldEntryWidth;
int nFieldLength, nFieldPos;
strncpy( szTag, pachRecord+nEntryOffset, _sizeFieldTag );
szTag[_sizeFieldTag] = '\0';
nEntryOffset += _sizeFieldTag;
nFieldLength = DDFScanInt( pachRecord+nEntryOffset, _sizeFieldLength );
nEntryOffset += _sizeFieldLength;
nFieldPos = DDFScanInt( pachRecord+nEntryOffset, _sizeFieldPos );
if (_fieldAreaStart+nFieldPos < 0 ||
_recLength - (_fieldAreaStart+nFieldPos) < nFieldLength)
{
if( !bFailQuietly )
CPLError( CE_Failure, CPLE_FileIO,
"Header record invalid on DDF file `%s'.",
pszFilename );
CPLFree( pachRecord );
return FALSE;
}
DDFFieldDefn *poFDefn = new DDFFieldDefn();
if( poFDefn->Initialize( this, szTag, nFieldLength,
pachRecord+_fieldAreaStart+nFieldPos ) )
AddField( poFDefn );
else
delete poFDefn;
}
CPLFree( pachRecord );
/* -------------------------------------------------------------------- */
/* Record the current file offset, the beginning of the first */
/* data record. */
/* -------------------------------------------------------------------- */
nFirstRecordOffset = (long)VSIFTellL( fpDDF );
return TRUE;
}