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.

146 lines
3.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: bktrow.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 2-15-95 srikants Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #pragma once
  18. #include <tblvarnt.hxx> // for CTableVariant
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Class: CInlineVariant
  22. //
  23. // Purpose: To have a dummy field at the end of a PROPVARIANT. This will
  24. // help us get the correct offset for variable data in an inline
  25. // variant.
  26. //
  27. // History: 2-15-95 srikants Created
  28. //
  29. // Notes: In other places, it has been just assumed that the variable
  30. // part is immediately after the fixed part in a variant.
  31. //
  32. //----------------------------------------------------------------------------
  33. #pragma warning( disable : 4200 )
  34. class CInlineVariant : public CTableVariant
  35. {
  36. public:
  37. BYTE * GetVarBuffer()
  38. {
  39. return &_abVarData[0];
  40. }
  41. private:
  42. BYTE _abVarData[];
  43. };
  44. #pragma warning( default : 4200 )
  45. //+---------------------------------------------------------------------------
  46. //
  47. // Class: CBucketRow
  48. //
  49. // Purpose: A Bucket row consists of a columns that are part of the
  50. // sort key. Each field is stored as a fully expanded in-line
  51. // variant to avoid frequent memory allocations and frees.
  52. //
  53. // History: 2-15-95 srikants Created
  54. //
  55. // Notes:
  56. //
  57. //----------------------------------------------------------------------------
  58. class CBucketRow
  59. {
  60. enum { cThreshold = 20 };
  61. public:
  62. CBucketRow( unsigned cCols = 0 );
  63. ~CBucketRow();
  64. //
  65. // The assignment operator can be used only when the RHS has the same
  66. // ordinality as the LHS.
  67. //
  68. CBucketRow & operator = ( CBucketRow & src );
  69. //
  70. // Initialize the specified column with given variant.
  71. //
  72. void Init( unsigned i, CTableVariant & src, BYTE * pbSrcBias = 0 );
  73. CTableVariant * Get( unsigned i, unsigned & size )
  74. {
  75. Win4Assert( i < _cCols );
  76. size = _acbVariants[i];
  77. return _apVariants[i];
  78. }
  79. //
  80. // Reallocates the specified variant to be atlease as big as cbData.
  81. //
  82. void ReAlloc( unsigned i, VARTYPE vt, unsigned cbData );
  83. //
  84. // Pointer to an array of variants that constitute the row.
  85. //
  86. PROPVARIANT ** GetVariants()
  87. {
  88. return (PROPVARIANT **) _apVariants.GetPointer();
  89. }
  90. //
  91. // Test if the spcified "vt" is for an ascii string.
  92. //
  93. static BOOL IsSTR( VARTYPE vt )
  94. {
  95. Win4Assert( 0 == ( VT_BYREF | vt ) );
  96. return LPSTR == vt;
  97. }
  98. //
  99. // Test if the specified "vt" is for a WIDE string.
  100. //
  101. static BOOL IsWSTR( VARTYPE vt )
  102. {
  103. Win4Assert( 0 == ( VT_BYREF | vt ) );
  104. return LPWSTR == vt;
  105. }
  106. private:
  107. // Number of columns in the row.
  108. unsigned _cCols;
  109. // Array of lengths of variants.
  110. XArray<unsigned> _acbVariants;
  111. // Array of variants, one for each column in the row.
  112. XArray<CInlineVariant *> _apVariants;
  113. };