Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
4.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // Class: CWidTable
  7. //
  8. // Purpose: Translation table of wids
  9. //
  10. // History: 28-May-92 KyleP Implemented
  11. // 12-Jun-91 BartoszM Created stub
  12. // 18-Mar-93 AmyA Moved from sort.hxx
  13. // 09-Nov-94 KyleP Added deleted wid detection
  14. //
  15. // Comments: FakeWid (or fake wid) can go from 1 to CI_MAX_DOCS_IN_WORDLIST
  16. //
  17. //----------------------------------------------------------------------------
  18. #pragma once
  19. inline WORKID iDocToFakeWid ( unsigned iDoc )
  20. {
  21. Win4Assert ( iDoc < CI_MAX_DOCS_IN_WORDLIST );
  22. return WORKID (iDoc + 1);
  23. }
  24. inline unsigned FakeWidToIndex ( WORKID fakeWid )
  25. {
  26. Win4Assert ( fakeWid > 0 );
  27. Win4Assert ( fakeWid <= CI_MAX_DOCS_IN_WORDLIST );
  28. return( fakeWid - 1 );
  29. }
  30. class CWidTable
  31. {
  32. public:
  33. CWidTable();
  34. WORKID WidToFakeWid( WORKID wid );
  35. inline WORKID FakeWidToWid( WORKID fakeWid ) const;
  36. inline WORKID FakeWidToUnfilteredWid( WORKID fakeWid ) const;
  37. inline void InvalidateWid( ULONG index );
  38. inline BOOL IsValid( ULONG index ) const;
  39. inline void SetVolumeId( WORKID fakeWid, VOLUMEID volumeId );
  40. inline VOLUMEID VolumeId( WORKID fakeWid ) const;
  41. inline void MarkWidUnfiltered( ULONG index );
  42. inline BOOL IsFiltered( ULONG index ) const;
  43. inline unsigned Count() const { return _count; }
  44. #if CIDBG==1
  45. BOOL IsWorkIdPresent( WORKID wid ) const;
  46. #endif // CIDBG==1
  47. #ifdef CIEXTMODE
  48. void CiExtDump(void *ciExtSelf);
  49. #endif
  50. private:
  51. class CWidEntry
  52. {
  53. #ifdef CIEXTMODE
  54. friend class CWidTable;
  55. #endif // CIEXTMODE
  56. public:
  57. CWidEntry() : _wid( widInvalid ), _fFiltered( TRUE ) {}
  58. void SetWid( WORKID wid ) { _wid = wid; _fFiltered = TRUE; }
  59. WORKID Wid() const { return _wid; }
  60. void SetVolumeId( VOLUMEID volumeId ) { _volumeId = volumeId; }
  61. VOLUMEID VolumeId() const { return _volumeId; }
  62. void MarkInvalid() { _wid = widInvalid; }
  63. BOOL IsValid() const { return _wid != widInvalid; }
  64. void MarkUnfiltered() { _fFiltered = FALSE; }
  65. BOOL IsFiltered() const { return _fFiltered; }
  66. private:
  67. WORKID _wid;
  68. VOLUMEID _volumeId;
  69. BOOL _fFiltered;
  70. };
  71. CWidEntry _table[CI_MAX_DOCS_IN_WORDLIST];
  72. unsigned _count;
  73. };
  74. //+-------------------------------------------------------------------------
  75. //
  76. // Member: CWidTable::FakeWidToWid, public
  77. //
  78. // Arguments: [fakeWid] -- fakeWid
  79. //
  80. // Returns: The WorkId mapped to [FakeWid]
  81. //
  82. // History: 20-May-92 KyleP Created
  83. //
  84. //--------------------------------------------------------------------------
  85. inline WORKID CWidTable::FakeWidToWid( WORKID fakeWid ) const
  86. {
  87. if ( fakeWid <= _count && _table[ FakeWidToIndex(fakeWid) ].IsFiltered() )
  88. return( _table[ FakeWidToIndex(fakeWid) ].Wid() );
  89. else
  90. return( widInvalid );
  91. }
  92. inline WORKID CWidTable::FakeWidToUnfilteredWid( WORKID fakeWid ) const
  93. {
  94. if ( fakeWid > _count || _table[ FakeWidToIndex(fakeWid) ].IsFiltered() )
  95. return( widInvalid );
  96. else
  97. return( _table[ FakeWidToIndex(fakeWid) ].Wid() );
  98. }
  99. //+-------------------------------------------------------------------------
  100. //
  101. // Member: CWidTable::InvalidateWid, public
  102. //
  103. // Arguments: [index] -- FakeWid of Wid
  104. //
  105. // Summary: Resets the WorkId at index in table to widInvalid
  106. //
  107. // History: 22-Sep-93 AmyA Created
  108. //
  109. //--------------------------------------------------------------------------
  110. inline void CWidTable::InvalidateWid( WORKID fakeWid )
  111. {
  112. Win4Assert( fakeWid <= _count );
  113. _table[FakeWidToIndex(fakeWid)].MarkInvalid();
  114. }
  115. inline BOOL CWidTable::IsValid( WORKID fakeWid ) const
  116. {
  117. Win4Assert( (fakeWid <= _count) ||
  118. _table[ FakeWidToIndex(fakeWid) ].Wid() == widInvalid );
  119. return( _table[FakeWidToIndex(fakeWid)].IsValid() );
  120. }
  121. inline void CWidTable::SetVolumeId( WORKID fakeWid, VOLUMEID volumeId )
  122. {
  123. Win4Assert( fakeWid <= _count );
  124. _table[FakeWidToIndex(fakeWid)].SetVolumeId( volumeId );
  125. }
  126. inline VOLUMEID CWidTable::VolumeId( WORKID fakeWid ) const
  127. {
  128. Win4Assert( fakeWid <= _count );
  129. return( _table[FakeWidToIndex(fakeWid)].VolumeId() );
  130. }
  131. inline void CWidTable::MarkWidUnfiltered( WORKID fakeWid )
  132. {
  133. Win4Assert( fakeWid <= _count );
  134. _table[FakeWidToIndex(fakeWid)].MarkUnfiltered();
  135. }
  136. inline BOOL CWidTable::IsFiltered( WORKID fakeWid ) const
  137. {
  138. Win4Assert( fakeWid <= _count );
  139. return( _table[FakeWidToIndex(fakeWid)].IsFiltered() );
  140. }
  141. #if CIDBG==1
  142. inline BOOL CWidTable::IsWorkIdPresent( WORKID wid ) const
  143. {
  144. for ( unsigned i = 0; i < _count; i++ )
  145. {
  146. if ( wid == _table[i].Wid() )
  147. {
  148. return TRUE;
  149. }
  150. }
  151. return FALSE;
  152. }
  153. #endif // CIDBG==1