[iostreams] How do you flush an entire filter chain?

Hi all, I have some code that uses standard C++ iostreams and I would like to use Boost iostreams to insert a filter in the process to provide transparent XOR encryption/decryption without needing to modify the existing code. I have written a filter that applies the algorithm, and I create a filtering_streamio::seekable "stack" which has the XOR filter pushed onto it, followed by the original iostream. I then pass this stack along to the original function and for the most part it works. However when the original code tries to flush() the changes back to disk, the filter only calls flush() on the first item in the stack. This means the XOR algorithm has its flush() function called, but the iostream (next in line on the stack) does not. If I remove the XOR algorithm (leaving the filter stack in place) then it does call flush() on the original iostream now that it is the first element in the stack. So I would like to know if there is a way to flush an entire filter stack, rather than just the top-most element in the stack. My XOR filter function doesn't actually perform any caching so its flush() function simply returns true, as this seems to be required from what I could make out in the docs about flushing. I was unable to find any mention in the docs of how flush() should behave in a filter (not even a function signature) so I am not sure if this is correct! I just copied it off some of the test code as that was the only place I could find anything about it. Many thanks, Adam.
participants (1)
-
Adam Nielsen