OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ossimDDFFieldDefn Class Reference

Information from the DDR defining one field. More...

#include <ossimIso8211.h>

Public Member Functions

 ossimDDFFieldDefn ()
 
 ~ossimDDFFieldDefn ()
 
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)
 
void AddSubfield (ossimDDFSubfieldDefn *poNewSFDefn, int bDontAddToFormat=false)
 
void AddSubfield (const char *pszName, const char *pszFormat)
 
int GenerateDDREntry (char **ppachData, int *pnLength)
 
int Initialize (ossimDDFModule *poModule, const char *pszTag, int nSize, const char *pachRecord)
 
void Dump (FILE *fp)
 Write out field definition info to debugging file. More...
 
const char * GetName ()
 Fetch a pointer to the field name (tag). More...
 
const char * GetDescription ()
 Fetch a longer descriptio of this field. More...
 
int GetSubfieldCount ()
 Get the number of subfields. More...
 
ossimDDFSubfieldDefnGetSubfield (int i)
 Fetch a subfield by index. More...
 
ossimDDFSubfieldDefnFindSubfieldDefn (const char *)
 Find a subfield definition by it's mnemonic tag. More...
 
int GetFixedWidth ()
 Get the width of this field. More...
 
int IsRepeating ()
 Fetch repeating flag. More...
 
void SetRepeatingFlag (int n)
 this is just for an S-57 hack for swedish data More...
 
char * GetDefaultValue (int *pnSize)
 Return default data for field instance. More...
 

Static Public Member Functions

static char * ExpandFormat (const char *)
 

Private Member Functions

int BuildSubfields ()
 
int ApplyFormats ()
 

Static Private Member Functions

static char * ExtractSubstring (const char *)
 

Private Attributes

ossimDDFModulepoModule
 
char * pszTag
 
char * _fieldName
 
char * _arrayDescr
 
char * _formatControls
 
int bRepeatingSubfields
 
int nFixedWidth
 
DDF_data_struct_code _data_struct_code
 
DDF_data_type_code _data_type_code
 
int nSubfieldCount
 
ossimDDFSubfieldDefn ** papoSubfields
 

Detailed Description

Information from the DDR defining one field.

Note that just because a field is defined for a DDFModule doesn't mean that it actually occurs on any records in the module. DDFFieldDefns are normally just significant as containers of the DDFSubfieldDefns.

Definition at line 179 of file ossimIso8211.h.

Constructor & Destructor Documentation

◆ ossimDDFFieldDefn()

ossimDDFFieldDefn::ossimDDFFieldDefn ( )

Definition at line 47 of file ossimDdffielddefn.cpp.

References _arrayDescr, _fieldName, _formatControls, bRepeatingSubfields, nFixedWidth, nSubfieldCount, papoSubfields, poModule, and pszTag.

49 {
50  poModule = NULL;
51  pszTag = NULL;
52  _fieldName = NULL;
53  _arrayDescr = NULL;
54  _formatControls = NULL;
55  nSubfieldCount = 0;
56  papoSubfields = NULL;
57  bRepeatingSubfields = false;
58  nFixedWidth = 0;
59 }
ossimDDFModule * poModule
Definition: ossimIso8211.h:243
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261

◆ ~ossimDDFFieldDefn()

ossimDDFFieldDefn::~ossimDDFFieldDefn ( )

Definition at line 65 of file ossimDdffielddefn.cpp.

References _arrayDescr, _fieldName, _formatControls, nSubfieldCount, papoSubfields, and pszTag.

67 {
68  int i;
69 
70  free( pszTag );
71  free( _fieldName );
72  free( _arrayDescr );
73  free( _formatControls );
74 
75  for( i = 0; i < nSubfieldCount; i++ )
76  delete papoSubfields[i];
77  free( papoSubfields );
78 }
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261

Member Function Documentation

◆ AddSubfield() [1/2]

void ossimDDFFieldDefn::AddSubfield ( ossimDDFSubfieldDefn poNewSFDefn,
int  bDontAddToFormat = false 
)

Definition at line 99 of file ossimDdffielddefn.cpp.

References _arrayDescr, _formatControls, ossimDDFSubfieldDefn::GetFormat(), ossimDDFSubfieldDefn::GetName(), nSubfieldCount, and papoSubfields.

Referenced by AddSubfield(), and BuildSubfields().

102 {
103  nSubfieldCount++;
105  realloc( papoSubfields, sizeof(void*) * nSubfieldCount );
106  papoSubfields[nSubfieldCount-1] = poNewSFDefn;
107 
108  if( bDontAddToFormat )
109  return;
110 
111 /* -------------------------------------------------------------------- */
112 /* Add this format to the format list. We don't bother */
113 /* aggregating formats here. */
114 /* -------------------------------------------------------------------- */
115  if( _formatControls == NULL || strlen(_formatControls) == 0 )
116  {
117  free( _formatControls );
118  _formatControls = strdup( "()" );
119  }
120 
121  int nOldLen = (int)strlen(_formatControls);
122 
123  char *pszNewFormatControls = (char *)
124  malloc(nOldLen+3+strlen(poNewSFDefn->GetFormat()));
125 
126  strcpy( pszNewFormatControls, _formatControls );
127  pszNewFormatControls[nOldLen-1] = '\0';
128  if( pszNewFormatControls[nOldLen-2] != '(' )
129  strcat( pszNewFormatControls, "," );
130 
131  strcat( pszNewFormatControls, poNewSFDefn->GetFormat() );
132  strcat( pszNewFormatControls, ")" );
133 
134  free( _formatControls );
135  _formatControls = pszNewFormatControls;
136 
137 /* -------------------------------------------------------------------- */
138 /* Add the subfield name to the list. */
139 /* -------------------------------------------------------------------- */
140  if( _arrayDescr == NULL )
141  _arrayDescr = strdup("");
142 
143  _arrayDescr = (char *)
144  realloc(_arrayDescr,
145  strlen(_arrayDescr)+strlen(poNewSFDefn->GetName())+2);
146  if( strlen(_arrayDescr) > 0 )
147  strcat( _arrayDescr, "!" );
148  strcat( _arrayDescr, poNewSFDefn->GetName() );
149 }
const char * GetName()
Get pointer to subfield name.
Definition: ossimIso8211.h:288
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261
const char * GetFormat()
Get pointer to subfield format string.
Definition: ossimIso8211.h:291
Information from the DDR record describing one subfield of a DDFFieldDefn.
Definition: ossimIso8211.h:278

◆ AddSubfield() [2/2]

void ossimDDFFieldDefn::AddSubfield ( const char *  pszName,
const char *  pszFormat 
)

Definition at line 84 of file ossimDdffielddefn.cpp.

References AddSubfield(), ossimDDFSubfieldDefn::SetFormat(), and ossimDDFSubfieldDefn::SetName().

87 {
89 
90  poSFDefn->SetName( pszName );
91  poSFDefn->SetFormat( pszFormat );
92  AddSubfield( poSFDefn );
93 }
void AddSubfield(ossimDDFSubfieldDefn *poNewSFDefn, int bDontAddToFormat=false)
void SetName(const char *pszName)
int SetFormat(const char *pszFormat)
Information from the DDR record describing one subfield of a DDFFieldDefn.
Definition: ossimIso8211.h:278

◆ ApplyFormats()

int ossimDDFFieldDefn::ApplyFormats ( )
private

Definition at line 659 of file ossimDdffielddefn.cpp.

References _formatControls, ExpandFormat(), ossimDDFSubfieldDefn::GetWidth(), nFixedWidth, nSubfieldCount, ossimCSLDestroy(), ossimCSLTokenizeStringComplex(), ossimNotify(), ossimNotifyLevel_DEBUG, ossimNotifyLevel_WARN, papoSubfields, and pszTag.

661 {
662  char *pszFormatList;
663  char **papszFormatItems;
664 
665 /* -------------------------------------------------------------------- */
666 /* Verify that the format string is contained within brackets. */
667 /* -------------------------------------------------------------------- */
668  if( strlen(_formatControls) < 2
669  || _formatControls[0] != '('
670  || _formatControls[strlen(_formatControls)-1] != ')' )
671  {
673  << "Format controls for `%s' field missing brackets:%s\n"
674  << pszTag << _formatControls << std::endl;
675 
676  return false;
677  }
678 
679 /* -------------------------------------------------------------------- */
680 /* Duplicate the string, and strip off the brackets. */
681 /* -------------------------------------------------------------------- */
682 
683  pszFormatList = ExpandFormat( _formatControls );
684 
685 /* -------------------------------------------------------------------- */
686 /* Tokenize based on commas. */
687 /* -------------------------------------------------------------------- */
688  papszFormatItems =
689  ossimCSLTokenizeStringComplex(pszFormatList, ",", false, false );
690 
691  free( pszFormatList );
692 
693 /* -------------------------------------------------------------------- */
694 /* Apply the format items to subfields. */
695 /* -------------------------------------------------------------------- */
696  int iFormatItem;
697 
698  for( iFormatItem = 0;
699  papszFormatItems[iFormatItem] != NULL;
700  iFormatItem++ )
701  {
702  const char *pszPastPrefix;
703 
704  pszPastPrefix = papszFormatItems[iFormatItem];
705  while( *pszPastPrefix >= '0' && *pszPastPrefix <= '9' )
706  pszPastPrefix++;
707 
709  // Did we get too many formats for the subfields created
710  // by names? This may be legal by the 8211 specification, but
711  // isn't encountered in any formats we care about so we just
712  // blow.
713 
714  if( iFormatItem >= nSubfieldCount )
715  {
717  << "Got more formats than subfields for field `%s'.\n"
718  << pszTag << std::endl;
719  break;
720  }
721 
722  if( !papoSubfields[iFormatItem]->SetFormat(pszPastPrefix) )
723  return false;
724  }
725 
726 /* -------------------------------------------------------------------- */
727 /* Verify that we got enough formats, cleanup and return. */
728 /* -------------------------------------------------------------------- */
729  ossimCSLDestroy( papszFormatItems );
730 
731  if( iFormatItem < nSubfieldCount )
732  {
734  << "Got less formats than subfields for field `%s',\n"
735  << pszTag << std::endl;
736  return false;
737  }
738 
739 /* -------------------------------------------------------------------- */
740 /* If all the fields are fixed width, then we are fixed width */
741 /* too. This is important for repeating fields. */
742 /* -------------------------------------------------------------------- */
743  nFixedWidth = 0;
744  for( int i = 0; i < nSubfieldCount; i++ )
745  {
746  if( papoSubfields[i]->GetWidth() == 0 )
747  {
748  nFixedWidth = 0;
749  break;
750  }
751  else
753  }
754 
755  return true;
756 }
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261
static char * ExpandFormat(const char *)
OSSIMDLLEXPORT void ossimCSLDestroy(char **papszStrList)
OSSIMDLLEXPORT char ** ossimCSLTokenizeStringComplex(const char *pszString, const char *pszDelimiter, int bHonourStrings, int bAllowEmptyTokens)
int GetWidth()
Get the subfield width (zero for variable).
Definition: ossimIso8211.h:324
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ BuildSubfields()

int ossimDDFFieldDefn::BuildSubfields ( )
private

Definition at line 481 of file ossimDdffielddefn.cpp.

References _arrayDescr, AddSubfield(), bRepeatingSubfields, ossimCSLCount(), ossimCSLDestroy(), ossimCSLTokenizeStringComplex(), and ossimDDFSubfieldDefn::SetName().

483 {
484  char **papszSubfieldNames;
485  const char *pszSublist = _arrayDescr;
486 
487  if( pszSublist[0] == '*' )
488  {
489  bRepeatingSubfields = true;
490  pszSublist++;
491  }
492 
493  papszSubfieldNames = ossimCSLTokenizeStringComplex( pszSublist, "!",
494  false, false );
495 
496  int nSFCount = ossimCSLCount( papszSubfieldNames );
497  for( int iSF = 0; iSF < nSFCount; iSF++ )
498  {
500 
501  poSFDefn->SetName( papszSubfieldNames[iSF] );
502  AddSubfield( poSFDefn, true );
503  }
504 
505  ossimCSLDestroy( papszSubfieldNames );
506 
507  return true;
508 }
OSSIMDLLEXPORT int ossimCSLCount(char **papszStrList)
OSSIMDLLEXPORT void ossimCSLDestroy(char **papszStrList)
void AddSubfield(ossimDDFSubfieldDefn *poNewSFDefn, int bDontAddToFormat=false)
void SetName(const char *pszName)
OSSIMDLLEXPORT char ** ossimCSLTokenizeStringComplex(const char *pszString, const char *pszDelimiter, int bHonourStrings, int bAllowEmptyTokens)
Information from the DDR record describing one subfield of a DDFFieldDefn.
Definition: ossimIso8211.h:278

◆ Create()

int ossimDDFFieldDefn::Create ( const char *  pszTag,
const char *  pszFieldName,
const char *  pszDescription,
DDF_data_struct_code  eDataStructCode,
DDF_data_type_code  eDataTypeCode,
const char *  pszFormat = NULL 
)

Definition at line 158 of file ossimDdffielddefn.cpp.

References _arrayDescr, _data_struct_code, _data_type_code, _fieldName, _formatControls, bRepeatingSubfields, poModule, and pszTag.

164 {
165  // assert( this->pszTag == NULL );
166  poModule = NULL;
167  this->pszTag = strdup( pszTag );
168  _fieldName = strdup( pszFieldName );
169  _arrayDescr = strdup( pszDescription );
170  _formatControls = strdup( "" );
171 
172  _data_struct_code = eDataStructCode;
173  _data_type_code = eDataTypeCode;
174 
175  if( pszFormat != NULL )
176  _formatControls = strdup( pszFormat );
177 
178  if( pszDescription != NULL && *pszDescription == '*' )
179  bRepeatingSubfields = true;
180 
181  return true;
182 }
ossimDDFModule * poModule
Definition: ossimIso8211.h:243
DDF_data_type_code _data_type_code
Definition: ossimIso8211.h:258
DDF_data_struct_code _data_struct_code
Definition: ossimIso8211.h:256

◆ Dump()

void ossimDDFFieldDefn::Dump ( FILE *  fp)

Write out field definition info to debugging file.

A variety of information about this field definition, and all it's subfields is written to the give debugging file handle.

Parameters
fpThe standard io file handle to write to. ie. stderr

Definition at line 397 of file ossimDdffielddefn.cpp.

References _arrayDescr, _data_struct_code, _data_type_code, _fieldName, _formatControls, dsc_array, dsc_concatenated, dsc_elementary, dsc_vector, dtc_bit_string, dtc_char_bit_string, dtc_char_string, dtc_explicit_point, dtc_explicit_point_scaled, dtc_implicit_point, dtc_mixed_data_type, nSubfieldCount, papoSubfields, and pszTag.

Referenced by ossimDDFModule::Dump().

399 {
400  const char *pszValue = "";
401 
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 );
406  fprintf( fp, " _formatControls = `%s'\n", _formatControls );
407 
408  switch( _data_struct_code )
409  {
410  case dsc_elementary:
411  pszValue = "elementary";
412  break;
413 
414  case dsc_vector:
415  pszValue = "vector";
416  break;
417 
418  case dsc_array:
419  pszValue = "array";
420  break;
421 
422  case dsc_concatenated:
423  pszValue = "concatenated";
424  break;
425 
426  default:
427  // assert( false );
428  pszValue = "(unknown)";
429  }
430 
431  fprintf( fp, " _data_struct_code = %s\n", pszValue );
432 
433  switch( _data_type_code )
434  {
435  case dtc_char_string:
436  pszValue = "char_string";
437  break;
438 
439  case dtc_implicit_point:
440  pszValue = "implicit_point";
441  break;
442 
443  case dtc_explicit_point:
444  pszValue = "explicit_point";
445  break;
446 
448  pszValue = "explicit_point_scaled";
449  break;
450 
451  case dtc_char_bit_string:
452  pszValue = "char_bit_string";
453  break;
454 
455  case dtc_bit_string:
456  pszValue = "bit_string";
457  break;
458 
459  case dtc_mixed_data_type:
460  pszValue = "mixed_data_type";
461  break;
462 
463  default:
464  // assert( false );
465  pszValue = "(unknown)";
466  break;
467  }
468 
469  fprintf( fp, " _data_type_code = %s\n", pszValue );
470 
471  for( int i = 0; i < nSubfieldCount; i++ )
472  papoSubfields[i]->Dump( fp );
473 }
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261
void Dump(FILE *fp)
Write out field definition info to debugging file.
DDF_data_type_code _data_type_code
Definition: ossimIso8211.h:258
DDF_data_struct_code _data_struct_code
Definition: ossimIso8211.h:256

◆ ExpandFormat()

char * ossimDDFFieldDefn::ExpandFormat ( const char *  pszSrc)
static

Definition at line 557 of file ossimDdffielddefn.cpp.

References ExtractSubstring().

Referenced by ApplyFormats().

559 {
560  int nDestMax = 32;
561  char *pszDest = (char *) malloc(nDestMax+1);
562  int iSrc, iDst;
563  int nRepeat = 0;
564 
565  iSrc = 0;
566  iDst = 0;
567  pszDest[0] = '\0';
568 
569  while( pszSrc[iSrc] != '\0' )
570  {
571  /* This is presumably an extra level of brackets around some
572  binary stuff related to rescaning which we don't care to do
573  (see 6.4.3.3 of the standard. We just strip off the extra
574  layer of brackets */
575  if( (iSrc == 0 || pszSrc[iSrc-1] == ',') && pszSrc[iSrc] == '(' )
576  {
577  char *pszContents = ExtractSubstring( pszSrc+iSrc );
578  char *pszExpandedContents = ExpandFormat( pszContents );
579 
580  if( (int) (strlen(pszExpandedContents) + strlen(pszDest) + 1)
581  > nDestMax )
582  {
583  nDestMax = 2 * ((int)strlen(pszExpandedContents) + (int)strlen(pszDest));
584  pszDest = (char *) realloc(pszDest,nDestMax+1);
585  }
586 
587  strcat( pszDest, pszExpandedContents );
588  iDst = (int)strlen(pszDest);
589 
590  iSrc = iSrc + (int)strlen(pszContents) + 2;
591 
592  free( pszContents );
593  free( pszExpandedContents );
594  }
595 
596  /* this is a repeated subclause */
597  else if( (iSrc == 0 || pszSrc[iSrc-1] == ',')
598  && isdigit(pszSrc[iSrc]) )
599  {
600  const char *pszNext;
601  nRepeat = atoi(pszSrc+iSrc);
602 
603  // skip over repeat count.
604  for( pszNext = pszSrc+iSrc; isdigit(*pszNext); pszNext++ )
605  iSrc++;
606 
607  char *pszContents = ExtractSubstring( pszNext );
608  char *pszExpandedContents = ExpandFormat( pszContents );
609 
610  for( int i = 0; i < nRepeat; i++ )
611  {
612  if( (int) (strlen(pszExpandedContents) + strlen(pszDest) + 1)
613  > nDestMax )
614  {
615  nDestMax =
616  2 * ((int)strlen(pszExpandedContents) + (int)strlen(pszDest));
617  pszDest = (char *) realloc(pszDest,nDestMax+1);
618  }
619 
620  strcat( pszDest, pszExpandedContents );
621  if( i < nRepeat-1 )
622  strcat( pszDest, "," );
623  }
624 
625  iDst = (int)strlen(pszDest);
626 
627  if( pszNext[0] == '(' )
628  iSrc = iSrc + (int)strlen(pszContents) + 2;
629  else
630  iSrc = iSrc + (int)strlen(pszContents);
631 
632  free( pszContents );
633  free( pszExpandedContents );
634  }
635  else
636  {
637  if( iDst+1 >= nDestMax )
638  {
639  nDestMax = 2 * iDst;
640  pszDest = (char *) realloc(pszDest,nDestMax);
641  }
642 
643  pszDest[iDst++] = pszSrc[iSrc++];
644  pszDest[iDst] = '\0';
645  }
646  }
647 
648  return pszDest;
649 }
static char * ExtractSubstring(const char *)
static char * ExpandFormat(const char *)

◆ ExtractSubstring()

char * ossimDDFFieldDefn::ExtractSubstring ( const char *  pszSrc)
staticprivate

Definition at line 523 of file ossimDdffielddefn.cpp.

Referenced by ExpandFormat().

525 {
526  int nBracket=0, i;
527  char *pszReturn;
528 
529  for( i = 0;
530  pszSrc[i] != '\0' && (nBracket > 0 || pszSrc[i] != ',');
531  i++ )
532  {
533  if( pszSrc[i] == '(' )
534  nBracket++;
535  else if( pszSrc[i] == ')' )
536  nBracket--;
537  }
538 
539  if( pszSrc[0] == '(' )
540  {
541  pszReturn = strdup( pszSrc + 1 );
542  pszReturn[i-2] = '\0';
543  }
544  else
545  {
546  pszReturn = strdup( pszSrc );
547  pszReturn[i] = '\0';
548  }
549 
550  return pszReturn;
551 }

◆ FindSubfieldDefn()

ossimDDFSubfieldDefn * ossimDDFFieldDefn::FindSubfieldDefn ( const char *  pszMnemonic)

Find a subfield definition by it's mnemonic tag.

Parameters
pszMnemonicThe name of the field.
Returns
The subfield pointer, or NULL if there isn't any such subfield.

Definition at line 771 of file ossimDdffielddefn.cpp.

References ossimDDFSubfieldDefn::GetName(), nSubfieldCount, and papoSubfields.

Referenced by ossimDDFRecord::GetFloatSubfield(), ossimDDFRecord::GetIntSubfield(), ossimDDFRecord::GetStringSubfield(), ossimAdrgHeader::parse(), ossimDDFRecord::SetFloatSubfield(), ossimDDFRecord::SetIntSubfield(), and ossimDDFRecord::SetStringSubfield().

773 {
774  for( int i = 0; i < nSubfieldCount; i++ )
775  {
777  if( s == pszMnemonic )
778  return papoSubfields[i];
779  }
780 
781  return NULL;
782 }
const char * GetName()
Get pointer to subfield name.
Definition: ossimIso8211.h:288
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261

◆ GenerateDDREntry()

int ossimDDFFieldDefn::GenerateDDREntry ( char **  ppachData,
int *  pnLength 
)

Definition at line 188 of file ossimDdffielddefn.cpp.

References _arrayDescr, _data_struct_code, _data_type_code, _fieldName, _formatControls, dsc_array, dsc_concatenated, dsc_elementary, dsc_vector, dtc_bit_string, dtc_char_bit_string, dtc_char_string, dtc_explicit_point, dtc_explicit_point_scaled, dtc_implicit_point, dtc_mixed_data_type, OSSIM_DDF_FIELD_TERMINATOR, and OSSIM_DDF_UNIT_TERMINATOR.

Referenced by ossimDDFModule::Create().

191 {
192  *pnLength = 9 + (int)strlen(_fieldName) + 1
193  + (int)strlen(_arrayDescr) + 1
194  + (int)strlen(_formatControls) + 1;
195 
196  if( strlen(_formatControls) == 0 )
197  *pnLength -= 1;
198 
199  if( ppachData == NULL )
200  return true;
201 
202  *ppachData = (char *) malloc( *pnLength+1 );
203 
205  (*ppachData)[0] = '0';
206  else if( _data_struct_code == dsc_vector )
207  (*ppachData)[0] = '1';
208  else if( _data_struct_code == dsc_array )
209  (*ppachData)[0] = '2';
210  else if( _data_struct_code == dsc_concatenated )
211  (*ppachData)[0] = '3';
212 
214  (*ppachData)[1] = '0';
215  else if( _data_type_code == dtc_implicit_point )
216  (*ppachData)[1] = '1';
217  else if( _data_type_code == dtc_explicit_point )
218  (*ppachData)[1] = '2';
220  (*ppachData)[1] = '3';
222  (*ppachData)[1] = '4';
223  else if( _data_type_code == dtc_bit_string )
224  (*ppachData)[1] = '5';
226  (*ppachData)[1] = '6';
227 
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",
237 
238  if( strlen(_formatControls) > 0 )
239  sprintf( *ppachData + strlen(*ppachData), "%c%s",
241  sprintf( *ppachData + strlen(*ppachData), "%c", OSSIM_DDF_FIELD_TERMINATOR );
242 
243  return true;
244 }
DDF_data_type_code _data_type_code
Definition: ossimIso8211.h:258
DDF_data_struct_code _data_struct_code
Definition: ossimIso8211.h:256
#define OSSIM_DDF_UNIT_TERMINATOR
Definition: ossimIso8211.h:65
#define OSSIM_DDF_FIELD_TERMINATOR
Definition: ossimIso8211.h:62

◆ GetDefaultValue()

char * ossimDDFFieldDefn::GetDefaultValue ( int *  pnSize)

Return default data for field instance.

Definition at line 818 of file ossimDdffielddefn.cpp.

References nSubfieldCount, and papoSubfields.

Referenced by ossimDDFRecord::CreateDefaultFieldInstance().

820 {
821 /* -------------------------------------------------------------------- */
822 /* Loop once collecting the sum of the subfield lengths. */
823 /* -------------------------------------------------------------------- */
824  int iSubfield;
825  int nTotalSize = 0;
826 
827  for( iSubfield = 0; iSubfield < nSubfieldCount; iSubfield++ )
828  {
829  int nSubfieldSize;
830 
831  if( !papoSubfields[iSubfield]->GetDefaultValue( NULL, 0,
832  &nSubfieldSize ) )
833  return NULL;
834  nTotalSize += nSubfieldSize;
835  }
836 
837 /* -------------------------------------------------------------------- */
838 /* Allocate buffer. */
839 /* -------------------------------------------------------------------- */
840  char *pachData = (char *) malloc( nTotalSize );
841 
842  if( pnSize != NULL )
843  *pnSize = nTotalSize;
844 
845 /* -------------------------------------------------------------------- */
846 /* Loop again, collecting actual default values. */
847 /* -------------------------------------------------------------------- */
848  int nOffset = 0;
849  for( iSubfield = 0; iSubfield < nSubfieldCount; iSubfield++ )
850  {
851  int nSubfieldSize;
852 
853  if( !papoSubfields[iSubfield]->GetDefaultValue(
854  pachData + nOffset, nTotalSize - nOffset, &nSubfieldSize ) )
855  {
856  // assert( false );
857  free( pachData );
858  return NULL;
859  }
860 
861  nOffset += nSubfieldSize;
862  }
863 
864  // assert( nOffset == nTotalSize );
865 
866  return pachData;
867 }
char * GetDefaultValue(int *pnSize)
Return default data for field instance.
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261

◆ GetDescription()

const char* ossimDDFFieldDefn::GetDescription ( )
inline

Fetch a longer descriptio of this field.

Returns
this is an internal copy and shouldn't be freed.

Definition at line 208 of file ossimIso8211.h.

References _fieldName.

208 { return _fieldName; }

◆ GetFixedWidth()

int ossimDDFFieldDefn::GetFixedWidth ( )
inline

Get the width of this field.

This function isn't normally used by applications.

Returns
The width of the field in bytes, or zero if the field is not apparently of a fixed width.

Definition at line 223 of file ossimIso8211.h.

References nFixedWidth.

Referenced by ossimDDFField::GetRepeatCount(), and ossimDDFField::GetSubfieldData().

223 { return nFixedWidth; }

◆ GetName()

const char* ossimDDFFieldDefn::GetName ( )
inline

Fetch a pointer to the field name (tag).

Returns
this is an internal copy and shouldn't be freed.

Definition at line 203 of file ossimIso8211.h.

References pszTag.

Referenced by ossimDDFRecord::CloneOn(), ossimDDFField::Dump(), ossimDDFRecord::FindField(), ossimDDFModule::FindFieldDefn(), and ossimDDFRecord::ResetDirectory().

203 { return pszTag; }

◆ GetSubfield()

ossimDDFSubfieldDefn * ossimDDFFieldDefn::GetSubfield ( int  i)

Fetch a subfield by index.

Parameters
iThe index subfield index. (Between 0 and GetSubfieldCount()-1)
Returns
The subfield pointer, or NULL if the index is out of range.

Definition at line 798 of file ossimDdffielddefn.cpp.

References nSubfieldCount, and papoSubfields.

Referenced by ossimDDFField::Dump(), ossimDDFField::GetInstanceData(), ossimDDFField::GetRepeatCount(), and ossimDDFField::GetSubfieldData().

800 {
801  if( i < 0 || i >= nSubfieldCount )
802  {
803  // assert( false );
804  return NULL;
805  }
806 
807  return papoSubfields[i];
808 }
ossimDDFSubfieldDefn ** papoSubfields
Definition: ossimIso8211.h:261

◆ GetSubfieldCount()

int ossimDDFFieldDefn::GetSubfieldCount ( )
inline

Get the number of subfields.

Definition at line 211 of file ossimIso8211.h.

References nSubfieldCount.

Referenced by ossimDDFField::Dump(), ossimDDFField::GetInstanceData(), ossimDDFField::GetRepeatCount(), and ossimDDFField::GetSubfieldData().

211 { return nSubfieldCount; }

◆ Initialize()

int ossimDDFFieldDefn::Initialize ( ossimDDFModule poModule,
const char *  pszTag,
int  nSize,
const char *  pachRecord 
)

Definition at line 253 of file ossimDdffielddefn.cpp.

References _data_struct_code, dsc_array, dsc_concatenated, dsc_elementary, dsc_vector, ossimDDFModule::GetFieldControlLength(), poModule, and pszTag.

258 {
259  int iFDOffset = poModuleIn->GetFieldControlLength();
260  int nCharsConsumed;
261 
262  poModule = poModuleIn;
263 
264  pszTag = strdup( pszTagIn );
265 
266 /* -------------------------------------------------------------------- */
267 /* Set the data struct and type codes. */
268 /* -------------------------------------------------------------------- */
269  switch( pachFieldArea[0] )
270  {
271  case '0':
273  break;
274 
275  case '1':
277  break;
278 
279  case '2':
281  break;
282 
283  case '3':
285  break;
286 
287  default:
288  if (traceDebug())
289  {
291  << "Unrecognised data_struct_code value %c.\n"
292  << "Field %s initialization incorrect.\n"
293  << pachFieldArea[0]
294  << pszTag
295  << std::endl;
296  }
298  }
299 
300  switch( pachFieldArea[1] )
301  {
302  case '0':
304  break;
305 
306  case '1':
308  break;
309 
310  case '2':
312  break;
313 
314  case '3':
316  break;
317 
318  case '4':
320  break;
321 
322  case '5':
324  break;
325 
326  case '6':
328  break;
329 
330  default:
331  if (traceDebug())
332  {
334  << "Unrecognised data_type_code value %c.\n"
335  << "Field %s initialization incorrect.\n"
336  << pachFieldArea[1] << pszTag << std::endl;
337  }
339  }
340 
341 /* -------------------------------------------------------------------- */
342 /* Capture the field name, description (sub field names), and */
343 /* format statements. */
344 /* -------------------------------------------------------------------- */
345 
346  _fieldName =
347  ossimDDFFetchVariable( pachFieldArea + iFDOffset,
348  nFieldEntrySize - iFDOffset,
351  &nCharsConsumed );
352  iFDOffset += nCharsConsumed;
353 
354  _arrayDescr =
355  ossimDDFFetchVariable( pachFieldArea + iFDOffset,
356  nFieldEntrySize - iFDOffset,
359  &nCharsConsumed );
360  iFDOffset += nCharsConsumed;
361 
363  ossimDDFFetchVariable( pachFieldArea + iFDOffset,
364  nFieldEntrySize - iFDOffset,
367  &nCharsConsumed );
368 
369 /* -------------------------------------------------------------------- */
370 /* Parse the subfield info. */
371 /* -------------------------------------------------------------------- */
373  {
374  if( !BuildSubfields() )
375  return false;
376 
377  if( !ApplyFormats() )
378  return false;
379  }
380 
381  return true;
382 }
ossimDDFModule * poModule
Definition: ossimIso8211.h:243
char * ossimDDFFetchVariable(const char *pszString, int nMaxChars, int nDelimChar1, int nDelimChar2, int *pnConsumedChars)
DDF_data_type_code _data_type_code
Definition: ossimIso8211.h:258
DDF_data_struct_code _data_struct_code
Definition: ossimIso8211.h:256
#define OSSIM_DDF_UNIT_TERMINATOR
Definition: ossimIso8211.h:65
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
#define OSSIM_DDF_FIELD_TERMINATOR
Definition: ossimIso8211.h:62

◆ IsRepeating()

int ossimDDFFieldDefn::IsRepeating ( )
inline

Fetch repeating flag.

See also
DDFField::GetRepeatCount()
Returns
TRUE if the field is marked as repeating.

Definition at line 230 of file ossimIso8211.h.

References bRepeatingSubfields.

Referenced by ossimDDFField::GetRepeatCount(), and ossimDDFRecord::SetFieldRaw().

230 { return bRepeatingSubfields; }

◆ SetRepeatingFlag()

void ossimDDFFieldDefn::SetRepeatingFlag ( int  n)
inline

this is just for an S-57 hack for swedish data

Definition at line 235 of file ossimIso8211.h.

References bRepeatingSubfields, and n.

235 { bRepeatingSubfields = n; }
os2<< "> n<< " > nendobj n

Member Data Documentation

◆ _arrayDescr

char* ossimDDFFieldDefn::_arrayDescr
private

◆ _data_struct_code

DDF_data_struct_code ossimDDFFieldDefn::_data_struct_code
private

Definition at line 256 of file ossimIso8211.h.

Referenced by Create(), Dump(), GenerateDDREntry(), and Initialize().

◆ _data_type_code

DDF_data_type_code ossimDDFFieldDefn::_data_type_code
private

Definition at line 258 of file ossimIso8211.h.

Referenced by Create(), Dump(), and GenerateDDREntry().

◆ _fieldName

char* ossimDDFFieldDefn::_fieldName
private

◆ _formatControls

char* ossimDDFFieldDefn::_formatControls
private

◆ bRepeatingSubfields

int ossimDDFFieldDefn::bRepeatingSubfields
private

◆ nFixedWidth

int ossimDDFFieldDefn::nFixedWidth
private

Definition at line 251 of file ossimIso8211.h.

Referenced by ApplyFormats(), GetFixedWidth(), and ossimDDFFieldDefn().

◆ nSubfieldCount

int ossimDDFFieldDefn::nSubfieldCount
private

◆ papoSubfields

ossimDDFSubfieldDefn** ossimDDFFieldDefn::papoSubfields
private

◆ poModule

ossimDDFModule* ossimDDFFieldDefn::poModule
private

Definition at line 243 of file ossimIso8211.h.

Referenced by Create(), Initialize(), and ossimDDFFieldDefn().

◆ pszTag

char* ossimDDFFieldDefn::pszTag
private

The documentation for this class was generated from the following files: