40 static ossimTrace traceDebug(
"ossimDDFFieldDefn:debug");
85 const char *pszFormat )
100 int bDontAddToFormat )
108 if( bDontAddToFormat )
123 char *pszNewFormatControls = (
char *)
124 malloc(nOldLen+3+strlen(poNewSFDefn->
GetFormat()));
127 pszNewFormatControls[nOldLen-1] =
'\0';
128 if( pszNewFormatControls[nOldLen-2] !=
'(' )
129 strcat( pszNewFormatControls,
"," );
131 strcat( pszNewFormatControls, poNewSFDefn->
GetFormat() );
132 strcat( pszNewFormatControls,
")" );
159 const char *pszDescription,
162 const char *pszFormat )
167 this->pszTag = strdup(
pszTag );
175 if( pszFormat != NULL )
178 if( pszDescription != NULL && *pszDescription ==
'*' )
199 if( ppachData == NULL )
202 *ppachData = (
char *) malloc( *pnLength+1 );
205 (*ppachData)[0] =
'0';
207 (*ppachData)[0] =
'1';
209 (*ppachData)[0] =
'2';
211 (*ppachData)[0] =
'3';
214 (*ppachData)[1] =
'0';
216 (*ppachData)[1] =
'1';
218 (*ppachData)[1] =
'2';
220 (*ppachData)[1] =
'3';
222 (*ppachData)[1] =
'4';
224 (*ppachData)[1] =
'5';
226 (*ppachData)[1] =
'6';
228 (*ppachData)[2] =
'0';
229 (*ppachData)[3] =
'0';
230 (*ppachData)[4] =
';';
231 (*ppachData)[5] =
'&';
232 (*ppachData)[6] =
' ';
233 (*ppachData)[7] =
' ';
234 (*ppachData)[8] =
' ';
235 sprintf( *ppachData + 9,
"%s%c%s",
239 sprintf( *ppachData + strlen(*ppachData),
"%c%s",
254 const char * pszTagIn,
256 const char * pachFieldArea )
264 pszTag = strdup( pszTagIn );
269 switch( pachFieldArea[0] )
291 <<
"Unrecognised data_struct_code value %c.\n" 292 <<
"Field %s initialization incorrect.\n" 300 switch( pachFieldArea[1] )
334 <<
"Unrecognised data_type_code value %c.\n" 335 <<
"Field %s initialization incorrect.\n" 336 << pachFieldArea[1] <<
pszTag << std::endl;
348 nFieldEntrySize - iFDOffset,
352 iFDOffset += nCharsConsumed;
356 nFieldEntrySize - iFDOffset,
360 iFDOffset += nCharsConsumed;
364 nFieldEntrySize - iFDOffset,
400 const char *pszValue =
"";
402 fprintf( fp,
" DDFFieldDefn:\n" );
403 fprintf( fp,
" Tag = `%s'\n",
pszTag );
404 fprintf( fp,
" _fieldName = `%s'\n",
_fieldName );
405 fprintf( fp,
" _arrayDescr = `%s'\n",
_arrayDescr );
411 pszValue =
"elementary";
423 pszValue =
"concatenated";
428 pszValue =
"(unknown)";
431 fprintf( fp,
" _data_struct_code = %s\n", pszValue );
436 pszValue =
"char_string";
440 pszValue =
"implicit_point";
444 pszValue =
"explicit_point";
448 pszValue =
"explicit_point_scaled";
452 pszValue =
"char_bit_string";
456 pszValue =
"bit_string";
460 pszValue =
"mixed_data_type";
465 pszValue =
"(unknown)";
469 fprintf( fp,
" _data_type_code = %s\n", pszValue );
484 char **papszSubfieldNames;
487 if( pszSublist[0] ==
'*' )
497 for(
int iSF = 0; iSF < nSFCount; iSF++ )
501 poSFDefn->
SetName( papszSubfieldNames[iSF] );
530 pszSrc[i] !=
'\0' && (nBracket > 0 || pszSrc[i] !=
',');
533 if( pszSrc[i] ==
'(' )
535 else if( pszSrc[i] ==
')' )
539 if( pszSrc[0] ==
'(' )
541 pszReturn = strdup( pszSrc + 1 );
542 pszReturn[i-2] =
'\0';
546 pszReturn = strdup( pszSrc );
561 char *pszDest = (
char *) malloc(nDestMax+1);
569 while( pszSrc[iSrc] !=
'\0' )
575 if( (iSrc == 0 || pszSrc[iSrc-1] ==
',') && pszSrc[iSrc] ==
'(' )
578 char *pszExpandedContents =
ExpandFormat( pszContents );
580 if( (
int) (strlen(pszExpandedContents) + strlen(pszDest) + 1)
583 nDestMax = 2 * ((int)strlen(pszExpandedContents) + (int)strlen(pszDest));
584 pszDest = (
char *) realloc(pszDest,nDestMax+1);
587 strcat( pszDest, pszExpandedContents );
588 iDst = (int)strlen(pszDest);
590 iSrc = iSrc + (int)strlen(pszContents) + 2;
593 free( pszExpandedContents );
597 else if( (iSrc == 0 || pszSrc[iSrc-1] ==
',')
598 && isdigit(pszSrc[iSrc]) )
601 nRepeat = atoi(pszSrc+iSrc);
604 for( pszNext = pszSrc+iSrc; isdigit(*pszNext); pszNext++ )
608 char *pszExpandedContents =
ExpandFormat( pszContents );
610 for(
int i = 0; i < nRepeat; i++ )
612 if( (
int) (strlen(pszExpandedContents) + strlen(pszDest) + 1)
616 2 * ((int)strlen(pszExpandedContents) + (int)strlen(pszDest));
617 pszDest = (
char *) realloc(pszDest,nDestMax+1);
620 strcat( pszDest, pszExpandedContents );
622 strcat( pszDest,
"," );
625 iDst = (int)strlen(pszDest);
627 if( pszNext[0] ==
'(' )
628 iSrc = iSrc + (int)strlen(pszContents) + 2;
630 iSrc = iSrc + (int)strlen(pszContents);
633 free( pszExpandedContents );
637 if( iDst+1 >= nDestMax )
640 pszDest = (
char *) realloc(pszDest,nDestMax);
643 pszDest[iDst++] = pszSrc[iSrc++];
644 pszDest[iDst] =
'\0';
663 char **papszFormatItems;
673 <<
"Format controls for `%s' field missing brackets:%s\n" 691 free( pszFormatList );
698 for( iFormatItem = 0;
699 papszFormatItems[iFormatItem] != NULL;
702 const char *pszPastPrefix;
704 pszPastPrefix = papszFormatItems[iFormatItem];
705 while( *pszPastPrefix >=
'0' && *pszPastPrefix <=
'9' )
717 <<
"Got more formats than subfields for field `%s'.\n" 734 <<
"Got less formats than subfields for field `%s',\n" 777 if( s == pszMnemonic )
834 nTotalSize += nSubfieldSize;
840 char *pachData = (
char *) malloc( nTotalSize );
843 *pnSize = nTotalSize;
854 pachData + nOffset, nTotalSize - nOffset, &nSubfieldSize ) )
861 nOffset += nSubfieldSize;
const char * GetName()
Get pointer to subfield name.
static char * ExtractSubstring(const char *)
char * GetDefaultValue(int *pnSize)
Return default data for field instance.
ossimDDFModule * poModule
int Initialize(ossimDDFModule *poModule, const char *pszTag, int nSize, const char *pachRecord)
char * ossimDDFFetchVariable(const char *pszString, int nMaxChars, int nDelimChar1, int nDelimChar2, int *pnConsumedChars)
ossimDDFSubfieldDefn ** papoSubfields
OSSIMDLLEXPORT int ossimCSLCount(char **papszStrList)
int GetFieldControlLength()
static char * ExpandFormat(const char *)
int GenerateDDREntry(char **ppachData, int *pnLength)
OSSIMDLLEXPORT void ossimCSLDestroy(char **papszStrList)
void AddSubfield(ossimDDFSubfieldDefn *poNewSFDefn, int bDontAddToFormat=false)
void Dump(FILE *fp)
Write out field definition info to debugging file.
ossimDDFSubfieldDefn * FindSubfieldDefn(const char *)
Find a subfield definition by it's mnemonic tag.
void SetName(const char *pszName)
DDF_data_type_code _data_type_code
DDF_data_struct_code _data_struct_code
The primary class for reading ISO 8211 files.
OSSIMDLLEXPORT char ** ossimCSLTokenizeStringComplex(const char *pszString, const char *pszDelimiter, int bHonourStrings, int bAllowEmptyTokens)
#define OSSIM_DDF_UNIT_TERMINATOR
int Create(const char *pszTag, const char *pszFieldName, const char *pszDescription, DDF_data_struct_code eDataStructCode, DDF_data_type_code eDataTypeCode, const char *pszFormat=NULL)
int GetWidth()
Get the subfield width (zero for variable).
const char * GetFormat()
Get pointer to subfield format string.
int SetFormat(const char *pszFormat)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossimDDFSubfieldDefn * GetSubfield(int i)
Fetch a subfield by index.
Information from the DDR record describing one subfield of a DDFFieldDefn.
#define OSSIM_DDF_FIELD_TERMINATOR