Search code examples
c++fstreampopenifstreamistream

istream with popen functionality


I have a function that accepts istream class.

I need to be able to make it work with gzip data.

Is there in C++ standard istream-like class with popen()-like functionality?

Alternatively, is there a way to convert FILE * to istream?


Solution

  • Both approaches can be implemented by implementing a suitable stream buffer but neither approach is part of the C++ standard. I think there are implementations in Boost.

    Specifically for the use with gzipped data I wouldn't use something spawning a process, though. Instead, I would create a stream buffer using the gzip library (which may also exist in Boost).