IStreamAdapter.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef ISTREAMADAPTER_H
  18. #define ISTREAMADAPTER_H
  19. #include <kopano/zcdefs.h>
  20. namespace KC {
  21. class _kc_export IStreamAdapter _kc_final : public IStream {
  22. public:
  23. IStreamAdapter(std::string& str);
  24. _kc_hidden virtual ~IStreamAdapter(void) _kc_impdtor;
  25. _kc_hidden virtual HRESULT QueryInterface(REFIID iid, void **pv) _kc_override;
  26. _kc_hidden virtual ULONG AddRef(void) _kc_override { return 1; }
  27. _kc_hidden virtual ULONG Release(void) _kc_override { return 1; }
  28. virtual HRESULT Read(void *pv, ULONG cb, ULONG *pcbRead) _kc_override;
  29. virtual HRESULT Write(const void *pv, ULONG cb, ULONG *pcbWritten) _kc_override;
  30. virtual HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) _kc_override;
  31. virtual HRESULT SetSize(ULARGE_INTEGER libNewSize) _kc_override;
  32. virtual HRESULT CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) _kc_override;
  33. _kc_hidden virtual HRESULT Commit(DWORD flags) _kc_override { return hrSuccess; }
  34. _kc_hidden virtual HRESULT Revert(void) _kc_override { return hrSuccess; }
  35. _kc_hidden virtual HRESULT LockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD lock) _kc_override { return MAPI_E_NO_SUPPORT; }
  36. _kc_hidden virtual HRESULT UnlockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD lock) _kc_override { return MAPI_E_NO_SUPPORT; }
  37. virtual HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFlag) _kc_override;
  38. _kc_hidden virtual HRESULT Clone(IStream **) _kc_override { return MAPI_E_NO_SUPPORT; }
  39. _kc_hidden IStream *get(void) { return this; }
  40. private:
  41. size_t m_pos = 0;
  42. std::string& m_str;
  43. };
  44. } /* namespace */
  45. #endif