Class for executing scans of record files. More...
#include <RecordFileScan.h>
Public Member Functions | |
ReturnCode | openScan (RecordFileHandle *fileHandle, AttributeType attrType, int attrLength, int attrOffset, ComparisonOp compOp, void *value) |
Initialize a record file scan. | |
ReturnCode | getNextRecord (Record *record) |
Get the next matching record. | |
ReturnCode | closeScan () |
Terminate the record file scan. |
Class for executing scans of record files.
This class provides clients the capability to perform scans over the records of a file, where a scan may be based on a specified condition. See method documentation below.
ReturnCode RecordFileScan::closeScan | ( | ) |
Terminate the record file scan.
Terminate the record file scan. Returns RC_OK on success, and other ReturnCode values otherwise.
ReturnCode RecordFileScan::getNextRecord | ( | Record * | record | ) |
Get the next matching record.
record | The record will be copied here |
Get the next matching record in the file. Returns RC_OK on success, RC_EOF if there are no more matching records, and other ReturnCode values otherwise.
ReturnCode RecordFileScan::openScan | ( | RecordFileHandle * | fileHandle, | |
AttributeType | attrType, | |||
int | attrLength, | |||
int | attrOffset, | |||
ComparisonOp | compOp, | |||
void * | value | |||
) |
Initialize a record file scan.
fileHandle | The handle to the record file to be scanned | |
attrType | The type of the attribute being compared | |
attrLength | The length in bytes of the attribute being compared | |
attrOffset | The offset in the record of the attribute being compared | |
compOp | The comparison operation to use | |
value | The value with which to compare |
Opens a scan of the record file referred to by parameter fileHandle. Returns RC_OK on success, and other ReturnCode values otherwise. During the scan, only the records satisfying the specified condition (a comparison with a value) should be retrieved. If the value parameter is a null pointer, then there is no condition and all records are retrieved during the scan. If the value parameter is not a null pointer, then it points to the value that attributes are to be compared with.
Parameters attrType and attrLength indicate the type and length of the attribute being compared: either a 4-byte integer, a 4-byte floating point number, or a character string with a length between 0 and MAX_STRING_LEN. You will need to cast "value" into the appropriate type for the attribute (or, in the case of an integer or a float, copy it into a separate variable to avoid alignment problems). If a character string has length n, then the attribute and the value will each be exactly n bytes long. They will not necessarily be null-terminated. Parameter attrOffset indicates where the attribute is found within the contents of each record. Parameter compOp indicates the way that the record's attribute value should be compared with the value parameter (see comments for ComparisonOp).