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.

238 lines
6.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: ColDesc.cxx
  7. //
  8. // Contents: Output column and sort column descriptors
  9. //
  10. // History: 22-Jun-93 KyleP Created
  11. // 08 Mar 94 AlanW Adapted for large tables
  12. //
  13. //--------------------------------------------------------------------------
  14. #include "pch.cxx"
  15. #pragma hdrstop
  16. #include <pidmap.hxx>
  17. #include <coldesc.hxx>
  18. //+-------------------------------------------------------------------------
  19. //
  20. // Synopsis: Marshalling routines for CColumnSet
  21. //
  22. // Obsolete, bug can't delete without changing on-the-wire protocol.
  23. //
  24. //+-------------------------------------------------------------------------
  25. inline void ReadOutputColumn(
  26. PROPID & Prop,
  27. PDeSerStream & stm,
  28. BOOL fAllBindingData
  29. ) {
  30. Prop = stm.GetULong();
  31. if (fAllBindingData)
  32. {
  33. //
  34. // The input stream has data for an obsolete CColumnOutputDesc.
  35. // Discard it.
  36. //
  37. ULONG dummy = stm.GetULong();
  38. dummy = stm.GetULong();
  39. dummy = stm.GetULong();
  40. dummy = stm.GetULong();
  41. dummy = stm.GetULong();
  42. dummy = (VARTYPE)stm.GetULong();
  43. }
  44. }
  45. //+-------------------------------------------------------------------------
  46. //
  47. // Synopsis: Marshalling routines for CColumnSet and CSortSet
  48. //
  49. //+-------------------------------------------------------------------------
  50. IMPL_DYNARRAY_INPLACE( CColumnSetBase, PROPID );
  51. CColumnSet::CColumnSet(unsigned size)
  52. : CColumnSetBase( size )
  53. {
  54. }
  55. void CColumnSet::Marshall( PSerStream & stm ) const
  56. {
  57. stm.PutULong( Count() );
  58. for ( unsigned i = 0; i < Count(); i++ )
  59. {
  60. stm.PutULong( Get(i) );
  61. }
  62. }
  63. CColumnSet::CColumnSet( PDeSerStream & stm, BOOL fAllBindingData )
  64. : CColumnSetBase( 0 )
  65. {
  66. // Validate the count looks realistic.
  67. ULONG cInSet = stm.GetULong();
  68. if ( cInSet >= 1000 )
  69. THROW( CException( E_INVALIDARG ) );
  70. SetExactSize( cInSet );
  71. for ( unsigned i = 0; i < cInSet; i++ )
  72. {
  73. PROPID Prop;
  74. ReadOutputColumn( Prop, stm, fAllBindingData );
  75. Add( Prop, i);
  76. }
  77. }
  78. IMPL_DYNARRAY_INPLACE( CSortSetBase, SSortKey );
  79. CSortSet::CSortSet(unsigned size)
  80. : CSortSetBase( size )
  81. {
  82. }
  83. void CSortSet::Marshall( PSerStream & stm ) const
  84. {
  85. stm.PutULong( Count() );
  86. for ( unsigned i = 0; i < Count(); i++ )
  87. {
  88. stm.PutULong( Get(i).pidColumn );
  89. stm.PutULong( Get(i).dwOrder );
  90. stm.PutULong( Get(i).locale );
  91. }
  92. }
  93. CSortSet::CSortSet( PDeSerStream & stm )
  94. : CSortSetBase( 0 )
  95. {
  96. ULONG cInSet = stm.GetULong();
  97. // Validate the count looks realistic.
  98. if ( cInSet >= 1000 )
  99. THROW( CException( E_INVALIDARG ) );
  100. SetExactSize( cInSet );
  101. for ( unsigned i = 0; i < cInSet; i++ )
  102. {
  103. SSortKey sk;
  104. sk.pidColumn = stm.GetULong();
  105. sk.dwOrder = stm.GetULong();
  106. Win4Assert( QUERY_SORTDESCEND == sk.dwOrder ||
  107. QUERY_SORTASCEND == sk.dwOrder );
  108. if ( QUERY_SORTDESCEND != sk.dwOrder &&
  109. QUERY_SORTASCEND != sk.dwOrder )
  110. THROW( CException( E_ABORT ) );
  111. sk.locale = stm.GetULong();
  112. Add( sk, i);
  113. }
  114. }
  115. //+-------------------------------------------------------------------------
  116. //
  117. // Synopsis: Marshalling routines for CCategorizationSet
  118. //
  119. //+-------------------------------------------------------------------------
  120. IMPL_DYNARRAY( CCategorizationSetBase, CCategorizationSpec );
  121. CCategorizationSet::CCategorizationSet(unsigned size)
  122. : CCategorizationSetBase( size ),
  123. _cCat( 0 )
  124. {
  125. }
  126. void CCategorizationSet::Marshall( PSerStream & stm ) const
  127. {
  128. stm.PutULong( Count() );
  129. for ( unsigned i = 0; i < Count(); i++ )
  130. Get(i)->Marshall( stm );
  131. }
  132. CCategorizationSet::CCategorizationSet( PDeSerStream & stm )
  133. : CCategorizationSetBase( 0 ),
  134. _cCat( 0 )
  135. {
  136. ULONG cInSet = stm.GetULong();
  137. // Validate the count looks realistic.
  138. if ( cInSet >= 1000 )
  139. THROW( CException( E_INVALIDARG ) );
  140. SetExactSize( cInSet );
  141. for ( unsigned i = 0; i < cInSet; i++ )
  142. Add( new CCategorizationSpec( stm ), i);
  143. }
  144. CCategorizationSet::CCategorizationSet( CCategorizationSet const & rCateg )
  145. : CCategorizationSetBase( rCateg.Count() ),
  146. _cCat( 0 )
  147. {
  148. // Validate the count looks realistic.
  149. if ( Size() >= 65536 )
  150. THROW( CException( E_INVALIDARG ) );
  151. for ( unsigned i = 0; i < Size(); i++ )
  152. Add( new CCategorizationSpec( *(rCateg.Get(i)) ), i);
  153. }
  154. void CCategorizationSpec::Marshall( PSerStream & stm ) const
  155. {
  156. _csColumns.Marshall( stm );
  157. _xSpec->Marshall( stm );
  158. } //Marshall
  159. CCategorizationSpec::CCategorizationSpec( PDeSerStream &stm )
  160. : _csColumns( stm )
  161. {
  162. unsigned type = stm.GetULong();
  163. if (CATEGORIZE_UNIQUE == type)
  164. _xSpec.Set( new CUniqueCategSpec( stm ) );
  165. else if (CATEGORIZE_BUCKETS == type)
  166. _xSpec.Set( new CBucketCategSpec( stm ) );
  167. else if (CATEGORIZE_RANGE == type)
  168. _xSpec.Set( new CRangeCategSpec( stm ) );
  169. else
  170. THROW( CException( E_INVALIDARG ) );
  171. } //CCategorizationSpec
  172. CCategorizationSpec::CCategorizationSpec( CCategorizationSpec const & rCatSpec )
  173. : _csColumns( rCatSpec.GetColumnSet().Count() )
  174. {
  175. for ( unsigned i = 0; i < _csColumns.Size(); i++ )
  176. _csColumns.Add( rCatSpec._csColumns.Get(i), i);
  177. unsigned type = rCatSpec.Type();
  178. if (CATEGORIZE_UNIQUE == type)
  179. _xSpec.Set( new CUniqueCategSpec( rCatSpec.GetCategSpec() ) );
  180. else if (CATEGORIZE_BUCKETS == type)
  181. _xSpec.Set( new CBucketCategSpec( rCatSpec.GetCategSpec() ) );
  182. else if (CATEGORIZE_RANGE == type)
  183. _xSpec.Set( new CRangeCategSpec( rCatSpec.GetCategSpec() ) );
  184. else
  185. THROW( CException( E_INVALIDARG ) );
  186. } //CCategorizationSpec