aboutsummaryrefslogtreecommitdiff
path: root/src/base/platform/win/BrigdeComStream.h
blob: 1621b5678a3ee0e05935dbcd17649e325c9b04ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include "cru/base/platform/win/WinPreConfig.h"

#include "cru/base/io/Stream.h"

#include <objidlbase.h>

namespace cru::platform::win {
class BridgeComStream : public IStream {
 public:
  explicit BridgeComStream(io::Stream* stream);

  CRU_DELETE_COPY(BridgeComStream)
  CRU_DELETE_MOVE(BridgeComStream)

  ~BridgeComStream();

 public:
  ULONG AddRef() override;
  ULONG Release() override;
  HRESULT QueryInterface(REFIID riid, void** ppvObject) override;

  HRESULT Read(void* pv, ULONG cb, ULONG* pcbRead) override;
  HRESULT Write(const void* pv, ULONG cb, ULONG* pcbWritten) override;
  HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin,
               ULARGE_INTEGER* plibNewPosition) override;
  HRESULT SetSize(ULARGE_INTEGER libNewSize) override;
  HRESULT CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead,
                 ULARGE_INTEGER* pcbWritten) override;
  HRESULT Commit(DWORD grfCommitFlags) override;
  HRESULT Revert() override;
  HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
                     DWORD dwLockType) override;
  HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
                       DWORD dwLockType) override;
  HRESULT Stat(STATSTG* pstatstg, DWORD grfStatFlag) override;
  HRESULT Clone(IStream** ppstm) override;

 private:
  io::Stream* stream_;
  ULONG ref_count_;
};
}  // namespace cru::platform::win