home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / database / bfast / btrieve.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-13  |  5.9 KB  |  171 lines

  1. //----File Summary--------------------------------------
  2. // File Name: btrieve.hpp
  3. //
  4. // class defined -> Btrieve
  5. // public member -> 
  6. // public data   -> 
  7. //
  8. //----End-----------------------------------------------
  9. #ifndef CL__BTRIEVE
  10. #define CL__BTRIEVE
  11. #endif
  12.  
  13. #ifndef __STDIO_H
  14. #include <stdio.h>
  15. #endif
  16. #ifndef __STRING_H
  17. #include <string.h>
  18. #endif
  19.  
  20. #ifndef CL__RDBMS
  21. #include "rdbms.hpp"
  22. #endif
  23.  
  24. #ifndef CL__FIELD
  25. #include "field.hpp"
  26. #endif
  27.  
  28. #define     GET_POST          22
  29. #define     GET_DIRECT          23
  30. #define     GET_EQUAL             5+200
  31. #define     GET_NEXT              6+200
  32. #define     GET_PREV              7+200
  33. #define     GET_GREATER           8+200
  34. #define     GET_GREATER_EQUAL     9+200
  35. #define     GET_LESS              10+200
  36. #define     GET_LESS_EQUAL        11+200
  37. #define     GET_FIRST         12+200
  38. #define     GET_LAST           13+200
  39. #define     STEP_FIRST          33+200
  40. #define     STEP_LAST          34+200
  41. #define     STEP_NEXT          24+200
  42. #define     STEP_PREV          35+200
  43. #define     KEY0                  0
  44. #define     KEY1                  1
  45. #define     KEY2                  2
  46. #define     NOKEY        0
  47. #define     UNLOCK      27
  48. #define     REWRITE     3
  49. #define     ADDNEW      2
  50. #define     DELETE      4
  51. #define     LOCK        1
  52.  
  53. #define MAX_INDEX_KEY 20
  54. #define MAX_KEY_LENGTH 256
  55. #define MAX_FIELD_LENGTH 256
  56.  
  57. typedef struct                   // defined in bcreate.h
  58. {
  59.     int recordLength;
  60.     int pageSize;
  61.     int indexNo;
  62.     long recordCount;
  63.     int fileFlag;
  64.     int reserved;
  65.     int allocation;
  66. }FileSpecs;
  67.  
  68. typedef struct
  69. {
  70.     int keyPostition;
  71.     int keyLength;
  72.     int keyFlag;
  73.     long keyCount;
  74.     char extendKeyType;
  75.     char nullValue;
  76.     char reserved[4];
  77. } KeySpecs;
  78.  
  79. //-----------class Btrieve----------------------------------------
  80.  
  81. class Btrieve :public Rdbms,public FIELD
  82. {
  83. public:
  84.     Btrieve(char* path, char *filename,Field xfld[],int fldNo,int keyNo=0);
  85.     ~Btrieve();
  86.  
  87.     virtual long RecCount()                         ;
  88.     virtual int KeyLength(int keyNo)                ;
  89.     virtual int KeyLength(void)                     ;
  90.     virtual int IndexNo(void)                       ;
  91.     virtual int UseIndex(int key=0)                 ;
  92.     virtual int ActiveIndex()                       ;
  93.     virtual char* KeyValue()                        ;
  94.     virtual int DataLen(void)                       ;
  95.     virtual int Open(void)                          ;
  96.     virtual int Close(void)                         ;
  97.     virtual int Bof(void)                           ;
  98.     virtual int Eof(void)                           ;
  99.     virtual int Empty(void)                         ;
  100.     virtual int Unlock(void)                        ;
  101.     virtual int Lock(void)                          ;
  102.  
  103.     virtual int GetFirst(int lock=0)                      ;
  104.     virtual int GetEqual(char* keyvalue, int lock=0)            ;
  105.     virtual int GetLast(int lock=0)                       ;
  106.     virtual int GetNext(int lock=0)                       ;
  107.     virtual int GetPrev(int lock=0)                       ;
  108.     virtual int GetGEqual(char* keyvalue, int lock=0)           ;
  109.     virtual int GetGreater(char* keyvalue, int lock=0)          ;
  110.     virtual long GetPost(int lock=0)                       ;
  111.     
  112.     virtual int GoTo(long,int lock=0)                     ;
  113.     
  114.     virtual int StepFirst(int lock=0)                     ;
  115.     virtual int StepLast(int lock=0)                      ;
  116.     virtual int StepNext(int lock=0)                      ;
  117.     virtual int StepPrev(int lock=0)                      ;
  118.                              
  119.     virtual int Rewrite(void)                        ; 
  120.     virtual int Write(void)                        ; 
  121.     virtual int Delete(void)                        ; 
  122.     virtual char* FileName(void)                    ;
  123.     virtual char* Path(void)                        ;
  124.     virtual int Err(void)                     ;
  125.  
  126.     virtual int fReplace(int ,char *  )                    ;
  127.     virtual int fReplace(int ,int  )                    ;
  128.     virtual int fReplace(int ,long )                    ;
  129.     virtual int fReplace(int ,float)                    ;
  130.     virtual int fReplace(int ,double)                    ;
  131.  
  132.     virtual int fReplace(char* ,char *  )                    ;
  133.     virtual int fReplace(char*,int  )                    ;
  134.     virtual int fReplace(char*,long )                    ;
  135.     virtual int fReplace(char*,float)                    ;
  136.     virtual int fReplace(char*,double)                    ;
  137.  
  138.     //-----------------------------------------------------------
  139.     // note that these field function are using the same buffer
  140.     // thus you cannot use something like this
  141.     // cout << f30.fStr(0) << f30.fStr(1);
  142.     //-----------------------------------------------------------
  143.     virtual char* fStr(char * str, const char *ptemplate="%s")                    ;
  144.     virtual char   fChar(char *  )                    ;
  145.     virtual int   fInt(char *  )                    ;
  146.     virtual long  fLong(char * )                    ;
  147.     virtual float fFloat(char *)                    ;
  148.     virtual double  fDouble(char *)                  ;
  149.  
  150.     virtual char* fStr(int i=0, const char *ptemplate="%s")                    ;
  151.     virtual char   fChar(int)                    ;
  152.     virtual int   fInt(int)                    ;
  153.     virtual long  fLong(int)                    ;
  154.     virtual float fFloat(int)                    ;
  155.     virtual double  fDouble(int)                  ;
  156. public:
  157.     int errorcode;
  158. protected:
  159.     char *fhd;
  160.     char *data;
  161.     int dataonly;               // indicate if the file is a data only file
  162.     int datalen;
  163.     int kLen[MAX_INDEX_KEY];    // store the key length
  164.     int kIndex; // No. of Index key
  165.     int kUsed;
  166.     char *kValue;
  167.     long lpost;     // physical position
  168.     int RecChanged; // if record is changed
  169. };
  170.  
  171.