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.

206 lines
7.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999.
  5. //
  6. // File: colinfo.hxx
  7. //
  8. // Contents: Column information for Indexing Service rowsets
  9. //
  10. // Classes: CColumnsInfo
  11. //
  12. // History: 04 Feb 1995 AlanW Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #pragma once
  16. #include <coldesc.hxx>
  17. #include <pidmap.hxx>
  18. class PQuery;
  19. class CTableColumnSet;
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Class: CColumnsInfo
  23. //
  24. // Purpose: IColumnsInfo implementation for Indexing Service OLE-DB.
  25. //
  26. // Interface: IColumnsInfo, potentially IColumnsRowset
  27. //
  28. // History: 04 Feb 1995 AlanW Created
  29. //
  30. // Notes: Designed as a delegated OLE class. Includes methods
  31. // to help with managing columns in row buffers for
  32. // the IRowset implementation.
  33. //
  34. //----------------------------------------------------------------------------
  35. class CColumnsInfo : public IColumnsInfo
  36. #ifdef INCLUDE_COLUMNS_ROWSET_IMPLEMENTATION
  37. , public IColumnsRowset
  38. #endif // INCLUDE_COLUMNS_ROWSET_IMPLEMENTATION
  39. {
  40. public:
  41. //
  42. // IUnknown methods.
  43. //
  44. STDMETHOD(QueryInterface) ( THIS_ REFIID riid,
  45. LPVOID *ppiuk );
  46. STDMETHOD_(ULONG, AddRef) (THIS);
  47. STDMETHOD_(ULONG, Release) (THIS);
  48. //
  49. // IColumnsInfo methods
  50. //
  51. STDMETHOD(GetColumnInfo) (DBORDINAL* pcColumns,
  52. DBCOLUMNINFO * * prgInfo,
  53. WCHAR * * ppStringsBuffer);
  54. STDMETHOD(MapColumnIDs) (DBORDINAL cColumnIDs,
  55. const DBID rgColumnIDs[],
  56. DBORDINAL rgColumns[]);
  57. #ifdef INCLUDE_COLUMNS_ROWSET_IMPLEMENTATION
  58. //
  59. // IColumnsRowset methods
  60. //
  61. STDMETHOD(GetAvailableColumns) (ULONG * pcSelections,
  62. DBID ** prgColumnSelection) /*const*/;
  63. STDMETHOD(GetColumnsRowset) (ULONG cSelections,
  64. DBID rgColumnSelection[],
  65. IRowset ** ppColRowset) /*const*/;
  66. #endif // INCLUDE_COLUMNS_ROWSET_IMPLEMENTATION
  67. //
  68. // Local methods.
  69. //
  70. CColumnsInfo( CColumnSet const & cols,
  71. CPidMapperWithNames const & pidmap,
  72. CCIOleDBError & ErrorObject,
  73. IUnknown & rUnknown,
  74. BOOL fSequential);
  75. CColumnsInfo( IUnknown & rUnknown,
  76. CCIOleDBError & ErrorObject,
  77. BOOL fNotPrepared=FALSE);
  78. virtual ~CColumnsInfo();
  79. void InitColumns( CColumnSet const & cols,
  80. CPidMapperWithNames const & pidmap,
  81. BOOL fSequential);
  82. void InitColumns( BOOL fNotPrepared );
  83. ULONG MapColumnID( DBID const * pColumnID );
  84. // Return number of columns
  85. ULONG GetColumnCount( void ) const
  86. { return _cColumns; }
  87. // Return number of columns, including hidden columns
  88. ULONG GetHiddenColumnCount( void ) const
  89. { return _cBoundColumns; }
  90. // Return column bindings for row buffers
  91. CTableColumnSet & GetColumnBindings( void ) const
  92. { return *_pColumns; }
  93. // Return row width for row buffers
  94. ULONG GetRowWidth( void ) const
  95. { return _cbRowWidth; }
  96. // Set column bindings for row buffers
  97. void SetColumnBindings(
  98. PQuery & rpQuery,
  99. ULONG hCursor,
  100. ULONG &obRowRefcount,
  101. ULONG &obRowWorkId,
  102. ULONG &obChaptRefcount,
  103. ULONG &obChaptWorkId);
  104. // Return standard column information for a column by column number
  105. const DBCOLUMNINFO & Get1ColumnInfo(
  106. ULONG iColumn);
  107. // Return TRUE if column ID is valid
  108. BOOL IsValidColumnId( ULONG iColumn )
  109. { return iColumn == 0 ? ! _fSequential :
  110. iColumn <= GetColumnCount(); }
  111. // Return column number for row ID column and its standard info
  112. ULONG GetRowIdColumn( )
  113. { return _iColRowId; };
  114. CFullPropSpec const * GetPropSpec( ULONG iColumn)
  115. { return _pidmap.PidToName( iColumn ); }
  116. ULONG GetId() const { return _idUnique; }
  117. private:
  118. // Set columns.
  119. void _SetColumns( CColumnSet const & cols,
  120. CPidMapperWithNames const & pidmap,
  121. BOOL fSequential);
  122. // Find standard column information for a column and return it.
  123. static DBCOLUMNINFO const & _FindColumnInfo(
  124. const CFullPropSpec & rColumnID );
  125. // Return standard column information for the Row ID column
  126. static DBCOLUMNINFO const & _GetRowIdColumnInfo( void );
  127. //
  128. // Column information for common columns and pseudo-columns
  129. //
  130. struct SPropSetInfo {
  131. unsigned cProps;
  132. DBCOLUMNINFO const * aPropDescs;
  133. };
  134. ULONG _GetNewId()
  135. {
  136. return InterlockedIncrement((LONG *) &_nUnique);
  137. }
  138. static const SPropSetInfo aPropSets[];
  139. static const ULONG cPropSets;
  140. static ULONG _nUnique; // A unique number for identifying each
  141. // CColumnsInfo object.
  142. ULONG _idUnique; // Id of this CColumnsInfo object
  143. IUnknown & _rUnknown; // Controlling IUnknown
  144. ULONG _cbRowWidth; // Width of a row
  145. ULONG _cColumns; // number of columns in rowset, not
  146. // including bookmark or added row ID
  147. ULONG _cBoundColumns; // number of bound columns
  148. ULONG _iColRowId; // column number of Row ID column
  149. BOOL _fSequential; // sequential rowset?
  150. CPidMapperWithNames _pidmap; // pid mapper for column numbers/names
  151. CTableColumnSet * _pColumns; // Table column descriptions
  152. BOOL _fNotPrepared; // return DB_E_NOTPREPARED for a command object?
  153. BOOL _fChaptered; // chaptered rowset?
  154. CCIOleDBError & _ErrorObject; // The controlling unknown's error object
  155. };