Xbase64 Class Library
3.1.2
|
xbMH struct More...
#include <xbdbf.h>
Public Member Functions | |
xbDbf (xbXBase *) | |
Constructor. More... | |
virtual | ~xbDbf () |
Destructor. More... | |
xbShort | AppendRecord () |
Append the current record to the data file. More... | |
xbShort | BlankRecord () |
Blank the record buffer. More... | |
xbShort | CloseDatabase (xbBool deleteIndexes=0) |
Close the dbf file. More... | |
xbShort | CopyDbfStructure (const char *, xbShort) |
Copy DBF structure. More... | |
xbShort | CreateDatabase (const char *Name, xbSchema *, xbShort Overlay) |
Create the dbf file. More... | |
xbShort | DeleteAllRecords () |
Delete all records. More... | |
xbShort | DeleteRecord () |
Delete the current record. More... | |
xbShort | DumpRecord (xbULong) |
Dump record. More... | |
xbLong | FieldCount () |
Return number of fields. More... | |
const xbString & | GetDbfName () |
Return Dbf name. More... | |
xbShort | GetDbfStatus () |
Return status. More... | |
xbShort | GetFirstRecord () |
Get the first physical record in the data file. More... | |
xbShort | GetLastRecord () |
Get the last phyiscal record in the data file. More... | |
xbShort | GetNextRecord () |
Get the next physical record in the data file. More... | |
xbShort | GetPrevRecord () |
Get the previous physical record in the data file. More... | |
xbLong | GetCurRecNo () |
Return current record number. More... | |
xbShort | GetRecord (xbULong) |
Get a record from the data file. More... | |
char * | GetRecordBuf () |
Return a pointer to the record buffer. More... | |
xbShort | GetRecordLen () |
Return record length. More... | |
xbShort | NameSuffixMissing (xbShort, const char *) |
Determine if file name suffix is missing. More... | |
xbLong | GetRecCnt () |
xbLong | NoOfRecords () |
Remove an index from the list. More... | |
xbLong | PhysicalNoOfRecords () |
Get the physical number of records in the data file. More... | |
xbShort | OpenDatabase (const char *) |
Dump header information. More... | |
xbShort | PackDatabase (xbShort LockWaitOption, void(*packStatusFunc)(xbLong itemNum, xbLong numItems)=0, void(*indexStatusFunc)(xbLong itemNum, xbLong numItems)=0) |
Pack the database. More... | |
xbShort | PutRecord () |
Write the current record buffer to the current record in the data file. More... | |
xbShort | PutRecord (xbULong) |
Write the current record buffer to the specified record in the data file. More... | |
xbShort | RebuildAllIndices (void(*statusFunc)(xbLong itemNum, xbLong numItems)=0) |
Add index to list. More... | |
xbShort | RecordDeleted () |
Determine if current record is deleted. More... | |
void | ResetNoOfRecs () |
Set number of records to zero???? More... | |
xbShort | SetVersion (xbShort) |
Set dbase version for the dbf file. More... | |
xbShort | UndeleteAllRecords () |
Undelete all records. More... | |
xbShort | UndeleteRecord () |
Undelete the current record. More... | |
xbShort | Zap (xbShort) |
Delete all records and pack data file. More... | |
const char * | GetField (xbShort FieldNo) const |
Get the value of the specified field. More... | |
const char * | GetField (const char *Name) const |
Get the value of the specified field. More... | |
xbShort | GetField (xbShort FieldNo, char *Buf) const |
Get the value of the specified field. More... | |
xbShort | GetRawField (xbShort FieldNo, char *Buf) const |
Get the raw value of the specified field. More... | |
xbShort | GetField (xbShort FieldNo, char *Buf, xbShort RecBufSw) const |
Get the value of the specified field. More... | |
xbShort | GetField (const char *Name, char *Buf) const |
Get the value of the specified field. More... | |
xbShort | GetRawField (const char *Name, char *Buf) const |
Get the raw value of the specified field. More... | |
xbShort | GetField (const char *Name, char *Buf, xbShort RecBufSw) const |
Get the value of the specified field. More... | |
xbShort | GetField (xbShort FieldNo, xbString &, xbShort RecBufSw) const |
xbShort | GetFieldDecimal (xbShort) |
Returns the number of decimals in the specified field. More... | |
xbShort | GetFieldLen (xbShort) |
Returns the length of the specified field. More... | |
char * | GetFieldName (xbShort) |
Returns the name of the specified field. More... | |
xbShort | GetFieldNo (const char *FieldName) const |
Returns the field number of the specified field. More... | |
char | GetFieldType (xbShort FieldNo) const |
Returns the type of the specified field. More... | |
xbShort | GetLogicalField (xbShort FieldNo) |
Get the logical value of the specified field. More... | |
xbShort | GetLogicalField (const char *FieldName) |
Get the logical value of the specified field. More... | |
char * | GetStringField (xbShort FieldNo) |
Get the string value of the specified field. More... | |
char * | GetStringField (const char *FieldName) |
Get the string value of the specified field. More... | |
xbShort | PutField (xbShort, const char *) |
Put a value into the specified field. More... | |
xbShort | PutRawField (xbShort FieldNo, const char *buf) |
Put a raw value into the specified field. More... | |
xbShort | PutField (const char *Name, const char *buf) |
Put a value into the specified field. More... | |
xbShort | PutRawField (const char *Name, const char *buf) |
Put a raw value into the specified field. More... | |
xbShort | ValidLogicalData (const char *) |
Determines if data is valid logical data. More... | |
xbShort | ValidNumericData (const char *) |
Determines if data is valid numeric data. More... | |
xbLong | GetLongField (const char *FieldName) const |
Get the long value of the specified field. More... | |
xbLong | GetLongField (const xbShort FieldNo) const |
Get the long value of the specified field. More... | |
xbShort | PutLongField (const xbShort, const xbLong) |
Put a long value into the specified field. More... | |
xbShort | PutLongField (const char *, const xbLong) |
Put a long value into the specified field. More... | |
xbFloat | GetFloatField (const char *FieldName) |
Get the float value of the specified field. More... | |
xbFloat | GetFloatField (xbShort FieldNo) |
Get the float value of the specified field. More... | |
xbShort | PutFloatField (const char *, const xbFloat) |
Put a float value into the specified field. More... | |
xbShort | PutFloatField (const xbShort, const xbFloat) |
Put a float value into the specified field. More... | |
xbDouble | GetDoubleField (const char *) |
Get the double value of the specified field. More... | |
xbDouble | GetDoubleField (xbShort, xbShort RecBufSw=0) |
Get the double value of the specified field. More... | |
xbShort | PutDoubleField (const char *, xbDouble) |
Put a double value into the specified field. More... | |
xbShort | PutDoubleField (const xbShort, xbDouble) |
Put a double value into the specified field. More... | |
xbShort | LockDatabase (xbShort, xbShort, xbLong) |
xbShort | ExclusiveLock (xbShort) |
xbShort | ExclusiveUnlock () |
void | AutoLockOn () |
Turn autolock on. More... | |
void | AutoLockOff () |
Turn autolock off. More... | |
xbShort | GetAutoLock () |
Return whether or not autolocking is on or off. More... | |
void | RealDeleteOn () |
Turn on "real" deletes. More... | |
void | RealDeleteOff () |
xbShort | GetRealDelete () |
Return whether "real" deletes are on or off. More... | |
void | Flush () |
virtual const char * | GetExtWithDot (bool lower) |
Public Attributes | |
xbXBase * | xbase |
Additional Inherited Members | |
![]() | |
void | SetFileName (const char *filename) |
xbFile () | |
const xbString & | GetFileName () |
xbString | MakeFileName (const char *filename) |
xbMH struct
Internal use only.xbDbf class
The xbDbf class encapsulates an xbase DBF database file. It includes all dbf access, field access, and locking methods.
xbDbf::xbDbf | ( | xbXBase * | x | ) |
Constructor.
x | pointer to the global xbXbase class |
|
virtual |
Destructor.
xbShort xbDbf::AppendRecord | ( | ) |
Append the current record to the data file.
This method attempts to append the contents of the current record buffer to the end of the DBF file and updates the file date and number of records in the file. Also updates any open indices associated with this data file.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_WRITE_ERROR | Error writing to file |
|
inline |
Turn autolock off.
|
inline |
Turn autolock on.
xbShort xbDbf::BlankRecord | ( | ) |
Blank the record buffer.
Sets the record to spaces.
Close the dbf file.
This method attempts to close the DBF file which was previously opened with either CreateDatabase() or OpenDatabase(). Deletes any memory allocated. Automatically closes any open indexes associated with this data file.
deleteIndexes | if TRUE, the indexes (xbIndex instances) will also be deleted (index files will not be deleted) |
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_NOT_OPEN | File was not open |
Create the dbf file.
This method attempts to create the DBF file with the specified name (TableName) and schema (xbSchema s). The OverLay switch is used to determine if an existing file should be overwritten or an error flagged if the file already exists. The record buffer is blanked (set to spaces).
TableName | name of the table | ||||||
s | xbSchema | ||||||
Overlay | One of the following:
|
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_FILE_EXISTS | If the file exists and OverLay is XB_DONTOVERLAY |
XB_OPEN_ERROR | Couldn't open the file |
XB_NO_MEMORY | Memory allocation error |
XB_WRITE_ERROR | Couldn't write to disk |
|
inline |
Delete all records.
xbShort xbDbf::DeleteRecord | ( | ) |
Delete the current record.
Marks the current record as deleted or if "real" deletes are turned on (xbDbf::RealDeleteOn()) will delete the record and add it to the free record list. Normal dBase behavior is to simply mark the record as deleted; the record will actually be deleted when the the DBF file "packed" (xbDbf::PackDatabase()). If "real" deletes are not on, a record may be undeleted using xbDbf::UndeleteRecord().
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_INVALID_RECORD | Invalid record number |
Dump record.
Dump the contents of the specified record to stdout.
RecNo | Record number of record to be dumped. |
|
inline |
|
inline |
Return number of fields.
void xbDbf::Flush | ( | ) |
|
inline |
Return whether or not autolocking is on or off.
|
inline |
Return current record number.
|
inline |
Return Dbf name.
|
inline |
Return status.
xbDouble xbDbf::GetDoubleField | ( | const char * | FieldName | ) |
Get the double value of the specified field.
Get the double value of the specified field.
|
virtual |
Implements xbFile.
const char * xbDbf::GetField | ( | xbShort | FieldNo | ) | const |
Get the value of the specified field.
Returns the value of the field specified by FieldNo.
FieldNo | Number of field. |
const char * xbDbf::GetField | ( | const char * | Name | ) | const |
Get the value of the specified field.
Returns the value of the field specified by Name.
Name | Name of field. |
Get the value of the specified field.
Get the value of the field specified by FieldNo and place its value in buf.
FieldNo | Number of field. |
buf | Buffer to hold field value. Must be large enough to hold the entire field value. Use GetFieldLen() to determine the length of the field, if necessary. |
RecBufSw |
xbShort xbDbf::GetField | ( | const char * | Name, |
char * | buf | ||
) | const |
Get the value of the specified field.
Get the value of the field specified by Name and place its value in buf.
Name | Name of field. |
buf | Buffer to hold field value. Must be large enough to hold the entire field value. Use GetFieldLen() to determine the length of the field, if necessary. |
Get the value of the specified field.
Get the value of the field referenced by Name and place its value in buf.
Name | Name of field. |
buf | Buffer to hold field value. Must be large enough to hold the entire field value. Use GetFieldLen() to determine the length of the field, if necessary. |
RecBufSw |
Returns the number of decimals in the specified field.
Returns the number of decimals in the field specified by FieldNo.
FieldNo | Number of field. |
Returns the length of the specified field.
Returns the length of the field specified by FieldNo.
FieldNo | Number of field. |
char * xbDbf::GetFieldName | ( | xbShort | FieldNo | ) |
Returns the name of the specified field.
Returns a pointer to the name for the field specified by FieldNo.
FieldNo | Number of field. |
xbShort xbDbf::GetFieldNo | ( | const char * | name | ) | const |
Returns the field number of the specified field.
Returns the field number for the named field.
name | Name of field. |
char xbDbf::GetFieldType | ( | xbShort | FieldNo | ) | const |
Returns the type of the specified field.
Returns the type of the field specified by FieldNo.
FieldNo | Number of field. |
xbShort xbDbf::GetFirstRecord | ( | ) |
Get the first physical record in the data file.
Attempts to retrieve the first physical record from the data file into the record buffer.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_SEEK_ERROR | Error seeking file |
XB_WRITE_ERROR | Error writing to file |
xbFloat xbDbf::GetFloatField | ( | const char * | FieldName | ) |
Get the float value of the specified field.
xbShort xbDbf::GetLastRecord | ( | ) |
Get the last phyiscal record in the data file.
Attempts to retrieve the last physical record from the data file into the record buffer.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_EOF | At end of file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_SEEK_ERROR | Error seeking file |
XB_WRITE_ERROR | Error writing to file |
xbShort xbDbf::GetLogicalField | ( | const char * | FieldName | ) |
Get the logical value of the specified field.
xbLong xbDbf::GetLongField | ( | const char * | FieldName | ) | const |
Get the long value of the specified field.
Get the long value of the specified field.
xbShort xbDbf::GetNextRecord | ( | ) |
Get the next physical record in the data file.
Attempts to retrieve the next physical record from the data file into the record buffer.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_EOF | At end of file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_SEEK_ERROR | Error seeking file |
XB_WRITE_ERROR | Error writing to file |
xbShort xbDbf::GetPrevRecord | ( | ) |
Get the previous physical record in the data file.
Attempts to retrieve the previous physical record from the data file into the record buffer.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_BOF | At beginning of file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_SEEK_ERROR | Error seeking file |
XB_WRITE_ERROR | Error writing to file |
Get the raw value of the specified field.
xbShort xbDbf::GetRawField | ( | const char * | Name, |
char * | buf | ||
) | const |
Get the raw value of the specified field.
Get the value of the field specified by Name and place its value in buf.
Name | Name of field. |
buf | Buffer to hold field value. Must be large enough to hold the entire field value. Use GetFieldLen() to determine the length of the field, if necessary. |
|
inline |
Return whether "real" deletes are on or off.
Use this to determine if "real deletes" are being used with the database.
|
inline |
Get a record from the data file.
This method attempts to retrieve the record specified by RecNo from the data file into the record buffer.
RecNo | Record number to retrieve |
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_WRITE_ERROR | Error writing to file |
|
inline |
Return a pointer to the record buffer.
|
inline |
Return record length.
char * xbDbf::GetStringField | ( | xbShort | FieldNo | ) |
Get the string value of the specified field.
char * xbDbf::GetStringField | ( | const char * | FieldName | ) |
Get the string value of the specified field.
Determine if file name suffix is missing.
Internal use only.
xbLong xbDbf::NoOfRecords | ( | ) |
Remove an index from the list.
Gets the number of records in the data file
xbShort xbDbf::OpenDatabase | ( | const char * | TableName | ) |
Dump header information.
Option | One of the following:
|
This method attempts to open the DBF file with the specified name (TableName). This method does not position to any particular record in the file. The record buffer is blanked (set to spaces).
TableName | Name of table to open |
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_OPEN_ERROR | Couldn't open file |
XB_NO_MEMORY | Memory allocation error |
XB_NOT_XBASE | Not an DBF file |
xbShort xbDbf::PackDatabase | ( | xbShort | LockWaitOption, |
void(*)(xbLong itemNum, xbLong numItems) | packStatusFunc = 0 , |
||
void(*)(xbLong itemNum, xbLong numItems) | indexStatusFunc = 0 |
||
) |
Pack the database.
This method removes all records marked for deletion from an Xbase (.DBF) file, reindexes any open index files, and also reorganizes any memo fields stored in a .DBT memo file.
packStatusFunc | status function | ||||||
indexStatusFunc | index status function | ||||||
LockWaitOption | One of the following:
|
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_CLOSE_ERROR | Unable to close intermediate work file |
XB_OPEN_ERROR | Could not open file |
XB_NO_MEMORY | Memory allocation error |
XB_WRITE_ERROR | Couldn't write to disk |
XB_SEEK_ERROR | Error seeking file |
XB_LOCK_FAILED | Unable to lock file or index |
xbLong xbDbf::PhysicalNoOfRecords | ( | ) |
Get the physical number of records in the data file.
Put a double value into the specified field.
Put a double value into the specified field.
xbShort xbDbf::PutField | ( | const char * | Name, |
const char * | buf | ||
) |
Put a value into the specified field.
Put a float value into the specified field.
Put a float value into the specified field.
Put a long value into the specified field.
Put a long value into the specified field.
Put a raw value into the specified field.
xbShort xbDbf::PutRawField | ( | const char * | Name, |
const char * | buf | ||
) |
Put a raw value into the specified field.
xbShort xbDbf::PutRecord | ( | ) |
Write the current record buffer to the current record in the data file.
Attempts to write the contents of the record buffer to the current record in the data file. Updates any open indexes.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_SEEK_ERROR | Error seeking file |
XB_WRITE_ERROR | Error writing to file |
Write the current record buffer to the specified record in the data file.
Attempts to write the contents of the record buffer to the record specified by RecNo. Updates any open indexes.
RecNo | Record number to which data should be written |
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_LOCK_FAILED | Couldn't lock file |
XB_NOT_OPEN | File is not open |
XB_INVALID_RECORD | Invalid record number |
XB_SEEK_ERROR | Error seeking file |
XB_WRITE_ERROR | Error writing to file |
|
inline |
Turn off "real" deletes
|
inline |
Turn on "real" deletes.
This should be done before creating a database (with xbDbf::CreateDatatabase()) and thereafter before opening a database with xbDbfCreateDatabase().
You cannot "turn on" real deletes once a database has been created and records added.
Add index to list.
Adds the specified index to the list of indexes maintained by the dbf.
n | index to add |
IndexName | name of indexRebuild all index files |
xbShort xbDbf::RecordDeleted | ( | ) |
Determine if current record is deleted.
|
inline |
Set number of records to zero????
Set dbase version for the dbf file.
Set dbase version. Should only be used before creating a database with xbDbf::CreateDatabase().
v | version, either 3 or 4. |
|
inline |
Undelete all records.
xbShort xbDbf::UndeleteRecord | ( | ) |
Undelete the current record.
Marks the currect record as not deleted (i.e. removes the flag indicating the record is deleted). This method may not be used (and will return an error code) if "real" deletes are on.
Return Code | Description |
---|---|
XB_NO_ERROR | No error |
XB_INVALID_RECORD | Invalid record number |
xbShort xbDbf::ValidLogicalData | ( | const char * | buf | ) |
Determines if data is valid logical data.
Determines if the data in buf is valid for a logical field value.
buf | data to be tested |
xbShort xbDbf::ValidNumericData | ( | const char * | buf | ) |
Determines if data is valid numeric data.
Determines if the data in buf is valid for a numeric field value.
buf |
xbXBase* xbDbf::xbase |