Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows IStream interface on std::istream

Within C++ on Windows, is there any easy way to create a (COM) IStream interface to an existing std::stream object?

An example would be to read an image with IWICStream::InitializeFromIStream() from std::cin.

like image 684
Hugues Avatar asked Oct 21 '25 13:10

Hugues


1 Answers

There is no standard implementation for that. You need to write your class (or find a third-party one) that implements the IStream interface and internally delegates to an std::stream as needed. However, you are likely to have trouble implementing IStream::Stat(), which is commonly used to retrieve a stream's data size. In the case of std::cin, you would not know how much data is being provided.

like image 169
Remy Lebeau Avatar answered Oct 23 '25 02:10

Remy Lebeau