DDFSubfieldDefn Class Reference

#include <iso8211.h>

List of all members.

Public Types

enum  DDFBinaryFormat

Public Member Functions

const char * GetName ()
const char * GetFormat ()
DDFDataType GetType ()
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)
int FormatIntValue (char *pachData, int nBytesAvailable, int *pnBytesUsed, int nNewValue)
int FormatFloatValue (char *pachData, int nBytesAvailable, int *pnBytesUsed, double dfNewValue)
int GetWidth ()
int GetDefaultValue (char *pachData, int nBytesAvailable, int *pnBytesUsed)
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 occurance of that field (as a DDFField) in a DDFRecord. Subfield's actually contain formatted data (as instances within a record).


Member Enumeration Documentation

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


Member Function Documentation

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:
fp The standard io file handle to write to. ie. stderr
void DDFSubfieldDefn::DumpData ( const char *  pachData,
int  nMaxBytes,
FILE *  fp 
)

Dump subfield value to debugging file.

Parameters:
pachData Pointer to data for this subfield.
nMaxBytes Maximum number of bytes available in pachData.
fp File to write report to.
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:
pachSourceData The pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytes The maximum number of bytes that are accessable after pachSourceData.
pnConsumedBytes Pointer 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()
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:
pachSourceData The pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytes The maximum number of bytes that are accessable after pachSourceData.
pnConsumedBytes Pointer 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()
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:
pachSourceData The pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytes The maximum number of bytes that are accessable after pachSourceData.
pnConsumedBytes Pointer 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()
int DDFSubfieldDefn::FormatFloatValue ( char *  pachData,
int  nBytesAvailable,
int *  pnBytesUsed,
double  dfNewValue 
)

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.

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

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.

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

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.

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:
pachSourceData The pointer to the raw data for this field. This may have come from DDFRecord::GetData(), taking into account skip factors over previous subfields data.
nMaxBytes The maximum number of bytes that are accessable after pachSourceData.
pnConsumedBytes Pointer 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).
int DDFSubfieldDefn::GetDefaultValue ( char *  pachData,
int  nBytesAvailable,
int *  pnBytesUsed 
)

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:
pachData the buffer into which the returned default will be placed. May be NULL if just querying default size.
nBytesAvailable the size of pachData in bytes.
pnBytesUsed will 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.
const char* DDFSubfieldDefn::GetFormat (  )  [inline]

Get pointer to subfield format string

const char* DDFSubfieldDefn::GetName (  )  [inline]

Get pointer to subfield name.

DDFDataType DDFSubfieldDefn::GetType (  )  [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.
int DDFSubfieldDefn::GetWidth (  )  [inline]

Get the subfield width (zero for variable).


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

Generated on 2 Aug 2014 for SDTS_AL by  doxygen 1.6.1