aOn Tue, Mar 10, 2020 at 5:49 PM Vinnie Falco
On Tue, Mar 10, 2020 at 1:31 AM Domen Vrankar
wrote: You compress/decompress in chunks so all you need is a const std::span for input and std::span for output and call decompress on a for loop.
You need to know:
1. how much input was consumed 2. how much output was produced
Now I understand what you mean. You got me confused as your compress function wasn't receiving any state (like z_stream in zlib) so I assumed that you meant to compress the entire buffer in one go.
...input iterator pair/range for input/output... ...std::istream_iterator... ...boost.spirit x3 parser... ...read->decompress->parse/process ... Whit iterators/ranges described above you wouldn't need to return std::size_t so return can be used for error codes instead.
It isn't clear what these things mean without seeing a function signature or class declaration.
Since you need to hold state I was talking about something like this:
struct Reader // should be implemented for reading from vector, file
stream... some provided as convinience, others user defined so an extension
point
{
std::spanstd::byte read(); // remains stable untill next call to
read, at that point it is auto consumed
bool eof();
};
template
Thanks