How to implement both IBufferByteAccess and IBuffer in Universal Windows (C++/CX)?
According to MSDN:
When you implement the IBuffer interface, you must implement the IBufferByteAccess interface, which is a COM interface for accessing the buffer directly. C++ callers use this interface to avoid making a copy of the buffer.
With following example:
ref class BufferWrapper sealed :
public Windows::Storage::Streams::IBufferByteAccess,
public Windows::Storage::Streams::IBuffer
{
public:
// Inherited via IBufferByteAccess
virtual HRESULT QueryInterface(REFIID riid, void ** ppvObject) override;
virtual ULONG AddRef(void) override;
virtual ULONG Release(void) override;
virtual HRESULT Buffer(byte ** value) override;
// Inherited via IBuffer
virtual property unsigned int Capacity;
virtual property unsigned int Length;
}
IBuffer is ok, but I get error on IBufferByteAccess that a C++/CX mapping ref class can only derive from another ref class or from interface class.
when I remove ref:
class BufferWrapper :
public Windows::Storage::Streams::IBufferByteAccess,
public Windows::Storage::Streams::IBuffer
IBufferByteAccess is ok, but I get error from IBuffer that a standard class cannot derive from a C++/CX class.
In header file I do not include anything, in source file I only included header that I have found here
#include <robuffer.h>
I have also found here that this header is only thing I need to include.
The problem is (I think) that IBufferByteAccess is not ref class but a struct derived from public IUnknown. Is there any header file with another deifnition of IBufferByteAccess that is ref class/interface that I am not aware of?