// The following file is the Foxpro.h file
#ifndef _FOXPRO_20110811_H_
#define _FOXPRO_20110811_H_
// Database header
struct FOXPRO_HEAD
{
BYTE byFlags;
BYTE byYear;
BYTE byMonth;
BYTE byDay;
DWORD dwRecordCount;
WORD wRecordAddress;
WORD wRecordLength;
DWORD dwReserve1;
DWORD dwReserve2;
DWORD dwReserve3;
DWORD dwReserve4;
DWORD dwReserve5;
};
// Database "field" attributes
struct FOXPRO_FIELDS
{
BYTE strName[10];
BYTE byFill;
BYTE byStyle;
DWORD dwDataAddress;
BYTE byLength;
BYTE byDotCount;
WORD wReserve1;
BYTE byFlags;
BYTE wsReserve[11];
};
// Database "class" definition
class CFoxpro
{
private:
BOOL m_bNew;
long m_lRecordPoint;
char m_strFile[256];
FOXPRO_HEAD m_FoxproHead;
FOXPRO_FIELDS m_FoxproFields;
FILE* m_pFile;
BYTE* m_pRecordBuf;
FOXPRO_FIELDS* m_pFoxproFields;
public:
// Create a new database
BOOL CreateFoxpro(const char*pStr);
// Open an existing database
BOOL OpenFoxpro(const char*pStr);
// Close the database
BOOL CloseFoxpro();
// Add a field
BOOL AddFields(const char* strName,BYTE byStyle,int nLength,int nDot);
// Get the "field" attributes of the specified column
FOXPRO_FIELDS* GetFoxproFields(int nIndex);
public:
// Get the number of columns
int GetFieldsCount() {return(m_FoxproHead.wRecordAddress-sizeof(FOXPRO_HEAD))/sizeof(FOXPRO_FIELDS);}
// Get the total number of records
long GetRecordCount() {return(m_FoxproHead.dwRecordCount);}
// Get the record address
long GetRecordAddress() {return((DWORD)m_FoxproHead.wRecordAddress);}
// Get the last modification date of the database - "month"
int GetMonth() {return((int)m_FoxproHead.byMonth);}
// Get the last modification date of the database - "day"
int GetDay() {return((int)m_FoxproHead.byDay);}
// Get the last modification date of the database - "year"
int GetYear() {return((int)1900+(DWORD)m_FoxproHead.byYear);}
// Get the length of the record
int GetRecordLength(){return((int)(DWORD)m_FoxproHead.wRecordLength);}
// Display database debugging information
void Debug();
public:
// Trim leading spaces of the specified string
static char* TrimLeft(char *pStr);
// Trim trailing spaces of the specified string
static char* TrimRight(char *pStr);
public:
// Set the string of the string type "field"
BOOL SetFieldsString(int nIndex, const char* pStr);
// Set the numeric value of the numeric type "field"
BOOL SetFieldsNumber(int nIndex,float fValue);
// Set the date value of the date type "field"
BOOL SetFieldsDate(int nIndex,int nYear,int nMonth,int nDay);
// Set the logical value of the logical type "field"
BOOL SetFieldsLogic(int nIndex,BOOL bLogic);
// Set the memo value of the memo type "field"
BOOL SetFieldsMemo(int nIndex, const char* pStr);
// Get the string of the string type "field"
BOOL GetFieldsString(int nIndex,char* pStr);
// Get the numeric value of the numeric type "field"
float GetFieldsNumber(int nIndex);
// Get the date value of the date type "field"
BOOL GetFieldsDate(int nIndex,int* pnYear,int* pnMonth,int* pnDay);
// Get the logical value of the logical type "field"
BOOL GetFieldsLogic(int nIndex);
// Get the memo value of the memo type "field"
BOOL GetFieldsMemo(int nIndex,char* pStr);
// Locate the record
BOOL Seek(long nIndex,int nMode);
// Determine if the database is already open
BOOL IsOpen();
// Refresh the database to disk
BOOL Flush();
// Add a new record
BOOL AddNew();
// Prepare to modify the current record
BOOL Edit();
// Make the current changes effective
BOOL Update();
// Insert a record in the current record
BOOL Insert();
// Delete the current record (with delete mark)
BOOL Delete();
// Delete the current record
BOOL DeleteEx();
// Delete records with delete criteria
BOOL Zap();
public:
void CoFoxpro();// Called by the constructor
// Constructor
CFoxpro();
// Constructor (open the specified database)
CFoxpro(char* strFile);
// Destructor
~CFoxpro();
};
#endif
#ifndef _FOXPRO_20110811_H_
#define _FOXPRO_20110811_H_
// Database header
struct FOXPRO_HEAD
{
BYTE byFlags;
BYTE byYear;
BYTE byMonth;
BYTE byDay;
DWORD dwRecordCount;
WORD wRecordAddress;
WORD wRecordLength;
DWORD dwReserve1;
DWORD dwReserve2;
DWORD dwReserve3;
DWORD dwReserve4;
DWORD dwReserve5;
};
// Database "field" attributes
struct FOXPRO_FIELDS
{
BYTE strName[10];
BYTE byFill;
BYTE byStyle;
DWORD dwDataAddress;
BYTE byLength;
BYTE byDotCount;
WORD wReserve1;
BYTE byFlags;
BYTE wsReserve[11];
};
// Database "class" definition
class CFoxpro
{
private:
BOOL m_bNew;
long m_lRecordPoint;
char m_strFile[256];
FOXPRO_HEAD m_FoxproHead;
FOXPRO_FIELDS m_FoxproFields;
FILE* m_pFile;
BYTE* m_pRecordBuf;
FOXPRO_FIELDS* m_pFoxproFields;
public:
// Create a new database
BOOL CreateFoxpro(const char*pStr);
// Open an existing database
BOOL OpenFoxpro(const char*pStr);
// Close the database
BOOL CloseFoxpro();
// Add a field
BOOL AddFields(const char* strName,BYTE byStyle,int nLength,int nDot);
// Get the "field" attributes of the specified column
FOXPRO_FIELDS* GetFoxproFields(int nIndex);
public:
// Get the number of columns
int GetFieldsCount() {return(m_FoxproHead.wRecordAddress-sizeof(FOXPRO_HEAD))/sizeof(FOXPRO_FIELDS);}
// Get the total number of records
long GetRecordCount() {return(m_FoxproHead.dwRecordCount);}
// Get the record address
long GetRecordAddress() {return((DWORD)m_FoxproHead.wRecordAddress);}
// Get the last modification date of the database - "month"
int GetMonth() {return((int)m_FoxproHead.byMonth);}
// Get the last modification date of the database - "day"
int GetDay() {return((int)m_FoxproHead.byDay);}
// Get the last modification date of the database - "year"
int GetYear() {return((int)1900+(DWORD)m_FoxproHead.byYear);}
// Get the length of the record
int GetRecordLength(){return((int)(DWORD)m_FoxproHead.wRecordLength);}
// Display database debugging information
void Debug();
public:
// Trim leading spaces of the specified string
static char* TrimLeft(char *pStr);
// Trim trailing spaces of the specified string
static char* TrimRight(char *pStr);
public:
// Set the string of the string type "field"
BOOL SetFieldsString(int nIndex, const char* pStr);
// Set the numeric value of the numeric type "field"
BOOL SetFieldsNumber(int nIndex,float fValue);
// Set the date value of the date type "field"
BOOL SetFieldsDate(int nIndex,int nYear,int nMonth,int nDay);
// Set the logical value of the logical type "field"
BOOL SetFieldsLogic(int nIndex,BOOL bLogic);
// Set the memo value of the memo type "field"
BOOL SetFieldsMemo(int nIndex, const char* pStr);
// Get the string of the string type "field"
BOOL GetFieldsString(int nIndex,char* pStr);
// Get the numeric value of the numeric type "field"
float GetFieldsNumber(int nIndex);
// Get the date value of the date type "field"
BOOL GetFieldsDate(int nIndex,int* pnYear,int* pnMonth,int* pnDay);
// Get the logical value of the logical type "field"
BOOL GetFieldsLogic(int nIndex);
// Get the memo value of the memo type "field"
BOOL GetFieldsMemo(int nIndex,char* pStr);
// Locate the record
BOOL Seek(long nIndex,int nMode);
// Determine if the database is already open
BOOL IsOpen();
// Refresh the database to disk
BOOL Flush();
// Add a new record
BOOL AddNew();
// Prepare to modify the current record
BOOL Edit();
// Make the current changes effective
BOOL Update();
// Insert a record in the current record
BOOL Insert();
// Delete the current record (with delete mark)
BOOL Delete();
// Delete the current record
BOOL DeleteEx();
// Delete records with delete criteria
BOOL Zap();
public:
void CoFoxpro();// Called by the constructor
// Constructor
CFoxpro();
// Constructor (open the specified database)
CFoxpro(char* strFile);
// Destructor
~CFoxpro();
};
#endif
