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

#include <ossimAuxFileHandler.h>

Public Member Functions

 ossimAuxField ()
 
 ~ossimAuxField ()
 
int extractInstValue (const char *auxField, int nIndexValue, char *entryData, ossim_uint32 nDataOffset, int nDataSize, char chReqType, void *reqReturn)
 
int getInstCount (char *entryData, int nDataSize)
 
int getInstBytes (char *entryData, int nDataSize)
 
const char * initialize (const char *fieldInput)
 
void completeDefn (ossimAuxDictionary *auxDict)
 

Public Attributes

int nBytes
 
int nItemCount
 
char chPointer
 
char chItemType
 
char * itemObjectType
 
ossimAuxTypem_auxItemObjectType
 
char ** enumNames
 
char * fieldName
 

Detailed Description

Definition at line 121 of file ossimAuxFileHandler.h.

Constructor & Destructor Documentation

◆ ossimAuxField()

ossimAuxField::ossimAuxField ( )

Definition at line 512 of file ossimAuxFileHandler.cpp.

513 {
514  nBytes = 0;
515 
516  nItemCount = 0;
517  chPointer = '\0';
518  chItemType = '\0';
519 
520  itemObjectType = NULL;
521  m_auxItemObjectType = NULL;
522 
523  enumNames = NULL;
524  fieldName = NULL;
525 }
ossimAuxType * m_auxItemObjectType

◆ ~ossimAuxField()

ossimAuxField::~ossimAuxField ( )

Definition at line 527 of file ossimAuxFileHandler.cpp.

528 {
529  if (itemObjectType != NULL)
530  {
531  delete[] itemObjectType;
532  itemObjectType = 0;
533  }
534 
535  if (enumNames != NULL)
536  {
537  delete[] enumNames;
538  enumNames = 0;
539  }
540 
541  if (fieldName != NULL)
542  {
543  delete[] fieldName;
544  fieldName = 0;
545  }
546 }

Member Function Documentation

◆ completeDefn()

void ossimAuxField::completeDefn ( ossimAuxDictionary auxDict)

Definition at line 615 of file ossimAuxFileHandler.cpp.

References ossimAuxType::completeDefn(), ossimAuxDictionary::findType(), and ossimAuxDictionary::getItemSize().

617 {
618  if( itemObjectType != NULL )
619  {
621  }
622 
623  if( chPointer == 'p' )
624  {
625  nBytes = -1; /* we can't know the instance size */
626  }
627  else if( m_auxItemObjectType != NULL )
628  {
629  m_auxItemObjectType->completeDefn( auxDict );
630  if( m_auxItemObjectType->nBytes == -1 )
631  {
632  nBytes = -1;
633  }
634  else
635  {
637  }
638 
639  if( chPointer == '*' && nBytes != -1 )
640  {
641  nBytes += 8; /* count, and offset */
642  }
643  }
644  else
645  {
646  nBytes = auxDict->getItemSize( chItemType ) * nItemCount;
647  }
648 }
ossimAuxType * m_auxItemObjectType
ossimAuxType * findType(const char *name)
static int getItemSize(char chType)
void completeDefn(ossimAuxDictionary *auxDict)

◆ extractInstValue()

int ossimAuxField::extractInstValue ( const char *  auxField,
int  nIndexValue,
char *  entryData,
ossim_uint32  nDataOffset,
int  nDataSize,
char  chReqType,
void *  reqReturn 
)

Definition at line 548 of file ossimAuxFileHandler.cpp.

552 {
553  int nInstItemCount = getInstCount( entryData, nDataSize );
554 
555  if( nIndexValue < 0 || nIndexValue >= nInstItemCount )
556  {
557  if( chItemType == 'b' && nIndexValue >= -3 && nIndexValue < 0 )
558  /* ok - special index values */;
559  else
560  return false;
561  }
562 
563  if( chPointer != '\0' )
564  {
565  ossim_uint32 nOffset;
566 
567  memcpy( &nOffset, entryData+4, 4 );
568 
569  entryData += 8;
570 
571  nDataOffset += 8;
572  nDataSize -= 8;
573  }
574 
575  if( (chItemType == 'c' || chItemType == 'C') && chReqType == 's' )
576  {
577  *((char **)reqReturn) = entryData;
578  return( entryData != NULL );
579  }
580 
581  return false;
582 }
int getInstCount(char *entryData, int nDataSize)
unsigned int ossim_uint32

◆ getInstBytes()

int ossimAuxField::getInstBytes ( char *  entryData,
int  nDataSize 
)

Definition at line 757 of file ossimAuxFileHandler.cpp.

References ossimAuxDictionary::getItemSize(), ossimAuxGetDataTypeBits(), and ossimAuxStandardFile().

Referenced by ossimAuxType::getInstBytes().

759 {
760  int nCount;
761  int nInstBytes = 0;
762 
763  if( nBytes > -1 )
764  return nBytes;
765 
766  if( chPointer != '\0' )
767  {
768  memcpy( &nCount, entryData, 4 );
769  ossimAuxStandardFile( 4, &nCount );
770 
771  entryData += 8;
772  nInstBytes += 8;
773  }
774  else
775  nCount = 1;
776 
777  if( chItemType == 'b' && nCount != 0 ) // BASEDATA
778  {
779  ossim_int32 nRows, nColumns;
780  ossim_int16 nBaseItemType;
781 
782  memcpy( &nRows, entryData, 4 );
783  ossimAuxStandardFile( 4, &nRows );
784  memcpy( &nColumns, entryData+4, 4 );
785  ossimAuxStandardFile( 4, &nColumns );
786  memcpy( &nBaseItemType, entryData+8, 2 );
787  ossimAuxStandardFile( 2, &nBaseItemType );
788 
789  nInstBytes += 12;
790 
791  nInstBytes +=
792  ((ossimAuxGetDataTypeBits(nBaseItemType) + 7) / 8) * nRows * nColumns;
793  }
794  else if( m_auxItemObjectType == NULL )
795  {
796  nInstBytes += nCount * ossimAuxDictionary::getItemSize(chItemType);
797  }
798  else
799  {
800  int i;
801 
802  for( i = 0; i < nCount; i++ )
803  {
804  int nThisBytes;
805 
806  nThisBytes =
807  m_auxItemObjectType->getInstBytes( entryData,
808  nDataSize - nInstBytes );
809  nInstBytes += nThisBytes;
810  entryData += nThisBytes;
811  }
812  }
813 
814  return( nInstBytes );
815 }
ossimAuxType * m_auxItemObjectType
int getInstBytes(char *entryData, int nDataSize)
short ossim_int16
void ossimAuxStandardFile(int nBytes, void *pData)
static int getItemSize(char chType)
int ossimAuxGetDataTypeBits(int nDataType)
int ossim_int32

◆ getInstCount()

int ossimAuxField::getInstCount ( char *  entryData,
int  nDataSize 
)

Definition at line 584 of file ossimAuxFileHandler.cpp.

References ossimAuxStandardFile().

585 {
586  if( chPointer == '\0' )
587  return nItemCount;
588  else if( chItemType == 'b' )
589  {
590  ossim_int32 nRows, nColumns;
591 
592  if( nDataSize < 20 )
593  return 0;
594 
595  memcpy( &nRows, entryData+8, 4 );
596  ossimAuxStandardFile( 4, &nRows );
597  memcpy( &nColumns, entryData+12, 4 );
598  ossimAuxStandardFile( 4, &nColumns );
599 
600  return nRows * nColumns;
601  }
602  else
603  {
604  ossim_int32 nCount;
605 
606  if( nDataSize < 4 )
607  return 0;
608 
609  memcpy( &nCount, entryData, 4 );
610  ossimAuxStandardFile( 4, &nCount );
611  return nCount;
612  }
613 }
void ossimAuxStandardFile(int nBytes, void *pData)
int ossim_int32

◆ initialize()

const char * ossimAuxField::initialize ( const char *  fieldInput)

Definition at line 650 of file ossimAuxFileHandler.cpp.

Referenced by ossimAuxType::initialize().

651 {
652  int i;
653  nItemCount = atoi(fieldInput);
654 
655  while( *fieldInput != '\0' && *fieldInput != ':' )
656  {
657  fieldInput++;
658  }
659 
660  if( *fieldInput == '\0' )
661  {
662  return NULL;
663  }
664 
665  fieldInput++;
666 
667  if( *fieldInput == 'p' || *fieldInput == '*' )
668  chPointer = *(fieldInput++);
669 
670  if( *fieldInput == '\0' )
671  return NULL;
672 
673  chItemType = *(fieldInput++);
674 
675  if( chItemType == 'o' )
676  {
677  for( i = 0; fieldInput[i] != '\0' && fieldInput[i] != ','; i++ ) {}
678 
679  itemObjectType = (char *) malloc(i+1);
680  strncpy( itemObjectType, fieldInput, i );
681  itemObjectType[i] = '\0';
682 
683  fieldInput += i+1;
684  }
685 
686  if( chItemType == 'x' && *fieldInput == '{' )
687  {
688  int nBraceDepth = 1;
689  fieldInput++;
690 
691  // Skip past the definition.
692  while( nBraceDepth > 0 && *fieldInput != '\0' )
693  {
694  if( *fieldInput == '{' )
695  nBraceDepth++;
696  else if( *fieldInput == '}' )
697  nBraceDepth--;
698 
699  fieldInput++;
700  }
701 
702  chItemType = 'o';
703 
704  // find the comma terminating the type name.
705  for( i = 0; fieldInput[i] != '\0' && fieldInput[i] != ','; i++ ) {}
706 
707  itemObjectType = (char *) malloc(i+1);
708  strncpy( itemObjectType, fieldInput, i );
709  itemObjectType[i] = '\0';
710 
711  fieldInput += i+1;
712  }
713 
714  if( chItemType == 'e' )
715  {
716  int nEnumCount = atoi(fieldInput);
717  int iEnum;
718 
719  fieldInput = strchr(fieldInput,':');
720  if( fieldInput == NULL )
721  return NULL;
722 
723  fieldInput++;
724 
725  enumNames = (char **) calloc(sizeof(char *), nEnumCount+1);
726 
727  for( iEnum = 0; iEnum < nEnumCount; iEnum++ )
728  {
729  char *pszToken;
730 
731  for( i = 0; fieldInput[i] != '\0' && fieldInput[i] != ','; i++ ) {}
732 
733  if( fieldInput[i] != ',' )
734  return NULL;
735 
736  pszToken = (char *) malloc(i+1);
737  strncpy( pszToken, fieldInput, i );
738  pszToken[i] = '\0';
739 
740  enumNames[iEnum] = pszToken;
741 
742  fieldInput += i+1;
743  }
744  }
745 
746  for( i = 0; fieldInput[i] != '\0' && fieldInput[i] != ','; i++ ) {}
747 
748  fieldName = (char *) malloc(i+1);
749  strncpy( fieldName, fieldInput, i );
750  fieldName[i] = '\0';
751 
752  fieldInput += i+1;
753 
754  return( fieldInput );
755 }

Member Data Documentation

◆ chItemType

char ossimAuxField::chItemType

Definition at line 128 of file ossimAuxFileHandler.h.

◆ chPointer

char ossimAuxField::chPointer

Definition at line 127 of file ossimAuxFileHandler.h.

◆ enumNames

char** ossimAuxField::enumNames

Definition at line 133 of file ossimAuxFileHandler.h.

◆ fieldName

char* ossimAuxField::fieldName

Definition at line 135 of file ossimAuxFileHandler.h.

◆ itemObjectType

char* ossimAuxField::itemObjectType

Definition at line 130 of file ossimAuxFileHandler.h.

◆ m_auxItemObjectType

ossimAuxType* ossimAuxField::m_auxItemObjectType

Definition at line 131 of file ossimAuxFileHandler.h.

◆ nBytes

int ossimAuxField::nBytes

Definition at line 124 of file ossimAuxFileHandler.h.

◆ nItemCount

int ossimAuxField::nItemCount

Definition at line 126 of file ossimAuxFileHandler.h.


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