168 <<
"Format type of `%c' not supported.\n" 176 <<
"Format type of `%c' not recognised.\n" 202 fprintf( fp,
" DDFSubfieldDefn:\n" );
203 fprintf( fp,
" Label = `%s'\n",
pszName );
238 int nMaxBytes,
int * pnConsumedBytes )
246 <<
"Only %d bytes available for subfield %s with\n" 247 <<
"format string %s ... returning shortened data." 250 if( pnConsumedBytes != NULL )
251 *pnConsumedBytes = nMaxBytes;
257 if( pnConsumedBytes != NULL )
266 int bCheckFieldTerminator =
true;
277 if( pachSourceData[0] < 32 || pachSourceData[0] >= 127 )
278 bCheckFieldTerminator =
false;
280 while( nLength < nMaxBytes
283 if( bCheckFieldTerminator
290 if( pnConsumedBytes != NULL )
293 *pnConsumedBytes = nLength;
295 *pnConsumedBytes = nLength+1;
339 int nMaxBytes,
int * pnConsumedBytes )
360 memcpy(
pachBuffer, pachSourceData, nLength );
395 int nMaxBytes,
int * pnConsumedBytes )
411 unsigned char abyData[8];
414 if( pnConsumedBytes != NULL )
440 return( abyData[0] );
461 signed char* ptr = (
signed char*) abyData;
483 float* ptr = (
float*) abyData;
488 double* ptr = (
double*) abyData;
545 int nMaxBytes,
int * pnConsumedBytes )
561 unsigned char abyData[8];
566 <<
"Attempt to extract int subfield %s with format %s\n" 567 <<
"failed as only %d bytes available. Using zero." 572 if( pnConsumedBytes != NULL )
603 return( abyData[0] );
624 signed char* ptr = (
signed char *) abyData;
641 float* ptr = (
float *) abyData;
646 double* ptr = (
double *) abyData;
694 fprintf( fp,
" Subfield `%s' = %f\n",
698 fprintf( fp,
" Subfield `%s' = %d\n",
706 fprintf( fp,
" Subfield `%s' = 0x",
pszName );
707 for( i = 0; i <
std::min(nBytes,24); i++ )
708 fprintf( fp,
"%02X", pabyBString[i] );
711 fprintf( fp,
"%s",
"..." );
716 fprintf( fp,
" Subfield `%s' = `%s'\n",
755 if( pnBytesUsed != NULL )
756 *pnBytesUsed = nDefaultSize;
758 if( pachData == NULL )
761 if( nBytesAvailable < nDefaultSize )
773 memset( pachData, 0, nDefaultSize );
775 memset( pachData,
' ', nDefaultSize );
778 memset( pachData, 0, nDefaultSize );
797 const char *pszValue,
803 if( nValueLength == -1 )
804 nValueLength = (int)strlen(pszValue);
808 nSize = nValueLength + 1;
815 if( pnBytesUsed != NULL )
816 *pnBytesUsed = nSize;
818 if( pachData == NULL )
821 if( nBytesAvailable < nSize )
826 strncpy( pachData, pszValue, nSize-1 );
833 memset( pachData,
' ', nSize );
834 memcpy( pachData, pszValue,
std::min(nValueLength,nSize) );
838 memset( pachData, 0, nSize );
839 memcpy( pachData, pszValue,
std::min(nValueLength,nSize) );
858 int *pnBytesUsed,
int nNewValue )
864 sprintf( szWork,
"%d", nNewValue );
868 nSize = (int)strlen(szWork) + 1;
878 if( pnBytesUsed != NULL )
879 *pnBytesUsed = nSize;
881 if( pachData == NULL )
884 if( nBytesAvailable < nSize )
889 strncpy( pachData, szWork, nSize-1 );
900 memset( pachData,
'0', nSize );
901 strncpy( pachData + nSize - strlen(szWork), szWork,
917 pachData[iOut] = (nNewValue & nMask) >> (i*8);
947 int *pnBytesUsed,
double dfNewValue )
953 sprintf( szWork,
"%.16g", dfNewValue );
957 nSize = (int)strlen(szWork) + 1;
967 if( pnBytesUsed != NULL )
968 *pnBytesUsed = nSize;
970 if( pachData == NULL )
973 if( nBytesAvailable < nSize )
978 strncpy( pachData, szWork, nSize-1 );
985 memset( pachData,
'0', nSize );
986 strncpy( pachData + nSize - strlen(szWork), szWork,
int GetDefaultValue(char *pachData, int nBytesAvailable, int *pnBytesUsed)
Get default data.
const char * ExtractStringData(const char *pachData, int nMaxBytes, int *pnConsumedBytes)
Extract a zero terminated string containing the data for this subfield.
int FormatFloatValue(char *pachData, int nBytesAvailable, int *pnBytesUsed, double dfNewValue)
Format float subfield value.
double ExtractFloatData(const char *pachData, int nMaxBytes, int *pnConsumedBytes)
Extract a subfield value as a float.
int FormatStringValue(char *pachData, int nBytesAvailable, int *pnBytesUsed, const char *pszValue, int nValueLength=-1)
Format string subfield value.
void Dump(FILE *fp)
Write out subfield definition info to debugging file.
unsigned short ossim_uint16
int FormatIntValue(char *pachData, int nBytesAvailable, int *pnBytesUsed, int nNewValue)
Format int subfield value.
unsigned int ossim_uint32
void SetName(const char *pszName)
int ExtractIntData(const char *pachData, int nMaxBytes, int *pnConsumedBytes)
Extract a subfield value as an integer.
int GetDataLength(const char *, int, int *)
Scan for the end of variable length data.
DDFBinaryFormat eBinaryFormat
#define OSSIM_DDF_UNIT_TERMINATOR
DDFBinaryFormat
Binary format: this is the digit immediately following the B or b for binary formats.
void DumpData(const char *pachData, int nMaxBytes, FILE *fp)
Dump subfield value to debugging file.
int SetFormat(const char *pszFormat)
DDFBinaryFormat GetBinaryFormat(void) const
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
DDFDataType GetType()
Get the general type of the subfield.
#define OSSIM_DDF_FIELD_TERMINATOR