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.

106 lines
2.6 KiB

  1. #pragma once
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // Memory stream implementations for DS OLE DB PROVIDER
  4. //
  5. // copied from cdopt\src\cdo\mystream.* and modified.
  6. class ATL_NO_VTABLE CStreamMem :
  7. INHERIT_TRACKING,
  8. public CComObjectRootEx<CComMultiThreadModel>,
  9. public IStream,
  10. public IGetSourceRow
  11. {
  12. public:
  13. DECLARE_GET_CONTROLLING_UNKNOWN()
  14. BEGIN_COM_MAP(CStreamMem)
  15. COM_INTERFACE_ENTRY(IStream)
  16. COM_INTERFACE_ENTRY(ISequentialStream)
  17. COM_INTERFACE_ENTRY(IGetSourceRow)
  18. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
  19. END_COM_MAP()
  20. HRESULT FinalConstruct()
  21. {
  22. RRETURN( CoCreateFreeThreadedMarshaler(
  23. GetControllingUnknown(), &m_pUnkMarshaler.p));
  24. }
  25. void FinalRelease()
  26. {
  27. m_pUnkMarshaler.Release();
  28. }
  29. CComPtr<IUnknown> m_pUnkMarshaler;
  30. private:
  31. auto_cs m_cs; // critical section
  32. ULONG m_cbSeek;
  33. STATSTG m_statstg;
  34. CComVariant m_pVar;
  35. auto_rel<IRow> m_pSourceRow;
  36. HROW m_hRow;
  37. PVOID m_pvData;
  38. DWORD m_cbBufferSize;
  39. bool m_fExternalData;
  40. public:
  41. CStreamMem(void);
  42. ~CStreamMem(void);
  43. //internal methods
  44. HRESULT Initialize(VARIANT *pVar, IRow* pSourceRow, HROW hRow);
  45. // IStream
  46. STDMETHODIMP Read(
  47. void __RPC_FAR *pv,
  48. ULONG cb,
  49. ULONG __RPC_FAR *pcbRead);
  50. STDMETHODIMP Write(
  51. const void __RPC_FAR *pv,
  52. ULONG cb,
  53. ULONG __RPC_FAR *pcbWritten);
  54. STDMETHODIMP Seek(
  55. LARGE_INTEGER dlibMove,
  56. DWORD dwOrigin,
  57. ULARGE_INTEGER __RPC_FAR *plibNewPosition);
  58. STDMETHODIMP SetSize(
  59. ULARGE_INTEGER libNewSize);
  60. STDMETHODIMP CopyTo(
  61. IStream __RPC_FAR *pstm,
  62. ULARGE_INTEGER cb,
  63. ULARGE_INTEGER __RPC_FAR *pcbRead,
  64. ULARGE_INTEGER __RPC_FAR *pcbWritten);
  65. STDMETHODIMP Commit(
  66. DWORD grfCommitFlags);
  67. STDMETHODIMP Revert( void);
  68. STDMETHODIMP LockRegion(
  69. ULARGE_INTEGER libOffset,
  70. ULARGE_INTEGER cb,
  71. DWORD dwLockType);
  72. STDMETHODIMP UnlockRegion(
  73. ULARGE_INTEGER libOffset,
  74. ULARGE_INTEGER cb,
  75. DWORD dwLockType);
  76. STDMETHODIMP Stat(
  77. STATSTG __RPC_FAR *pstatstg,
  78. DWORD grfStatFlag);
  79. STDMETHODIMP Clone(
  80. IStream __RPC_FAR *__RPC_FAR *ppstm);
  81. //IGetSourceRow
  82. STDMETHODIMP GetSourceRow(REFIID riid, IUnknown **ppRow);
  83. };