ISO8211Lib
Public Types | Public Member Functions | List of all members
DDFSubfieldDefn Class Reference

#include <iso8211.h>

Public Types

enum  DDFBinaryFormat
 

Public Member Functions

const char * GetName () const
 
const char * GetFormat () const
 
DDFDataType GetType () const
 
double ExtractFloatData (const char *pachData, int nMaxBytes, int *pnConsumedBytes)
 
int ExtractIntData (const char *pachData, int nMaxBytes, int *pnConsumedBytes)
 
const char * ExtractStringData (const char *pachData, int nMaxBytes, int *pnConsumedBytes)
 
int GetDataLength (const char *, int, int *)
 
void DumpData (const char *pachData, int nMaxBytes, FILE *fp)
 
int FormatStringValue (char *pachData, int nBytesAvailable, int *pnBytesUsed, const char *pszValue, int nValueLength=-1) const
 
int FormatIntValue (char *pachData, int nBytesAvailable, int *pnBytesUsed, int nNewValue) const
 
int FormatFloatValue (char *pachData, int nBytesAvailable, int *pnBytesUsed, double dfNewValue) const
 
int GetWidth () const
 
int GetDefaultValue (char *pachData, int nBytesAvailable, int *pnBytesUsed) const
 
void Dump (FILE *fp)
 

Detailed Description

Information from the DDR record describing one subfield of a DDFFieldDefn. All subfields of a field will occur in each occurrence of that field (as a DDFField) in a DDFRecord. Subfield's actually contain formatted data (as instances within a record).

Member Enumeration Documentation

◆ DDFBinaryFormat

Binary format: this is the digit immediately following the B or b for binary formats.

Member Function Documentation

◆ Dump()

void DDFSubfieldDefn::Dump ( FILE *  fp)

Write out subfield definition info to debugging file.

A variety of information about this field definition is written to the give debugging file handle.

Parameters
fpThe standard IO file handle to write to. i.e. stderr

◆ DumpData()

void DDFSubfieldDefn::DumpData ( const char *  pachData,
int  nMaxBytes,
FILE *  fp 
)

Dump subfield value to debugging file.

Parameters
pachDataPointer to data for this subfield.
nMaxBytesMaximum number of bytes available in pachData.
fpFile to write report to.

◆ ExtractFloatData()

double DDFSubfieldDefn::ExtractFloatData ( const char *  pachSourceData,
int  nMaxBytes,
int *  pnConsumedBytes 
)

Extract a subfield value as a float. Given a pointer to the data for this subfield (from within a DDFRecord) this method will return the floating point data for this subfield. The number of bytes consumed as part of this field can also be fetched. This method may be called for any type of subfield, and will return zero if the subfield is not numeric.

Parameters
pachSourceDataThe pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytesThe maximum number of bytes that are accessible after pachSourceData.
pnConsumedBytesPointer to an integer into which the number of bytes consumed by this field should be written. May be NULL to ignore. This is used as a skip factor to increment pachSourceData to point to the next subfields data.
Returns
The subfield's numeric value (or zero if it isn't numeric).
See also
ExtractIntData(), ExtractStringData()

◆ ExtractIntData()

int DDFSubfieldDefn::ExtractIntData ( const char *  pachSourceData,
int  nMaxBytes,
int *  pnConsumedBytes 
)

Extract a subfield value as an integer. Given a pointer to the data for this subfield (from within a DDFRecord) this method will return the int data for this subfield. The number of bytes consumed as part of this field can also be fetched. This method may be called for any type of subfield, and will return zero if the subfield is not numeric.

Parameters
pachSourceDataThe pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytesThe maximum number of bytes that are accessible after pachSourceData.
pnConsumedBytesPointer to an integer into which the number of bytes consumed by this field should be written. May be NULL to ignore. This is used as a skip factor to increment pachSourceData to point to the next subfields data.
Returns
The subfield's numeric value (or zero if it isn't numeric).
See also
ExtractFloatData(), ExtractStringData()

◆ ExtractStringData()

const char * DDFSubfieldDefn::ExtractStringData ( const char *  pachSourceData,
int  nMaxBytes,
int *  pnConsumedBytes 
)

Extract a zero terminated string containing the data for this subfield. Given a pointer to the data for this subfield (from within a DDFRecord) this method will return the data for this subfield. The number of bytes consumed as part of this field can also be fetched. This number may be one longer than the string length if there is a terminator character used.

This function will return the raw binary data of a subfield for types other than DDFString, including data past zero chars. This is the standard way of extracting DDFBinaryString subfields for instance.

Parameters
pachSourceDataThe pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytesThe maximum number of bytes that are accessible after pachSourceData.
pnConsumedBytesPointer to an integer into which the number of bytes consumed by this field should be written. May be NULL to ignore. This is used as a skip factor to increment pachSourceData to point to the next subfields data.
Returns
A pointer to a buffer containing the data for this field. The returned pointer is to an internal buffer which is invalidated on the next ExtractStringData() call on this DDFSubfieldDefn(). It should not be freed by the application.
See also
ExtractIntData(), ExtractFloatData()

◆ FormatFloatValue()

int DDFSubfieldDefn::FormatFloatValue ( char *  pachData,
int  nBytesAvailable,
int *  pnBytesUsed,
double  dfNewValue 
) const

Format float subfield value.

Returns a buffer with the passed in float value reformatted in a way suitable for storage in a DDFField for this subfield.

◆ FormatIntValue()

int DDFSubfieldDefn::FormatIntValue ( char *  pachData,
int  nBytesAvailable,
int *  pnBytesUsed,
int  nNewValue 
) const

Format int subfield value.

Returns a buffer with the passed in int value reformatted in a way suitable for storage in a DDFField for this subfield.

◆ FormatStringValue()

int DDFSubfieldDefn::FormatStringValue ( char *  pachData,
int  nBytesAvailable,
int *  pnBytesUsed,
const char *  pszValue,
int  nValueLength = -1 
) const

Format string subfield value.

Returns a buffer with the passed in string value reformatted in a way suitable for storage in a DDFField for this subfield.

◆ GetDataLength()

int DDFSubfieldDefn::GetDataLength ( const char *  pachSourceData,
int  nMaxBytes,
int *  pnConsumedBytes 
)

Scan for the end of variable length data. Given a pointer to the data for this subfield (from within a DDFRecord) this method will return the number of bytes which are data for this subfield. The number of bytes consumed as part of this field can also be fetched. This number may be one longer than the length if there is a terminator character used.

This method is mainly for internal use, or for applications which want the raw binary data to interpret themselves. Otherwise use one of ExtractStringData(), ExtractIntData() or ExtractFloatData().

Parameters
pachSourceDataThe pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytesThe maximum number of bytes that are accessible after pachSourceData.
pnConsumedBytesPointer to an integer into which the number of bytes consumed by this field should be written. May be NULL to ignore.
Returns
The number of bytes at pachSourceData which are actual data for this record (not including unit, or field terminator).

◆ GetDefaultValue()

int DDFSubfieldDefn::GetDefaultValue ( char *  pachData,
int  nBytesAvailable,
int *  pnBytesUsed 
) const

Get default data.

Returns the default subfield data contents for this subfield definition. For variable length numbers this will normally be "0<unit-terminator>". For variable length strings it will be "<unit-terminator>". For fixed length numbers it is zero filled. For fixed length strings it is space filled. For binary numbers it is binary zero filled.

Parameters
pachDatathe buffer into which the returned default will be placed. May be NULL if just querying default size.
nBytesAvailablethe size of pachData in bytes.
pnBytesUsedwill receive the size of the subfield default data in bytes.
Returns
TRUE on success or FALSE on failure or if the passed buffer is too small to hold the default.

◆ GetFormat()

const char* DDFSubfieldDefn::GetFormat ( ) const
inline

Get pointer to subfield format string

◆ GetName()

const char* DDFSubfieldDefn::GetName ( ) const
inline

Get pointer to subfield name.

◆ GetType()

DDFDataType DDFSubfieldDefn::GetType ( ) const
inline

Get the general type of the subfield. This can be used to determine which of ExtractFloatData(), ExtractIntData() or ExtractStringData() should be used.

Returns
The subfield type. One of DDFInt, DDFFloat, DDFString or DDFBinaryString.

◆ GetWidth()

int DDFSubfieldDefn::GetWidth ( ) const
inline

Get the subfield width (zero for variable).


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