本文整理汇总了C++中DDFModule::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ DDFModule::Close方法的具体用法?C++ DDFModule::Close怎么用?C++ DDFModule::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDFModule
的用法示例。
在下文中一共展示了DDFModule::Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int nArgc, char ** papszArgv )
{
DDFModule oModule;
const char *pszFilename;
int i;
if( nArgc > 1 )
pszFilename = papszArgv[1];
else
{
printf( "Usage: 8211view filename\n" );
exit( 1 );
}
for( i = 0; i < 40; i++ )
{
/* -------------------------------------------------------------------- */
/* Open the file. Note that by default errors are reported to */
/* stderr, so we don't bother doing it ourselves. */
/* -------------------------------------------------------------------- */
if( !oModule.Open( pszFilename ) )
{
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Loop reading records till there are none left. */
/* -------------------------------------------------------------------- */
DDFRecord *poRecord;
int nRecordCount = 0;
int nFieldCount = 0;
while( (poRecord = oModule.ReadRecord()) != NULL )
{
/* ------------------------------------------------------------ */
/* Loop over each field in this particular record. */
/* ------------------------------------------------------------ */
for( int iField = 0; iField < poRecord->GetFieldCount(); iField++ )
{
DDFField *poField = poRecord->GetField( iField );
ViewRecordField( poField );
nFieldCount++;
}
nRecordCount++;
}
oModule.Close();
printf( "Read %d records, %d fields.\n", nRecordCount, nFieldCount );
}
}
示例2: main
//.........这里部分代码省略.........
const char* pachData = poField->GetData();
int nDataSize = poField->GetDataSize();
if( nRepeatCount == 1 && poDefn->GetSubfieldCount() == 0 )
{
printf(" value=\"0x");
for( int i = 0; i < nDataSize - 1; i++ )
printf( "%02X", pachData[i] );
printf("\">\n");
}
else
printf(">\n");
for( nLoopCount = 0; nLoopCount < nRepeatCount; nLoopCount++ )
{
for( int iSubField = 0; iSubField < poDefn->GetSubfieldCount(); iSubField++ )
{
int nBytesConsumed;
DDFSubfieldDefn* poSubFieldDefn = poDefn->GetSubfield(iSubField);
const char* pszSubFieldName = poSubFieldDefn->GetName();
printf(" <DDFSubfield name=\"%s\" ", pszSubFieldName);
DDFDataType eType = poSubFieldDefn->GetType();
const char* pachSubdata = pachData + iOffset;
int nMaxBytes = nDataSize - iOffset;
if( eType == DDFFloat )
printf("type=\"float\">%f",
poSubFieldDefn->ExtractFloatData( pachSubdata, nMaxBytes, NULL ) );
else if( eType == DDFInt )
printf("type=\"integer\">%d",
poSubFieldDefn->ExtractIntData( pachSubdata, nMaxBytes, NULL ) );
else if( eType == DDFBinaryString )
{
int nBytes, i;
GByte *pabyBString = (GByte *)
poSubFieldDefn->ExtractStringData( pachSubdata, nMaxBytes, &nBytes );
printf( "type=\"binary\">0x" );
for( i = 0; i < nBytes; i++ )
printf( "%02X", pabyBString[i] );
}
else
{
GByte* pabyString = (GByte *)poSubFieldDefn->ExtractStringData( pachSubdata, nMaxBytes, NULL );
int bBinary = FALSE;
int i;
for( i = 0; pabyString[i] != '\0'; i ++ )
{
if( pabyString[i] < 32 || pabyString[i] > 127 )
{
bBinary = TRUE;
break;
}
}
if( bBinary )
{
printf( "type=\"binary\">0x" );
for( i = 0; pabyString[i] != '\0'; i ++ )
printf( "%02X", pabyString[i] );
}
else
{
char* pszEscaped = CPLEscapeString((const char*)pabyString, -1, CPLES_XML);
printf("type=\"string\">%s", pszEscaped);
CPLFree(pszEscaped);
}
}
printf("</DDFSubfield>\n");
poSubFieldDefn->GetDataLength( pachSubdata, nMaxBytes, &nBytesConsumed );
iOffset += nBytesConsumed;
}
}
printf(" </DDFField>\n");
}
printf("</DDFRecord>\n");
}
printf("</DDFModule>\n");
}
else
{
oModule.Dump( stdout );
long nStartLoc;
nStartLoc = VSIFTellL( oModule.GetFP() );
for( poRecord = oModule.ReadRecord();
poRecord != NULL; poRecord = oModule.ReadRecord() )
{
printf( "File Offset: %ld\n", nStartLoc );
poRecord->Dump( stdout );
nStartLoc = VSIFTellL( oModule.GetFP() );
}
}
oModule.Close();
#ifdef DBMALLOC
malloc_dump(1);
#endif
}
示例3: Open
int SDTSRasterReader::Open( SDTS_CATD * poCATD, SDTS_IREF * poIREF,
const char * pszModule )
{
strncpy( szModule, pszModule, sizeof(szModule) );
szModule[sizeof(szModule) - 1] = '\0';
/* ==================================================================== */
/* Search the LDEF module for the requested cell module. */
/* ==================================================================== */
DDFModule oLDEF;
DDFRecord *poRecord;
/* -------------------------------------------------------------------- */
/* Open the LDEF module, and report failure if it is missing. */
/* -------------------------------------------------------------------- */
if( poCATD->GetModuleFilePath("LDEF") == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Can't find LDEF entry in CATD module ... "
"can't treat as raster.\n" );
return FALSE;
}
if( !oLDEF.Open( poCATD->GetModuleFilePath("LDEF") ) )
return FALSE;
/* -------------------------------------------------------------------- */
/* Read each record, till we find what we want. */
/* -------------------------------------------------------------------- */
while( (poRecord = oLDEF.ReadRecord() ) != NULL )
{
const char* pszCandidateModule = poRecord->GetStringSubfield("LDEF",0,"CMNM",0);
if( pszCandidateModule == NULL )
{
poRecord = NULL;
break;
}
if( EQUAL(pszCandidateModule, pszModule) )
break;
}
if( poRecord == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Can't find module `%s' in LDEF file.\n",
pszModule );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Extract raster dimensions, and origin offset (0/1). */
/* -------------------------------------------------------------------- */
nXSize = poRecord->GetIntSubfield( "LDEF", 0, "NCOL", 0 );
nYSize = poRecord->GetIntSubfield( "LDEF", 0, "NROW", 0 );
nXStart = poRecord->GetIntSubfield( "LDEF", 0, "SOCI", 0 );
nYStart = poRecord->GetIntSubfield( "LDEF", 0, "SORI", 0 );
/* -------------------------------------------------------------------- */
/* Get the point in the pixel that the origin defines. We only */
/* support top left and center. */
/* -------------------------------------------------------------------- */
const char* pszINTR = poRecord->GetStringSubfield( "LDEF", 0, "INTR", 0 );
if( pszINTR == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined, "Can't find INTR subfield of LDEF field" );
return FALSE;
}
strcpy( szINTR, pszINTR );
if( EQUAL(szINTR,"") )
strcpy( szINTR, "CE" );
if( !EQUAL(szINTR,"CE") && !EQUAL(szINTR,"TL") )
{
CPLError( CE_Warning, CPLE_AppDefined,
"Unsupported INTR value of `%s', assume CE.\n"
"Positions may be off by one pixel.\n",
szINTR );
strcpy( szINTR, "CE" );
}
/* -------------------------------------------------------------------- */
/* Record the LDEF record number we used so we can find the */
/* corresponding RSDF record. */
/* -------------------------------------------------------------------- */
int nLDEF_RCID;
nLDEF_RCID = poRecord->GetIntSubfield( "LDEF", 0, "RCID", 0 );
oLDEF.Close();
/* ==================================================================== */
/* Search the RSDF module for the requested cell module. */
/* ==================================================================== */
DDFModule oRSDF;
/* -------------------------------------------------------------------- */
/* Open the RSDF module, and report failure if it is missing. */
/* -------------------------------------------------------------------- */
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
if( pszValue != NULL && STARTS_WITH(pszValue, "0x") )
{
pszValue += 2;
int nDataLen = (int)strlen(pszValue) / 2;
char* pabyData = (char*) malloc(nDataLen);
for(int i=0;i<nDataLen;i++)
{
char c;
int nHigh, nLow;
c = pszValue[2*i];
if( c >= 'A' && c <= 'F' )
nHigh = 10 + c - 'A';
else
nHigh = c - '0';
c = pszValue[2*i + 1];
if( c >= 'A' && c <= 'F' )
nLow = 10 + c - 'A';
else
nLow = c - '0';
pabyData[i] = (nHigh << 4) + nLow;
}
poRec->SetFieldRaw( poField, nFieldOcc, (const char *) pabyData, nDataLen );
free(pabyData);
}
else
{
CPLXMLNode* psSubfieldIter = psSubIter->psChild;
std::map<std::string, int> oMapSubfield;
while( psSubfieldIter != NULL )
{
if( psSubfieldIter->eType == CXT_Element &&
strcmp(psSubfieldIter->pszValue, "DDFSubfield") == 0 )
{
const char* pszSubfieldName = CPLGetXMLValue(psSubfieldIter, "name", "");
const char* pszSubfieldType = CPLGetXMLValue(psSubfieldIter, "type", "");
const char* pszSubfieldValue = CPLGetXMLValue(psSubfieldIter, NULL, "");
int nOcc = oMapSubfield[pszSubfieldName];
oMapSubfield[pszSubfieldName] ++ ;
if( strcmp(pszSubfieldType, "float") == 0 )
{
poRec->SetFloatSubfield( pszFieldName, nFieldOcc, pszSubfieldName, nOcc,
CPLAtof(pszSubfieldValue) );
}
else if( strcmp(pszSubfieldType, "integer") == 0 )
{
poRec->SetIntSubfield( pszFieldName, nFieldOcc, pszSubfieldName, nOcc,
atoi(pszSubfieldValue) );
}
else if( strcmp(pszSubfieldType, "string") == 0 )
{
poRec->SetStringSubfield( pszFieldName, nFieldOcc, pszSubfieldName, nOcc,
pszSubfieldValue );
}
else if( strcmp(pszSubfieldType, "binary") == 0 &&
STARTS_WITH(pszSubfieldValue, "0x") )
{
pszSubfieldValue += 2;
int nDataLen = (int)strlen(pszSubfieldValue) / 2;
char* pabyData = (char*) malloc(nDataLen);
for(int i=0;i<nDataLen;i++)
{
char c;
int nHigh, nLow;
c = pszSubfieldValue[2*i];
if( c >= 'A' && c <= 'F' )
nHigh = 10 + c - 'A';
else
nHigh = c - '0';
c = pszSubfieldValue[2*i + 1];
if( c >= 'A' && c <= 'F' )
nLow = 10 + c - 'A';
else
nLow = c - '0';
pabyData[i] = (nHigh << 4) + nLow;
}
poRec->SetStringSubfield( pszFieldName, nFieldOcc, pszSubfieldName, nOcc,
pabyData, nDataLen );
free(pabyData);
}
}
psSubfieldIter = psSubfieldIter->psNext;
}
}
}
psSubIter = psSubIter->psNext;
}
poRec->Write();
delete poRec;
}
psIter = psIter->psNext;
}
CPLDestroyXMLNode(poRoot);
oModule.Close();
return 0;
}