home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cslio205.zip / INCLUDE / CSIBASE.H < prev    next >
C/C++ Source or Header  |  1997-01-21  |  3KB  |  119 lines

  1. /***********************************************************************
  2.  
  3.                       CSDB Library, Free Evaluation Version 2.0.5 
  4.                                        Release: January 22th 1997 
  5.  
  6.        Header file of the IBASE class.
  7.        Database class for fixed length records.
  8.  
  9.                                            Copyright(c) 1994-1997 
  10.                                                           ComBits 
  11.                                                   The Netherlands 
  12. ***********************************************************************/
  13.  
  14. #ifndef __CSIBASE_H
  15. #define __CSIBASE_H
  16.  
  17. #include <csdir.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "csdlay.h"
  21.  
  22.  
  23. class IBASE: public DLAY
  24. {
  25.  
  26. protected:
  27.  
  28.    U16  lenrec;
  29.    U16  recpage;
  30.    U16  rec_foot;
  31.    U16  len_rec_plus_foot;
  32.    S32  NUMREC;
  33.    S32  lrco;
  34.    S32  wrco;
  35.    S32  rrco;
  36.    S32  cur_rec;
  37.  
  38.  
  39. protected:
  40.  
  41.    void check_rec(S32  l);
  42.  
  43.    S32  r2p(S32  rec)    { return (1+(rec-1)*len_rec_plus_foot); }
  44.  
  45.    virtual int check_id(U32 id);
  46.    virtual void set_id(void);
  47.  
  48.    void init_defaults(void);
  49.    void init_vars(void);
  50.    void vars2head(void);
  51.    void head2vars(void);
  52.  
  53. ////////////////////////////////////////////////////////////////////////
  54. ////////////////////// PUBLIC FUNCTIONS ////////////////////////////////
  55. ////////////////////////////////////////////////////////////////////////
  56.  
  57. public:
  58.    IBASE(void);
  59.    virtual
  60.   ~IBASE(void);
  61.  
  62.  
  63. //////////////////////// Compatibility functions ////////////////////////
  64.    void speed_option_121(void)   { smallest_page(); }
  65.    void smallest_page(void)      {}
  66.    U16  lengthrec(void)          { return length_rec(); }
  67.  
  68.  
  69. //////////////////////// Definition //////////////////////////////////////////
  70.    int  define(csCHAR *name,U16  reclen);
  71.  
  72. //////////////////////// Open & Close ////////////////////////////////////////
  73.    int  open(csCHAR *name,S16 kb=32);
  74.    int  open(void)                 { return already_open(); }
  75.    int  close(void);
  76.    int  save(void);
  77.  
  78. //////////////////////// Read & Writes records  //////////////////////////////
  79.    void read_rec(  S32  rec, void *d);
  80.    void write_rec( S32  rec, void *d);
  81.  
  82. //////////////////////// Add Records /////////////////////////////////////////
  83.    S32  append_rec(void *data);
  84.    S32  append_rec(void);
  85.  
  86. ////////////////////////// Inserting ///////////////////////////////////////////
  87.    int insert_rec_b(S32  r,void *p);  // Before 'r'
  88.    int insert_rec_a(S32  r,void *p);  // After  'r'
  89.  
  90. ////////////////////////// Deleting ////////////////////////////////////////////
  91.    void delet(S32  r);
  92.  
  93. //////////////////////// Number of Records ///////////////////////////////////
  94.    S32  numrec(void)      { return NUMREC; }
  95.  
  96. ////////////////////////// Record Length ///////////////////////////////////////
  97.    U16  length_rec(void)   { return lenrec; }
  98.  
  99. //////////////////////// Report Writing //////////////////////////////////////
  100.    int  report(csCHAR *name,int sub=1);
  101.    void report(FILE *fipo,int sub);
  102.  
  103. ////////////////////////// Miscellaneous ///////////////////////////////////////
  104. /* Inherited
  105.    int  background(void)
  106. */
  107.  
  108.    int pack(void);
  109.    int zap(void);
  110.    void info(void);
  111.    int empty(void);
  112.    virtual int class_ID(void)  { return CS_CLID_IBASE; }
  113.  
  114.  
  115.  
  116. };
  117.  
  118. #endif
  119.