home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / todb101 / todb / lib / tindex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-20  |  1.8 KB  |  89 lines

  1. // ========================================================================
  2. //  TODB LIBRARY
  3. //    tindex.h
  4. //
  5. //    TIndex class
  6. //    B-Plus interface
  7. //
  8. //    Version: see TODB.H file
  9. //
  10. //    Copyright 1993 Christian Thérien
  11. //    All rights reserved
  12. // ========================================================================
  13.  
  14. #ifndef _TINDEX_H
  15. #define _TINDEX_H
  16.  
  17. #include "strn.h"
  18. #include "boolean.h"
  19.  
  20. extern "C"
  21. {
  22. #include "bplus.h"
  23. }
  24.  
  25. class ErrReporter;
  26.  
  27. enum DupKeys
  28. {
  29.     NO_DUP,         // duplicate key not allowed (normal state for TODB)
  30.     DUP          // duplicate key allowed
  31. };
  32.  
  33. enum TIndexError
  34. {
  35.     TIE_CLOSED,         // file already closed
  36. };
  37.  
  38. class TIndex
  39. {
  40. public:
  41.     // constructors
  42.     TIndex();
  43.     TIndex( DupKeys dk, String & fn );
  44.  
  45.     // destructor
  46.     ~TIndex();
  47.  
  48.     // index file manipulators
  49.     int OpenExist( DupKeys dk, String & fn );
  50.     int OpenNew( DupKeys dk, String & fn );
  51.     int CloseIndex();
  52.  
  53.     // index operators
  54.     int FindKey( const char * key, RECPOS * addr );
  55.     int LocateKey( char * key, RECPOS    * addr );
  56.     int AddKey( const char * key, RECPOS addr );
  57.     int DeleteKey( const char * key, RECPOS addr );
  58.     int NextKey( char * key, RECPOS * addr );
  59.     void BufferFlush();
  60.  
  61.     // error control
  62.     static void SetErrOut( ErrReporter * er );
  63.  
  64.     // not implemented
  65. #ifdef ALL_TINDEX
  66.     int FirstKey();
  67.     int LastKey();
  68.     int PrevKey();
  69.     int FindExact();
  70. #endif // ALL_TINDEX
  71.  
  72. private:
  73.     IX_DESC pix_;
  74.     ENTRY   ee_;
  75.     String  fname_;
  76.     int     dupKeys_;
  77.     Boolean open_;
  78.  
  79.     //    disable (meaningless for this class)
  80.     TIndex( const TIndex & bp );
  81.     TIndex & operator = ( const TIndex & bp );
  82.  
  83.     // error control
  84.     static ErrReporter * ErrOut;
  85.     static void ErrorHandler( TIndexError err );
  86. };
  87.  
  88. #endif // _TINDEX_H
  89.