简体   繁体   English

std :: istream上的Windows IStream接口

[英]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? 在Windows上的C ++中,是否有任何简单的方法来创建到现有std::stream对象的(COM) IStream接口?

An example would be to read an image with IWICStream::InitializeFromIStream() from std::cin . 一个示例是从std::cinIWICStream::InitializeFromIStream()读取图像。

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. 您需要编写实现IStream接口并在需要时内部委托给std::stream的类(或找到第三方类)。 However, you are likely to have trouble implementing IStream::Stat() , which is commonly used to retrieve a stream's data size. 但是,您可能会在实现IStream::Stat()遇到麻烦,该方法通常用于检索流的数据大小。 In the case of std::cin , you would not know how much data is being provided. 对于std::cin ,您将不知道提供了多少数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM