Boost logo

Boost Users :

Subject: Re: [Boost-users] [iostreams] gzip problem
From: Olaf Krzikalla (olaf.krzikalla_at_[hidden])
Date: 2014-02-24 09:45:19

Am 21.02.2014 16:26, schrieb Nat Goodspeed:
> Could you wrap the input stream in a filter that would pass through only the chunk, pretending to its consumer that the chunk is the entire stream?
Yep, the following code does the trick:

struct chunk_device : boost::iostreams::source
   std::istream& stream_;
   std::streamsize size_;

   chunk_device(std::istream& is, std::streamsize sz) :
     size_(sz) {}

   std::streamsize read(char* s, std::streamsize n)
     if (size_ == 0)
       return -1;
     n = std::min(n, size_);
     std::streamsize result =, n).gcount();
     size_ -= result;
     return result;

Thanks Olaf

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at