本文整理汇总了C++中DDFSubfieldDefn::ExtractFloatData方法的典型用法代码示例。如果您正苦于以下问题:C++ DDFSubfieldDefn::ExtractFloatData方法的具体用法?C++ DDFSubfieldDefn::ExtractFloatData怎么用?C++ DDFSubfieldDefn::ExtractFloatData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDFSubfieldDefn
的用法示例。
在下文中一共展示了DDFSubfieldDefn::ExtractFloatData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
static void
WriteAttrRecordToDBF( DBFHandle hDBF, int iRecord,
SDTSTransfer * poTransfer, DDFField * poSR )
{
/* -------------------------------------------------------------------- */
/* Process each subfield in the record. */
/* -------------------------------------------------------------------- */
DDFFieldDefn *poFDefn = poSR->GetFieldDefn();
for( int iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ )
{
DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF );
int iField;
int nMaxBytes;
const char * pachData = poSR->GetSubfieldData(poSFDefn,
&nMaxBytes);
/* -------------------------------------------------------------------- */
/* Identify the related DBF field, if any. */
/* -------------------------------------------------------------------- */
for( iField = 0; iField < hDBF->nFields; iField++ )
{
if( EQUALN(poSFDefn->GetName(),
hDBF->pszHeader+iField*32,10) )
break;
}
if( iField == hDBF->nFields )
iField = -1;
/* -------------------------------------------------------------------- */
/* Handle each of the types. */
/* -------------------------------------------------------------------- */
switch( poSFDefn->GetType() )
{
case DDFString:
const char *pszValue;
pszValue = poSFDefn->ExtractStringData(pachData, nMaxBytes,
NULL);
if( iField != -1 )
DBFWriteStringAttribute(hDBF, iRecord, iField, pszValue );
break;
case DDFFloat:
double dfValue;
dfValue = poSFDefn->ExtractFloatData(pachData, nMaxBytes,
NULL);
if( iField != -1 )
DBFWriteDoubleAttribute( hDBF, iRecord, iField, dfValue );
break;
case DDFInt:
int nValue;
nValue = poSFDefn->ExtractIntData(pachData, nMaxBytes, NULL);
if( iField != -1 )
DBFWriteIntegerAttribute( hDBF, iRecord, iField, nValue );
break;
default:
break;
}
} /* next subfield */
}
示例2: main
//.........这里部分代码省略.........
{
DDFField* poField = poRecord->GetField(iField);
DDFFieldDefn* poDefn = poField->GetFieldDefn();
const char* pszFieldName = poDefn->GetName();
printf(" <DDFField name=\"%s\"", pszFieldName);
if( poField->GetRepeatCount() > 1 )
printf(" repeatCount=\"%d\"", poField->GetRepeatCount());
int iOffset = 0, nLoopCount;
int nRepeatCount = poField->GetRepeatCount();
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] );
}
示例3: switch
static void
AssignAttrRecordToFeature( OGRFeature * poFeature,
CPL_UNUSED SDTSTransfer * poTransfer,
DDFField * poSR )
{
/* -------------------------------------------------------------------- */
/* Process each subfield in the record. */
/* -------------------------------------------------------------------- */
DDFFieldDefn *poFDefn = poSR->GetFieldDefn();
for( int iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ )
{
DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF );
int iField;
int nMaxBytes;
const char * pachData = poSR->GetSubfieldData(poSFDefn,
&nMaxBytes);
/* -------------------------------------------------------------------- */
/* Indentify this field on the feature. */
/* -------------------------------------------------------------------- */
iField = poFeature->GetFieldIndex( poSFDefn->GetName() );
/* -------------------------------------------------------------------- */
/* Handle each of the types. */
/* -------------------------------------------------------------------- */
switch( poSFDefn->GetType() )
{
case DDFString:
const char *pszValue;
pszValue = poSFDefn->ExtractStringData(pachData, nMaxBytes,
NULL);
if( iField != -1 )
poFeature->SetField( iField, pszValue );
break;
case DDFFloat:
double dfValue;
dfValue = poSFDefn->ExtractFloatData(pachData, nMaxBytes,
NULL);
if( iField != -1 )
poFeature->SetField( iField, dfValue );
break;
case DDFInt:
int nValue;
nValue = poSFDefn->ExtractIntData(pachData, nMaxBytes, NULL);
if( iField != -1 )
poFeature->SetField( iField, nValue );
break;
default:
break;
}
} /* next subfield */
}