home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / bfast.zip / BTRIEVE.HPP < prev    next >
C/C++ Source or Header  |  1992-03-18  |  6KB  |  172 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 60
  55. #define MAX_FIELD_LENGTH 256
  56. //
  57. // intend to be used for creating file
  58. //
  59. typedef struct
  60. {
  61.     int recordLength;
  62.     int pageSize;
  63.     int indexNo;
  64.     long recordCount;
  65.     int fileFlag;
  66.     int reserved;
  67.     int allocation;
  68. }FileSpecs;
  69.  
  70. typedef struct
  71. {
  72.     int keyPostition;
  73.     int keyLength;
  74.     int keyFlag;
  75.     long keyCount;
  76.     char extendKeyType;
  77.     char nullValue;
  78.     char reserved[4];
  79. } KeySpecs;
  80.  
  81. //-----------class Btrieve----------------------------------------
  82.  
  83. class Btrieve :public Rdbms,public FIELD
  84. {
  85. public:
  86.     Btrieve(char* path, char *filename,Field xfld[],int fldNo,int keyNo=0);
  87.     ~Btrieve();
  88.  
  89.     virtual int KeyLength(int keyNo)                ;
  90.     virtual int KeyLength(void)                ;
  91.     virtual int IndexNo(void)                       ;
  92.     virtual int UseIndex(int key=0)                   ;
  93.     virtual int ActiveIndex()                   ;
  94.     virtual char* KeyValue()                        ;
  95.     virtual int DataLen(void)                       ;
  96.     virtual int Open(void)                          ;
  97.     virtual int Close(void)                         ;
  98.     virtual int Bof(void)                           ;
  99.     virtual int Eof(void)                           ;
  100.     virtual int Empty(void)                         ;
  101.     virtual int Unlock(void)                        ;
  102.     virtual int Lock(void)                          ;
  103.  
  104.     virtual int GetFirst(int lock=0)                      ;
  105.     virtual int GetEqual(char* keyvalue, int lock=0)            ;
  106.     virtual int GetLast(int lock=0)                       ;
  107.     virtual int GetNext(int lock=0)                       ;
  108.     virtual int GetPrev(int lock=0)                       ;
  109.     virtual int GetGEqual(char* keyvalue, int lock=0)           ;
  110.     virtual int GetGreater(char* keyvalue, int lock=0)          ;
  111.     virtual long GetPost(int lock=0)                       ;
  112.     
  113.     virtual int GoTo(long,int lock=0)                     ;
  114.     
  115.     virtual int StepFirst(int lock=0)                     ;
  116.     virtual int StepLast(int lock=0)                      ;
  117.     virtual int StepNext(int lock=0)                      ;
  118.     virtual int StepPrev(int lock=0)                      ;
  119.                              
  120.     virtual int Rewrite(void)                        ; 
  121.     virtual int Write(void)                        ; 
  122.     virtual int Delete(void)                        ; 
  123.     virtual char* FileName(void)                    ;
  124.     virtual char* Path(void)                        ;
  125.     virtual int Err(void)                     ;
  126.  
  127.     virtual int fReplace(int ,char *  )                    ;
  128.     virtual int fReplace(int ,int  )                    ;
  129.     virtual int fReplace(int ,long )                    ;
  130.     virtual int fReplace(int ,float)                    ;
  131.     virtual int fReplace(int ,double)                    ;
  132.  
  133.     virtual int fReplace(char* ,char *  )                    ;
  134.     virtual int fReplace(char*,int  )                    ;
  135.     virtual int fReplace(char*,long )                    ;
  136.     virtual int fReplace(char*,float)                    ;
  137.     virtual int fReplace(char*,double)                    ;
  138.  
  139.     //-----------------------------------------------------------
  140.     // note that these field function are using the same buffer
  141.     // thus you cannot use something like this
  142.     // cout << f30.fStr(0) << f30.fStr(1);
  143.     //-----------------------------------------------------------
  144.     virtual char* fStr(char * str, const char *ptemplate="%s")                    ;
  145.     virtual char   fChar(char *  )                    ;
  146.     virtual int   fInt(char *  )                    ;
  147.     virtual long  fLong(char * )                    ;
  148.     virtual float fFloat(char *)                    ;
  149.     virtual double  fDouble(char *)                  ;
  150.  
  151.     virtual char* fStr(int i=0, const char *ptemplate="%s")                    ;
  152.     virtual char   fChar(int)                    ;
  153.     virtual int   fInt(int)                    ;
  154.     virtual long  fLong(int)                    ;
  155.     virtual float fFloat(int)                    ;
  156.     virtual double  fDouble(int)                  ;
  157. public:
  158.     int errorcode;
  159. protected:
  160.     char *fhd;
  161.     char *data;
  162.     int dataonly;               // indicate if the file is a data only file
  163.     int datalen;
  164.     int kLen[MAX_INDEX_KEY];    // store the key length
  165.     int kIndex; // No. of Index key
  166.     int kUsed;
  167.     char *kValue;
  168.     long lpost;     // physical position
  169.     int RecChanged; // if record is changed
  170. };
  171.  
  172.