home *** CD-ROM | disk | FTP | other *** search
- // This is a part of the Objective Grid C++ Library.
- // Copyright (C) 1995,1996 ClassWorks, Stefan Hoenig.
- // All rights reserved.
- //
- // This source code is only intended as a supplement to
- // the Objective Grid Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding
- // the Objective Grid product.
- //
-
- // dbfile.h : defines the interface for the CDBaseFile class
-
- #ifndef _DBFILE_H_
- #define _DBFILE_H_
-
- // A note on DBCS/Unicode support.
- //
- // I assume that data in the dbase file are in ANSI/DBCS format.
- // If this application is compiled with _UNICODE switch,
- // data and field names will be converted from single byte chars
- // to wide chars.
-
- class CField
- {
- public:
- enum FieldType {
- charField = 'C',
- dateField = 'D',
- numericField = 'N',
- logicalField = 'L',
- memoField = 'M'
- };
-
- char name[11]; // dbf field names are 10 chars long max.
- // If this application is compiled with _UNICODE switch,
- // the field name will be converted to wide chars
- // when the column header is displayed in the grid.
- char type;
- short len;
- short width;
- short decimals;
- int offset;
- short display_width;
- };
-
- class CDBaseFile
- {
- public:
- CDBaseFile();
- ~CDBaseFile();
-
- BOOL Open(LPCTSTR szFileName, BOOL readOnly = FALSE);
- void Close();
-
- CString sFileName; // sFileName
- FILE* fd; // File handle
- long nRecordCount; // No. of records
- long nCurrentRecord; // Current read record
- int nFieldCount; // No. of fields
- CPtrArray fieldArray; // Array with fields
- char* recordBuf; // buffer for reading records
- // If this application is compiled with _UNICODE switch,
- // the data name will be converted to/from wide chars
- // in the SetValue/GetValue routines (see below).
- BOOL bReadOnly;
- BOOL bWriteFlag;
-
- BOOL Seek(long nRecord);
- void Flush();
- void AddNew();
-
- CField* GetField(int n) const;
-
- BOOL IsDeleted() const;
-
- // DBCS/UNICODE aware versions of SetValue and GetValue
- BOOL SetValue(int n, LPCTSTR s);
- BOOL GetValue(int n, CString& result) const;
-
- int InitFields();
-
- short offset;
- short size;
- };
-
- #endif // _DBFILE_H_
-