167 static const size_t nLeaderSize = 24;
184 fpDDF = fopen( pszFilename,
"rb" );
190 <<
"Unable to open DDF file `%s'." 191 << pszFilename << std::endl;
198 char achLeader[nLeaderSize];
200 if( fread( achLeader, 1, nLeaderSize,
fpDDF ) != nLeaderSize )
207 <<
"Leader is short on DDF file `%s'." 208 << pszFilename << std::endl;
216 int i, bValid =
true;
218 for( i = 0; i < (int)nLeaderSize; i++ )
220 if( achLeader[i] < 32 || achLeader[i] > 126 )
224 if( achLeader[5] !=
'1' && achLeader[5] !=
'2' && achLeader[5] !=
'3' )
227 if( achLeader[6] !=
'L' )
229 if( achLeader[8] !=
'1' && achLeader[8] !=
' ' )
273 <<
"File `%s' does not appear to have\n" 274 <<
"a valid ISO 8211 header.\n" 275 << pszFilename << std::endl;
285 memcpy( pachRecord, achLeader, nLeaderSize );
292 <<
"Header record is short on DDF file `%s'." 293 << pszFilename << std::endl;
301 int nFieldEntryWidth, nFDCount = 0;
305 for( i = nLeaderSize; i <
_recLength; i += nFieldEntryWidth )
316 for( i = 0; i < nFDCount; i++ )
319 int nEntryOffset = nLeaderSize + i*nFieldEntryWidth;
320 int nFieldLength, nFieldPos;
333 poFDefn->
Initialize(
this, szTag, nFieldLength,
355 char chCodeExtensionIndicator,
356 char chVersionNumber,
358 const char *pszExtendedCharSet,
359 int nSizeFieldLength,
389 fpDDF = fopen( pszFilename,
"wb+" );
393 <<
"Failed to create file %s, check path and permissions." 394 << pszFilename << std::endl;
425 sprintf( achLeader+0,
"%05d", (
int)
_recLength );
438 fwrite( achLeader, 24, 1,
fpDDF );
446 char achDirEntry[12];
457 fwrite( achDirEntry, 11, 1,
fpDDF );
461 fwrite( &chUT, 1, 1,
fpDDF );
472 fwrite( pachData, nLength, 1,
fpDDF );
496 fprintf( fp,
"DDFModule:\n" );
497 fprintf( fp,
" _recLength = %ld\n",
_recLength );
500 fprintf( fp,
" _inlineCodeExtensionIndicator = %c\n",
548 if( *pszThisName == *pszFieldName
549 && strcmp( pszFieldName+1, pszThisName+1) == 0 )
560 if( s == pszFieldName )
711 fseek(
fpDDF, nOffset, SEEK_SET );
ossimDDFModule()
The constructor.
void RemoveCloneRecord(ossimDDFRecord *)
Information from the DDR defining one field.
const char * GetName()
Fetch a pointer to the field name (tag).
int Initialize(ossimDDFModule *poModule, const char *pszTag, int nSize, const char *pachRecord)
int Create(const char *pszFilename)
int GenerateDDREntry(char **ppachData, int *pnLength)
ossimDDFRecord * poRecord
void Dump(FILE *fp)
Write out module info to debugging file.
~ossimDDFModule()
The destructor.
ossimDDFFieldDefn * FindFieldDefn(const char *)
Fetch the definition of the named field.
ossimDDFRecord ** papoClones
void Dump(FILE *fp)
Write out field definition info to debugging file.
ossimDDFFieldDefn ** papoFieldDefns
void Rewind(long nOffset=-1)
Return to first record.
void AddField(ossimDDFFieldDefn *poNewFDefn)
Add new field definition.
ossimDDFFieldDefn * GetField(int)
Fetch a field definition by index.
void Close()
Close an ISO 8211 file.
int Open(const char *pszFilename, int bFailQuietly=false)
Open a ISO 8211 (DDF) file for reading.
char _inlineCodeExtensionIndicator
ossimDDFRecord * ReadRecord(void)
Read one record from the file.
long ossimDDFScanInt(const char *pszString, int nMaxChars)
Contains instance data from one data record (DR).
OSSIMDLLEXPORT void * ossimCPLRealloc(void *pData, size_t nNewSize)
int Initialize(char chInterchangeLevel='3', char chLeaderIden='L', char chCodeExtensionIndicator='E', char chVersionNumber='1', char chAppIndicator=' ', const char *pszExtendedCharSet=" ! ", int nSizeFieldLength=3, int nSizeFieldPos=4, int nSizeFieldTag=4)
void AddCloneRecord(ossimDDFRecord *)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
#define OSSIM_DDF_FIELD_TERMINATOR