本文整理汇总了C++中DDFModule::GetFieldControlLength方法的典型用法代码示例。如果您正苦于以下问题:C++ DDFModule::GetFieldControlLength方法的具体用法?C++ DDFModule::GetFieldControlLength怎么用?C++ DDFModule::GetFieldControlLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDFModule
的用法示例。
在下文中一共展示了DDFModule::GetFieldControlLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int nArgc, char ** papszArgv )
{
DDFModule oModule;
const char *pszFilename = NULL;
int bFSPTHack = FALSE;
int bXML = FALSE;
bool bAllDetails = false;
/* -------------------------------------------------------------------- */
/* Check arguments. */
/* -------------------------------------------------------------------- */
for( int iArg = 1; iArg < nArgc; iArg++ )
{
if( EQUAL(papszArgv[iArg],"-fspt_repeating") )
bFSPTHack = TRUE;
else if( EQUAL(papszArgv[iArg],"-xml") )
bXML = TRUE;
else if( EQUAL(papszArgv[iArg],"-xml_all_details") )
{
bXML = TRUE;
bAllDetails = true;
}
else
pszFilename = papszArgv[iArg];
}
if( pszFilename == NULL )
{
printf( "Usage: 8211dump [-xml|-xml_all_details] [-fspt_repeating] filename\n" );
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Open file. */
/* -------------------------------------------------------------------- */
if( !oModule.Open( pszFilename ) )
exit( 1 );
/* -------------------------------------------------------------------- */
/* Apply FSPT hack if required. */
/* -------------------------------------------------------------------- */
if( bFSPTHack )
{
DDFFieldDefn *poFSPT = oModule.FindFieldDefn( "FSPT" );
if( poFSPT == NULL )
fprintf( stderr,
"unable to find FSPT field to set repeating flag.\n" );
else
poFSPT->SetRepeatingFlag( TRUE );
}
/* -------------------------------------------------------------------- */
/* Dump header, and all records. */
/* -------------------------------------------------------------------- */
if( bXML )
{
printf("<DDFModule");
if( bAllDetails )
{
printf(" _interchangeLevel=\"%c\"", oModule.GetInterchangeLevel());
printf(" _leaderIden=\"%c\"", oModule.GetLeaderIden());
printf(" _inlineCodeExtensionIndicator=\"%c\"", oModule.GetCodeExtensionIndicator());
printf(" _versionNumber=\"%c\"", oModule.GetVersionNumber());
printf(" _appIndicator=\"%c\"", oModule.GetAppIndicator());
printf(" _extendedCharSet=\"%s\"", oModule.GetExtendedCharSet());
printf(" _fieldControlLength=\"%d\"", oModule.GetFieldControlLength());
printf(" _sizeFieldLength=\"%d\"", oModule.GetSizeFieldLength());
printf(" _sizeFieldPos=\"%d\"", oModule.GetSizeFieldPos());
printf(" _sizeFieldTag=\"%d\"", oModule.GetSizeFieldTag());
}
printf(">\n");
int nFieldDefnCount = oModule.GetFieldCount();
for( int i = 0; i < nFieldDefnCount; i++ )
{
DDFFieldDefn* poFieldDefn = oModule.GetField(i);
const char* pszDataStructCode = NULL;
switch( poFieldDefn->GetDataStructCode() )
{
case dsc_elementary:
pszDataStructCode = "elementary";
break;
case dsc_vector:
pszDataStructCode = "vector";
break;
case dsc_array:
pszDataStructCode = "array";
break;
case dsc_concatenated:
pszDataStructCode = "concatenated";
break;
default:
pszDataStructCode = "(unknown)";
break;
//.........这里部分代码省略.........
示例2: main
int main(int nArgc, char* papszArgv[])
{
const char *pszFilename = NULL, *pszOutFilename = NULL;
DDFModule oModule;
/* -------------------------------------------------------------------- */
/* Check arguments. */
/* -------------------------------------------------------------------- */
for( int iArg = 1; iArg < nArgc; iArg++ )
{
if( pszFilename == NULL )
pszFilename = papszArgv[iArg];
else if( pszOutFilename == NULL )
pszOutFilename = papszArgv[iArg];
else
{
pszFilename = NULL;
break;
}
}
if( pszFilename == NULL )
{
printf( "Usage: 8211createfromxml filename.xml outfilename\n" );
exit( 1 );
}
CPLXMLNode* poRoot = CPLParseXMLFile( pszFilename );
if( poRoot == NULL )
{
fprintf(stderr, "Cannot parse XML file '%s'\n", pszFilename);
exit( 1 );
}
CPLXMLNode* poXMLDDFModule = CPLSearchXMLNode(poRoot, "=DDFModule");
if( poXMLDDFModule == NULL )
{
fprintf(stderr, "Cannot find DDFModule node in XML file '%s'\n", pszFilename);
exit( 1 );
}
/* Compute the size of the DDFField tag */
CPLXMLNode* psIter = poXMLDDFModule->psChild;
int nSizeFieldTag = 0;
while( psIter != NULL )
{
if( psIter->eType == CXT_Element &&
strcmp(psIter->pszValue, "DDFFieldDefn") == 0 )
{
const char* pszTag = CPLGetXMLValue(psIter, "tag", "");
if( nSizeFieldTag == 0 )
nSizeFieldTag = (int)strlen(pszTag);
else if( nSizeFieldTag != (int)strlen(pszTag) )
{
fprintf(stderr, "All fields have not the same tag size\n");
exit( 1 );
}
}
psIter = psIter->psNext;
}
char chInterchangeLevel = '3';
char chLeaderIden = 'L';
char chCodeExtensionIndicator = 'E';
char chVersionNumber = '1';
char chAppIndicator = ' ';
const char *pszExtendedCharSet = " ! ";
int nSizeFieldLength = 3;
int nSizeFieldPos = 4;
chInterchangeLevel = CPLGetXMLValue(poXMLDDFModule, "_interchangeLevel", CPLSPrintf("%c", chInterchangeLevel))[0];
chLeaderIden = CPLGetXMLValue(poXMLDDFModule, "_leaderIden", CPLSPrintf("%c", chLeaderIden))[0];
chCodeExtensionIndicator = CPLGetXMLValue(poXMLDDFModule, "_inlineCodeExtensionIndicator", CPLSPrintf("%c", chCodeExtensionIndicator))[0];
chVersionNumber = CPLGetXMLValue(poXMLDDFModule, "_versionNumber", CPLSPrintf("%c", chVersionNumber))[0];
chAppIndicator = CPLGetXMLValue(poXMLDDFModule, "_appIndicator", CPLSPrintf("%c", chAppIndicator))[0];
char szExtendedCharSet[4];
snprintf(szExtendedCharSet, sizeof(szExtendedCharSet), "%s", CPLGetXMLValue(poXMLDDFModule, "_extendedCharSet", pszExtendedCharSet));
pszExtendedCharSet = szExtendedCharSet;
nSizeFieldLength = atoi(CPLGetXMLValue(poXMLDDFModule, "_sizeFieldLength", CPLSPrintf("%d", nSizeFieldLength)));
nSizeFieldPos = atoi(CPLGetXMLValue(poXMLDDFModule, "_sizeFieldPos", CPLSPrintf("%d", nSizeFieldPos)));
nSizeFieldTag = atoi(CPLGetXMLValue(poXMLDDFModule, "_sizeFieldTag", CPLSPrintf("%d", nSizeFieldTag)));
oModule.Initialize(chInterchangeLevel,
chLeaderIden,
chCodeExtensionIndicator,
chVersionNumber,
chAppIndicator,
pszExtendedCharSet,
nSizeFieldLength,
nSizeFieldPos,
nSizeFieldTag);
oModule.SetFieldControlLength(atoi(CPLGetXMLValue(poXMLDDFModule, "_fieldControlLength", CPLSPrintf("%d", oModule.GetFieldControlLength()))));
int bCreated = FALSE;
/* Create DDFFieldDefn and DDFRecord elements */
psIter = poXMLDDFModule->psChild;
while( psIter != NULL )
{
if( psIter->eType == CXT_Element &&
//.........这里部分代码省略.........