DDFRecord Class Reference

#include <iso8211.h>

List of all members.

Public Member Functions

DDFRecordClone ()
DDFRecordCloneOn (DDFModule *)
void Dump (FILE *)
int GetFieldCount ()
DDFFieldFindField (const char *, int=0)
DDFFieldGetField (int)
int GetIntSubfield (const char *, int, const char *, int, int *=NULL)
double GetFloatSubfield (const char *, int, const char *, int, int *=NULL)
const char * GetStringSubfield (const char *, int, const char *, int, int *=NULL)
int SetIntSubfield (const char *pszField, int iFieldIndex, const char *pszSubfield, int iSubfieldIndex, int nValue)
int SetStringSubfield (const char *pszField, int iFieldIndex, const char *pszSubfield, int iSubfieldIndex, const char *pszValue, int nValueLength=-1)
int SetFloatSubfield (const char *pszField, int iFieldIndex, const char *pszSubfield, int iSubfieldIndex, double dfNewValue)
int GetDataSize ()
const char * GetData ()
DDFModuleGetModule ()
int ResizeField (DDFField *poField, int nNewDataSize)
int DeleteField (DDFField *poField)
DDFFieldAddField (DDFFieldDefn *)
int CreateDefaultFieldInstance (DDFField *poField, int iIndexWithinField)
int SetFieldRaw (DDFField *poField, int iIndexWithinField, const char *pachRawData, int nRawDataSize)
int Write ()

Detailed Description

Contains instance data from one data record (DR). The data is contained as a list of DDFField instances partitioning the raw data into fields.


Member Function Documentation

DDFField * DDFRecord::AddField ( DDFFieldDefn poDefn  ) 

Add a new field to record.

Add a new zero sized field to the record. The new field is always added at the end of the record.

NOTE: This method doesn't currently update the header information for the record to include the field information for this field, so the resulting record image isn't suitable for writing to disk. However, everything else about the record state should be updated properly to reflect the new field.

Parameters:
poDefn the definition of the field to be added.
Returns:
the field object on success, or NULL on failure.
DDFRecord * DDFRecord::Clone (  ) 

Make a copy of a record.

This method is used to make a copy of a record that will become (mostly) the properly of application. However, it is automatically destroyed if the DDFModule it was created relative to is destroyed, as it's field and subfield definitions relate to that DDFModule. However, it does persist even when the record returned by DDFModule::ReadRecord() is invalidated, such as when reading a new record. This allows an application to cache whole DDFRecords.

Returns:
A new copy of the DDFRecord. This can be delete'd by the application when no longer needed, otherwise it will be cleaned up when the DDFModule it relates to is destroyed or closed.
DDFRecord * DDFRecord::CloneOn ( DDFModule poTargetModule  ) 

Recreate a record referencing another module.

Works similarly to the DDFRecord::Clone() method, but creates the new record with reference to a different DDFModule. All DDFFieldDefn references are transcribed onto the new module based on field names. If any fields don't have a similarly named field on the target module the operation will fail. No validation of field types and properties is done, but this operation is intended only to be used between modules with matching definitions of all affected fields.

The new record will be managed as a clone by the target module in a manner similar to regular clones.

Parameters:
poTargetModule the module on which the record copy should be created.
Returns:
NULL on failure or a pointer to the cloned record.
int DDFRecord::CreateDefaultFieldInstance ( DDFField poField,
int  iIndexWithinField 
)

Initialize default instance.

This method is normally only used internally by the AddField() method to initialize the new field instance with default subfield values. It installs default data for one instance of the field in the record using the DDFFieldDefn::GetDefaultValue() method and DDFRecord::SetFieldRaw().

Parameters:
poField the field within the record to be assign a default instance.
iIndexWithinField the instance to set (may not have been tested with values other than 0).
Returns:
TRUE on success or FALSE on failure.
int DDFRecord::DeleteField ( DDFField poTarget  ) 

Delete a field instance from a record.

Remove a field from this record, cleaning up the data portion and repacking the fields list. We don't try to reallocate the data area of the record to be smaller.

NOTE: This method doesn't actually remove the header information for this field from the record tag list yet. This should be added if the resulting record is even to be written back to disk!

Parameters:
poTarget the field instance on this record to delete.
Returns:
TRUE on success, or FALSE on failure. Failure can occur if poTarget isn't really a field on this record.
void DDFRecord::Dump ( FILE *  fp  ) 

Write out record contents to debugging file.

A variety of information about this record, and all it's fields and subfields is written to the given debugging file handle. Note that field definition information (ala DDFFieldDefn) isn't written.

Parameters:
fp The standard io file handle to write to. ie. stderr
DDFField * DDFRecord::FindField ( const char *  pszName,
int  iFieldIndex = 0 
)

Find the named field within this record.

Parameters:
pszName The name of the field to fetch. The comparison is case insensitive.
iFieldIndex The instance of this field to fetch. Use zero (the default) for the first instance.
Returns:
Pointer to the requested DDFField. This pointer is to an internal object, and should not be freed. It remains valid until the next record read.
const char* DDFRecord::GetData (  )  [inline]

Fetch the raw data for this record. The returned pointer is effectively to the data for the first field of the record, and is of size GetDataSize().

int DDFRecord::GetDataSize (  )  [inline]

Fetch size of records raw data (GetData()) in bytes.

DDFField * DDFRecord::GetField ( int  i  ) 

Fetch field object based on index.

Parameters:
i The index of the field to fetch. Between 0 and GetFieldCount()-1.
Returns:
A DDFField pointer, or NULL if the index is out of range.
int DDFRecord::GetFieldCount (  )  [inline]

Get the number of DDFFields on this record.

double DDFRecord::GetFloatSubfield ( const char *  pszField,
int  iFieldIndex,
const char *  pszSubfield,
int  iSubfieldIndex,
int *  pnSuccess = NULL 
)

Fetch value of a subfield as a float (double). This is a convenience function for fetching a subfield of a field within this record.

Parameters:
pszField The name of the field containing the subfield.
iFieldIndex The instance of this field within the record. Use zero for the first instance of this field.
pszSubfield The name of the subfield within the selected field.
iSubfieldIndex The instance of this subfield within the record. Use zero for the first instance.
pnSuccess Pointer to an int which will be set to TRUE if the fetch succeeds, or FALSE if it fails. Use NULL if you don't want to check success.
Returns:
The value of the subfield, or zero if it failed for some reason.
int DDFRecord::GetIntSubfield ( const char *  pszField,
int  iFieldIndex,
const char *  pszSubfield,
int  iSubfieldIndex,
int *  pnSuccess = NULL 
)

Fetch value of a subfield as an integer. This is a convenience function for fetching a subfield of a field within this record.

Parameters:
pszField The name of the field containing the subfield.
iFieldIndex The instance of this field within the record. Use zero for the first instance of this field.
pszSubfield The name of the subfield within the selected field.
iSubfieldIndex The instance of this subfield within the record. Use zero for the first instance.
pnSuccess Pointer to an int which will be set to TRUE if the fetch succeeds, or FALSE if it fails. Use NULL if you don't want to check success.
Returns:
The value of the subfield, or zero if it failed for some reason.
DDFModule* DDFRecord::GetModule (  )  [inline]

Fetch the DDFModule with which this record is associated.

const char * DDFRecord::GetStringSubfield ( const char *  pszField,
int  iFieldIndex,
const char *  pszSubfield,
int  iSubfieldIndex,
int *  pnSuccess = NULL 
)

Fetch value of a subfield as a string. This is a convenience function for fetching a subfield of a field within this record.

Parameters:
pszField The name of the field containing the subfield.
iFieldIndex The instance of this field within the record. Use zero for the first instance of this field.
pszSubfield The name of the subfield within the selected field.
iSubfieldIndex The instance of this subfield within the record. Use zero for the first instance.
pnSuccess Pointer to an int which will be set to TRUE if the fetch succeeds, or FALSE if it fails. Use NULL if you don't want to check success.
Returns:
The value of the subfield, or NULL if it failed for some reason. The returned pointer is to internal data and should not be modified or freed by the application.
int DDFRecord::ResizeField ( DDFField poField,
int  nNewDataSize 
)

Alter field data size within record.

This method will rearrange a DDFRecord altering the amount of space reserved for one of the existing fields. All following fields will be shifted accordingly. This includes updating the DDFField infos, and actually moving stuff within the data array after reallocating to the desired size.

Parameters:
poField the field to alter.
nNewDataSize the number of data bytes to be reserved for the field.
Returns:
TRUE on success or FALSE on failure.
int DDFRecord::SetFieldRaw ( DDFField poField,
int  iIndexWithinField,
const char *  pachRawData,
int  nRawDataSize 
)

Set the raw contents of a field instance.

Parameters:
poField the field to set data within.
iIndexWithinField The instance of this field to replace. Must be a value between 0 and GetRepeatCount(). If GetRepeatCount() is used, a new instance of the field is appeneded.
pachRawData the raw data to replace this field instance with.
nRawDataSize the number of bytes pointed to by pachRawData.
Returns:
TRUE on success or FALSE on failure.
int DDFRecord::SetFloatSubfield ( const char *  pszField,
int  iFieldIndex,
const char *  pszSubfield,
int  iSubfieldIndex,
double  dfNewValue 
)

Set a float subfield in record.

The value of a given subfield is replaced with a new float value formatted appropriately.

Parameters:
pszField the field name to operate on.
iFieldIndex the field index to operate on (zero based).
pszSubfield the subfield name to operate on.
iSubfieldIndex the subfield index to operate on (zero based).
dfNewValue the new value to place in the subfield.
Returns:
TRUE if successful, and FALSE if not.
int DDFRecord::SetIntSubfield ( const char *  pszField,
int  iFieldIndex,
const char *  pszSubfield,
int  iSubfieldIndex,
int  nNewValue 
)

Set an integer subfield in record.

The value of a given subfield is replaced with a new integer value formatted appropriately.

Parameters:
pszField the field name to operate on.
iFieldIndex the field index to operate on (zero based).
pszSubfield the subfield name to operate on.
iSubfieldIndex the subfield index to operate on (zero based).
nNewValue the new value to place in the subfield.
Returns:
TRUE if successful, and FALSE if not.
int DDFRecord::SetStringSubfield ( const char *  pszField,
int  iFieldIndex,
const char *  pszSubfield,
int  iSubfieldIndex,
const char *  pszValue,
int  nValueLength = -1 
)

Set a string subfield in record.

The value of a given subfield is replaced with a new string value formatted appropriately.

Parameters:
pszField the field name to operate on.
iFieldIndex the field index to operate on (zero based).
pszSubfield the subfield name to operate on.
iSubfieldIndex the subfield index to operate on (zero based).
pszValue the new string to place in the subfield. This may be arbitrary binary bytes if nValueLength is specified.
nValueLength the number of valid bytes in pszValue, may be -1 to internally fetch with strlen().
Returns:
TRUE if successful, and FALSE if not.
int DDFRecord::Write (  ) 

Write record out to module.

This method writes the current record to the module to which it is attached. Normally this would be at the end of the file, and only used for modules newly created with DDFModule::Create(). Rewriting existing records is not supported at this time. Calling Write() multiple times on a DDFRecord will result it multiple copies being written at the end of the module.

Returns:
TRUE on success or FALSE on failure.

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

Generated on 2 Aug 2014 for ISO8211Lib by  doxygen 1.6.1