I want to implement a C++ WinRT IBuffer that wraps a char* buffer, so i can use it with WinRT WriteAsync/ReadAsync operations that accept an IBuffer^ parameter.
EDIT 1 (clarification)
I want to avoid data copy.
I want to implement a C++ WinRT IBuffer that wraps a char* buffer, so i can use it with WinRT WriteAsync/ReadAsync operations that accept an IBuffer^ parameter.
EDIT 1 (clarification)
I want to avoid data copy.
This should work:
Mostly copied from http://jeremiahmorrill.wordpress.com/2012/05/11/http-winrt-client-for-c/ but adapted to directly wrap my own byte[]:
NativeBuffer.h:
To create the IBuffer:
And the call to read data (lpBuffer is the byte[]):
I am not so sure if the ComPtr needs some cleanup, so any suggestions regarding memory management are welcome.