00001
00002
00003
00004 #ifndef __ODB_H
00005 #define __ODB_H
00006
00007 #ifndef __OFILE_H
00008 #include <OFILE.H>
00009 #endif
00010
00011
00012
00014 class Database : public File {
00015 private:
00016
00018 struct DbfHeader {
00019 char dbf_id;
00020 char last_update[3];
00021 long last_rec;
00022 unsigned short data_offset;
00023 unsigned short rec_size;
00024 };
00025
00027 struct DbfRec {
00028 char field_name[11];
00029 char field_type;
00030 long dummy[4];
00031 union {
00032 unsigned char_len;
00033 struct {
00034 char len;
00035 char dec;
00036 } num_size;
00037 }len_info;
00038
00039 char filler[14];
00040 };
00041
00042 private:
00043
00044 DbfHeader dbf_header;
00045 char* rec_buf;
00046 long cur_recno;
00047 long last_read_recno;
00048
00049 char* dbf_buf;
00050 char dbf_buf_allocated;
00051
00052 public:
00053
00054 Database(char* =0, int=0);
00055 ~Database();
00056
00057 void open(char*, int=0);
00058 void open_from_buf(char*);
00059
00060 char* read(long=0);
00061 void go(long recNo) { cur_recno=recNo; }
00062 void close();
00063
00064 long rec_count() { return dbf_header.last_rec; }
00065 long recno() { return cur_recno; }
00066 };
00067
00068
00069
00070
00071
00072
00073 #endif