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.

190 lines
5.8 KiB

  1. //-----------------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: caccess.hxx
  7. //
  8. // Contents: Microsoft OleDB/OleDS Data Source Object for ADSI
  9. //
  10. // CImpIAccessor object implementing the IAccessor interface.
  11. //
  12. // History: 08-01-96 shanksh Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef _CACCESS_HXX
  16. #define _CACCESS_HXX
  17. // ADSI accessor structure
  18. typedef struct tagADSACCESSOR {
  19. DBACCESSORFLAGS dwFlags; // accessor flags
  20. DBREFCOUNT cRef; // reference count of the accessor
  21. DBLENGTH cbRowSize; // size of the row in the client's buffer
  22. DBORDINAL *rgcol; // array of cols referenced by the accessor
  23. DBCOUNTITEM cBindings; // # of bindings
  24. DBBINDING rgBindings[1];// array of binding structs
  25. } ADSACCESSOR;
  26. typedef ADSACCESSOR *PADSACCESSOR;
  27. //-----------------------------------------------------------------------------------
  28. //
  29. // class CImpIAccessor | Contained IAccessor class
  30. //
  31. //-----------------------------------------------------------------------------------
  32. class CImpIAccessor : INHERIT_TRACKING,
  33. public IAccessor // public | IAccessor
  34. {
  35. // Immediate user objects are friends
  36. friend class CCommandObject;
  37. private:
  38. void *_pObj;
  39. LPUNKNOWN _pUnkOuter;
  40. ULONG _dwStatus; // status dword
  41. LPEXTBUFF _pextbuffer; // array of accessor ptrs
  42. ULONG _dwGetDataTypeBadHandle; // specifies bad handle accessor type
  43. CRITICAL_SECTION _criticalsectionAccessor;// critical section for CreateAccessor calls
  44. IDataConvert *_pIDC;
  45. IMalloc *_pIMalloc;
  46. STDMETHODIMP_(void) DetermineTypes (
  47. DBACCESSORFLAGS dwAccessorFlags,
  48. ULONG *pdwGetDataType,
  49. ULONG *pdwSetDataType
  50. );
  51. STDMETHODIMP_(void) DeleteADsAccessor (
  52. PADSACCESSOR pADsaccessor
  53. );
  54. public:
  55. CImpIAccessor(void *, LPUNKNOWN);
  56. ~CImpIAccessor(void);
  57. DECLARE_STD_REFCOUNTING
  58. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) ;
  59. STDMETHODIMP FInit (
  60. void
  61. );
  62. STDMETHODIMP AddRefAccessor(
  63. HACCESSOR hAccessor,
  64. DBREFCOUNT *pcRefCounts
  65. );
  66. STDMETHODIMP CreateAccessor(
  67. DBACCESSORFLAGS dwAccessorFlags,
  68. DBCOUNTITEM cBindings,
  69. const DBBINDING rgBindings[],
  70. DBLENGTH cbRowSize,
  71. HACCESSOR *phAccessor,
  72. DBBINDSTATUS rgStatus[]
  73. );
  74. STDMETHODIMP GetBindings(
  75. HACCESSOR hAccessor,
  76. DBACCESSORFLAGS *pdwAccessorFlags,
  77. DBCOUNTITEM *pcBindings,
  78. DBBINDING **prgBindings
  79. );
  80. STDMETHODIMP ReleaseAccessor(
  81. HACCESSOR hAccessor,
  82. DBREFCOUNT *pcRefCounts
  83. );
  84. // Verifies that a DB type used in a binding is supported.
  85. inline STDMETHODIMP_(BOOL) IsGoodBindingType(
  86. DBTYPE dbtype
  87. )
  88. {
  89. switch ((dbtype & ~(DBTYPE_ARRAY|DBTYPE_BYREF|DBTYPE_VECTOR))) {
  90. case DBTYPE_I1:
  91. case DBTYPE_UI1:
  92. case DBTYPE_I2:
  93. case DBTYPE_UI2:
  94. case DBTYPE_I4:
  95. case DBTYPE_UI4:
  96. case DBTYPE_I8:
  97. case DBTYPE_UI8:
  98. case DBTYPE_R4:
  99. case DBTYPE_R8:
  100. case DBTYPE_CY:
  101. case DBTYPE_GUID:
  102. case DBTYPE_BOOL:
  103. case DBTYPE_VARIANT:
  104. case DBTYPE_DATE:
  105. case DBTYPE_DBDATE:
  106. case DBTYPE_DBTIME:
  107. case DBTYPE_DBTIMESTAMP:
  108. case DBTYPE_BSTR:
  109. case DBTYPE_STR:
  110. case DBTYPE_WSTR:
  111. case DBTYPE_BYTES:
  112. case DBTYPE_NUMERIC:
  113. case DBTYPE_IUNKNOWN:
  114. return TRUE;
  115. break;
  116. default:
  117. return FALSE;
  118. }
  119. }
  120. HRESULT CreateBadAccessor(void);
  121. };
  122. // Accessor status flags (_dwStatus)
  123. //const UDWORD ACCESSORSTAT_UNDERROWSET =0x00000001L;// aggregated under Rowset object
  124. const ULONG ACCESSORSTAT_VALIDATENOW =0x00000002L;// accessors totally validated on
  125. const ULONG ACCESSORSTAT_CANACCESSBLOBS=0x00000004L;// can create accessors for BLOBS
  126. //------ D E F I N E S, M A C R O S A N D I N L I N E F U N C T I O N S -------
  127. // Internal accessor type classifications
  128. // Common types
  129. // Marks an incorrect accessor.
  130. #define ACCESSORTYPE_INERROR 0
  131. // Types used by GetData.
  132. #define GD_ACCESSORTYPE_INERROR ACCESSORTYPE_INERROR
  133. #define GD_ACCESSORTYPE_PARAM_ONLY 1
  134. #define GD_ACCESSORTYPE_READ_BYREF 2
  135. #define GD_ACCESSORTYPE_READ_COLS_BYREF 3
  136. #define GD_ACCESSORTYPE_READ_OPTIMIZED 4
  137. #define GD_ACCESSORTYPE_READ 5
  138. // First good GetData type.
  139. #define GD_ACCESSORTYPE_GOOD GD_ACCESSORTYPE_READ_BYREF
  140. // Types used by SetData.
  141. #define SD_ACCESSORTYPE_INERROR ACCESSORTYPE_INERROR
  142. #define SD_ACCESSORTYPE_PARAM_ONLY 1
  143. #define SD_ACCESSORTYPE_READ_ONLY 2
  144. #define SD_ACCESSORTYPE_READWRITE 3
  145. const ULONG DBACCESSOR_VALID_FLAGS =
  146. (DBACCESSOR_PASSBYREF|DBACCESSOR_ROWDATA|
  147. DBACCESSOR_PARAMETERDATA|DBACCESSOR_OPTIMIZED);
  148. const DBTYPE TYPE_MODIFIERS = (DBTYPE_BYREF | DBTYPE_VECTOR | DBTYPE_ARRAY);
  149. const ULONG INITIAL_NUM_PARAM =256;
  150. // Zero element of the extbuffer of accessors always represents an invalid accessor.
  151. const ULONG_PTR hAccessorBadHandle =0;
  152. // Internal DBACCESSOR flag to mark accessors referencing BLOB columns.
  153. const DBACCESSORFLAGS DBACCESSOR_REFERENCES_BLOB =0x8000;
  154. #endif