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.

106 lines
4.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998 - 1998.
  5. //
  6. // File: odbvarnt.hxx
  7. //
  8. // Contents: Helper class for PROPVARIANTs, OLE-DB variant types and
  9. // Automation variant types in tables
  10. //
  11. // Classes: COLEDBVariant - derives from CTableVariant
  12. //
  13. // History: 09 Jan 1998 VikasMan Created
  14. //
  15. //--------------------------------------------------------------------------
  16. #pragma once
  17. #include <tblvarnt.hxx>
  18. // forward declaration for OLE DB data conversion interface
  19. interface IDataConvert;
  20. //+-------------------------------------------------------------------------
  21. //
  22. // Class: COLEDBVariant
  23. //
  24. // Purpose: Derives from CTableVariant - adds functionality to convert
  25. // to/from OLE DB types and Automation variants. This class will
  26. // normally be used on the client side, while CTableVariant class
  27. // will normally be used on the server side.
  28. //
  29. // Interface:
  30. //
  31. // Notes: Because the underlying base data *is* a variant, this
  32. // class cannot have any non-static members (including
  33. // a vtable).
  34. //
  35. // For various conversions to OLE-DB types, this class uses
  36. // the OLEDB data conversion library(MSDADC.DLL).
  37. //
  38. // For additional info. refer to the notes section in the
  39. // CTableVariant class.
  40. //
  41. // History: 09 Jan 1998 VikasMan Created
  42. //
  43. //--------------------------------------------------------------------------
  44. class COLEDBVariant: public CTableVariant
  45. {
  46. public:
  47. DBSTATUS OLEDBConvert(
  48. BYTE * pbDest,
  49. DBLENGTH cbDest,
  50. VARTYPE vtDest,
  51. PVarAllocator & rVarAllocator,
  52. DBLENGTH & rcbDstLen,
  53. XInterface<IDataConvert>& xDataConvert,
  54. BOOL fExtTypes = TRUE,
  55. BYTE bPrecision = 0,
  56. BYTE bScale = 0 ) const;
  57. static BOOL CanConvertType(DBTYPE wFromType,
  58. DBTYPE wToType,
  59. XInterface<IDataConvert>& xDataConvert);
  60. DBSTATUS GetDstLength(
  61. XInterface<IDataConvert>& xDataConvert,
  62. DBTYPE dbtypeDst,
  63. DBLENGTH & rcbDstLen );
  64. private:
  65. HRESULT _GetOLEDBType( VARTYPE vt, DBTYPE& dbtype ) const;
  66. void * _GetDataPointer() const;
  67. DBSTATUS _CopyToOAVariant( VARIANT * pDest,
  68. PVarAllocator & rVarAllocator) const;
  69. DBSTATUS _StoreSimpleTypeArray( SAFEARRAY ** pbDstBuf) const;
  70. DBSTATUS _StoreLPSTRArray( SAFEARRAY ** pbDstBuf,
  71. PVarAllocator & rPool) const;
  72. DBSTATUS _StoreLPWSTRArray( SAFEARRAY ** pbDstBuf,
  73. PVarAllocator & rPool) const;
  74. DBSTATUS _StoreBSTRArray( SAFEARRAY ** pbDstBuf,
  75. PVarAllocator & rPool) const;
  76. DBSTATUS _StoreDecimalArray( SAFEARRAY ** pbDstBuf) const;
  77. DBSTATUS _StoreIntegerArray( VARTYPE vtDst,
  78. SAFEARRAY ** pbDstBuf) const;
  79. DBSTATUS _StoreVariantArray( SAFEARRAY ** pbDstBuf,
  80. PVarAllocator & rPool) const;
  81. DBSTATUS _StoreDateArray( SAFEARRAY ** pbDstBuf) const;
  82. DBSTATUS _StoreDate(BYTE * pbDstBuf,
  83. DBLENGTH cbDstBuf,
  84. VARTYPE vtDst,
  85. LONG lElem = 0) const;
  86. static BOOL _GetIDataConvert( XInterface<IDataConvert>& xDataConvert );
  87. };
  88. inline BOOL DBStatusOK( DBSTATUS DstStatus)
  89. {
  90. return ( DBSTATUS_S_OK == DstStatus ||
  91. DBSTATUS_S_ISNULL == DstStatus ||
  92. DBSTATUS_S_TRUNCATED == DstStatus );
  93. }