home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / todb101 / todb / lib / schema.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-03  |  3.9 KB  |  171 lines

  1. // ========================================================================
  2. //  TODB LIBRARY
  3. //    schema.h
  4. //
  5. //    Schema
  6. //
  7. //    Version: see TODB.H file
  8. //
  9. //    Copyright 1993 Christian Thérien
  10. //    All rights reserved
  11. // ========================================================================
  12.  
  13. #ifndef _SCHEMA_H
  14. #define _SCHEMA_H
  15.  
  16. #include "todb.h"
  17. #include "icoll.h"
  18. #include "kspersis.h"
  19.  
  20. extern Boolean LoadBibNote( char * fn );
  21. Boolean DeleteBibNote( char * fn );
  22. extern TODB * ksDB;
  23.  
  24. //-------------------------------------------------------------------------
  25. // MakeTokenUW class
  26. //     "Upper case Word" token generator
  27. //-------------------------------------------------------------------------
  28.  
  29. class MakeTokenUW : public MakeToken
  30. {
  31. public:
  32.     MakeTokenUW();
  33.     ~MakeTokenUW();
  34.     void Put( const char * s );
  35.     int First( char * token );
  36.     int Next( char * token );
  37.  
  38. private:
  39.     char * buf_;
  40.     char * postoken_;
  41.     int length_;
  42.  
  43.     int AcceptToken( char * token );
  44. };
  45.  
  46. inline MakeTokenUW::~MakeTokenUW()
  47. {
  48.     delete [] buf_;
  49. }
  50.  
  51. //-------------------------------------------------------------------------
  52. // Persistent classes identification (cid)
  53. //-------------------------------------------------------------------------
  54.  
  55. enum ClassId
  56. {
  57.     // Count class identification
  58.     COUNT,
  59.     // BibNote class identification
  60.     BIBNOTE
  61. };
  62.  
  63. //-------------------------------------------------------------------------
  64. // Indexes identification (idxid)
  65. //-------------------------------------------------------------------------
  66.  
  67. // BibNote class
  68. enum BibNote_idxid
  69. {
  70.     AUTHOR,        // index field
  71.     DATE,
  72.     KEYWORDS,
  73.     PUBLISHER,
  74.     PUB_PLACE,
  75.  
  76. // common indexes identification
  77.     TITLES,        // index identification (idxid) for
  78.             // common indexation of
  79.             // title and article_title
  80.     SUBTITLES        // index identification for
  81.             // common indexation of
  82.             // subtitle and article_subtitle
  83. };
  84.  
  85. //-------------------------------------------------------------------------
  86. // Count class
  87. //-------------------------------------------------------------------------
  88. // Only one instance of this class is placed at the beginning of the file.
  89. // This instance keeps the state of a counter.    This counter is used as a
  90. // single (primary or auxiliary) key generator (RECORD-ID generator).
  91.  
  92. class Count : public KSPersistent
  93. {
  94. public:
  95.     Count();
  96.     Count( KeyType countno );
  97.     ~Count();
  98.  
  99.     KeyType CNote();
  100.     void SetCNote( KeyType cn );
  101.     KeyType IncCNote();
  102.     void SetVersion( String & vs );
  103.     Boolean Dirty();
  104.     void SetDirty();
  105.     void ResetDirty();
  106.  
  107. private:
  108.     String version_;
  109.     unsigned int dirty_;
  110.     KeyType cnote_;
  111.  
  112.     void Read();
  113.     void Write();
  114. };
  115.  
  116. inline KeyType Count::CNote()
  117. {
  118.     return cnote_;
  119. }
  120.  
  121. inline KeyType Count::IncCNote()
  122. {
  123.     return ++cnote_;
  124. }
  125.  
  126. //-------------------------------------------------------------------------
  127. // BibNote class
  128. //-------------------------------------------------------------------------
  129. // The indexed object!
  130.  
  131. class BibNote : private IdxColl
  132. {
  133. friend Boolean LoadBibNote( char * fn );
  134. friend Boolean DeleteBibNote( char * fn );
  135.  
  136. public:
  137.     BibNote( KeyType nno );
  138.  
  139.     ~BibNote();
  140.  
  141.     void Delete();
  142.  
  143. private:
  144.     KeyType noteno;      // single (primary or auxiliary) key
  145.  
  146.     IdxString author;      // index field; idxid is AUTHOR
  147.     String    shelf_mark; // this field is not indexed
  148.     IdxString date;      // index field; idxid is DATE
  149.     IdxString keywords;   // and so on
  150.     IdxString publisher;
  151.     String    issn;
  152.     String    isbn;
  153.     IdxString publishing_place;
  154.     String    paging;
  155.     IdxString title;
  156.     IdxString subtitle;
  157.     IdxString article_title;
  158.     IdxString article_subtitle;
  159.  
  160.     MakeTokenUW UW_token;
  161.  
  162.     void Index();
  163. };
  164.  
  165. inline BibNote::~BibNote()
  166. {
  167.     SaveIdx();
  168. }
  169.  
  170. #endif    // _SCHEMA_H
  171.