Leaked source code of windows server 2003
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.

257 lines
6.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993 - 1998.
  5. //
  6. // File: ColDesc.hxx
  7. //
  8. // Contents: Column, sort, and categorization set descriptors
  9. //
  10. // Classes: SSortKey
  11. // CSortSetBase
  12. // CSortSet
  13. //
  14. // CColumnSetBase
  15. // CColumnSet
  16. //
  17. // CCategorizationSet
  18. // CCategorizationSetBase
  19. //
  20. // History: 18-Jun-93 KyleP Created
  21. // 14 Jun 94 AlanW Added classes for large tables.
  22. //
  23. //--------------------------------------------------------------------------
  24. #pragma once
  25. #include <sstream.hxx> // PSerStream
  26. //+-------------------------------------------------------------------------
  27. //
  28. // Class: SSortKey
  29. //
  30. // Purpose: A sort key, with ColumnID translated to PropID
  31. //
  32. // Notes:
  33. //
  34. //--------------------------------------------------------------------------
  35. class SSortKey
  36. {
  37. public:
  38. SSortKey( ) :
  39. pidColumn(0),
  40. dwOrder(0),
  41. locale(0)
  42. { }
  43. SSortKey(PROPID pid, ULONG dwOrd, LCID loc = 0) :
  44. pidColumn(pid),
  45. dwOrder(dwOrd),
  46. locale(loc)
  47. { }
  48. PROPID pidColumn; // Property ID
  49. ULONG dwOrder; // ascending or descending, Nulls first or last
  50. LCID locale; // locale for collation order
  51. };
  52. DECL_DYNARRAY_INPLACE( CColumnSetBase, PROPID );
  53. class CColumnSet : public CColumnSetBase
  54. {
  55. public:
  56. CColumnSet(unsigned size = arraySize);
  57. //
  58. // Serialization
  59. //
  60. void Marshall( PSerStream & stm ) const;
  61. CColumnSet( PDeSerStream & stm, BOOL fNewFormat = FALSE );
  62. };
  63. DECLARE_SMARTP( ColumnSet );
  64. DECL_DYNARRAY_INPLACE( CSortSetBase, SSortKey );
  65. class CSortSet : public CSortSetBase
  66. {
  67. public:
  68. CSortSet(unsigned size = arraySize);
  69. //
  70. // Serialization
  71. //
  72. void Marshall( PSerStream & stm ) const;
  73. CSortSet( PDeSerStream & stm );
  74. //
  75. // Checks if the propId exists in the sortset
  76. //
  77. inline BOOL Exists( const PROPID propId ) const
  78. {
  79. for( unsigned ii = 0; ii < Count(); ii++)
  80. {
  81. if ( propId == Get(ii).pidColumn )
  82. {
  83. return TRUE;
  84. }
  85. }
  86. return FALSE;
  87. }
  88. };
  89. DECLARE_SMARTP( SortSet );
  90. class CCategSpec
  91. {
  92. public:
  93. unsigned Type() const
  94. { return _ulCategType; }
  95. virtual void Marshall(PSerStream & stm ) const
  96. { stm.PutULong( _ulCategType ); }
  97. protected:
  98. CCategSpec( unsigned CategType ) : _ulCategType( CategType ) {}
  99. ULONG _ulCategType;
  100. };
  101. class CUniqueCategSpec : public CCategSpec
  102. {
  103. public:
  104. CUniqueCategSpec(CCategSpec const &CatSpec) :
  105. CCategSpec( CATEGORIZE_UNIQUE ) {}
  106. CUniqueCategSpec() :
  107. CCategSpec( CATEGORIZE_UNIQUE ) {}
  108. CUniqueCategSpec( PDeSerStream &stm ) :
  109. CCategSpec( CATEGORIZE_UNIQUE ) {}
  110. void Marshall( PSerStream &stm ) const { CCategSpec::Marshall( stm ); }
  111. };
  112. class CBucketCategSpec : public CCategSpec
  113. {
  114. public:
  115. CBucketCategSpec(CCategSpec const & CatSpec) :
  116. CCategSpec( CATEGORIZE_BUCKETS ) {}
  117. CBucketCategSpec( BUCKETCATEGORIZE const & range ) :
  118. CCategSpec( CATEGORIZE_BUCKETS ) {}
  119. CBucketCategSpec( PDeSerStream &stm ) :
  120. CCategSpec( CATEGORIZE_BUCKETS ) {}
  121. void Marshall( PSerStream &stm ) const { CCategSpec::Marshall( stm ); }
  122. private:
  123. BUCKETCATEGORIZE _bucket;
  124. };
  125. class CRangeCategSpec : public CCategSpec
  126. {
  127. public:
  128. CRangeCategSpec(CCategSpec const &CatSpec) :
  129. CCategSpec( CATEGORIZE_RANGE ) {}
  130. CRangeCategSpec( RANGECATEGORIZE const & range ) :
  131. CCategSpec( CATEGORIZE_RANGE ) {}
  132. CRangeCategSpec( PDeSerStream &stm ) :
  133. CCategSpec( CATEGORIZE_RANGE ) {}
  134. void Marshall( PSerStream &stm ) const { CCategSpec::Marshall( stm ); }
  135. private:
  136. RANGECATEGORIZE _range;
  137. };
  138. class CCategorizationSpec
  139. {
  140. public:
  141. CCategorizationSpec( CCategorizationSpec const & rCatSpec );
  142. CCategorizationSpec( CCategSpec * pCateg, unsigned cCol ) :
  143. _xSpec( pCateg ), _csColumns( cCol )
  144. {
  145. }
  146. CCategorizationSpec( CATEGORIZATION &Categ ) :
  147. _xSpec( 0 ), _csColumns( Categ.csColumns.cCol )
  148. {
  149. if (CATEGORIZE_UNIQUE == Categ.ulCatType)
  150. _xSpec.Set( new CUniqueCategSpec() );
  151. else if (CATEGORIZE_BUCKETS == Categ.ulCatType)
  152. _xSpec.Set( new CBucketCategSpec( Categ.bucket ) );
  153. else if (CATEGORIZE_RANGE == Categ.ulCatType)
  154. _xSpec.Set( new CRangeCategSpec( Categ.range ) );
  155. else
  156. Win4Assert(!"Unsupported categorization type!");
  157. }
  158. CCategorizationSpec( PDeSerStream &stm );
  159. ~CCategorizationSpec() {}
  160. unsigned Type() const { return _xSpec->Type(); }
  161. const CCategSpec & GetCategSpec( ) const
  162. { return _xSpec.GetReference(); }
  163. const CColumnSet & GetColumnSet( ) const
  164. { return _csColumns; }
  165. void SetColumn( PROPID pid, unsigned iPosition )
  166. { _csColumns.Add( pid, iPosition ); }
  167. void Marshall( PSerStream & stm ) const;
  168. private:
  169. XPtr<CCategSpec> _xSpec;
  170. CColumnSet _csColumns; // columns that can be bound to
  171. };
  172. DECL_DYNARRAY( CCategorizationSetBase, CCategorizationSpec );
  173. class CPidMapper;
  174. class CCategorizationSet : public CCategorizationSetBase
  175. {
  176. public:
  177. CCategorizationSet( CCategorizationSet const & rCateg );
  178. CCategorizationSet(unsigned size = arraySize);
  179. CCategorizationSet( unsigned size,
  180. CATEGORIZATIONSET *pSet,
  181. SORTSET *pSort,
  182. CPidMapper &pidMap );
  183. //
  184. // Serialization
  185. //
  186. void Marshall( PSerStream & stm ) const;
  187. CCategorizationSet( PDeSerStream & stm );
  188. void Add( CCategorizationSpec * pSpec, unsigned i )
  189. {
  190. CCategorizationSetBase::Add( pSpec, i );
  191. if (i >= _cCat)
  192. _cCat = i+1;
  193. }
  194. ULONG Count() const
  195. { return _cCat; }
  196. private:
  197. ULONG _cCat;
  198. };
  199. DECLARE_SMARTP( CategorizationSet );