On 8/03/2022 16:00, Robert Dodier wrote:
I'm interested in working with an input stream which comprises multiple input streams. The resulting stream comprises all of the input from the first stream (until EOF), then all of the input from the second, etc. For what it's worth, such an input stream is called a concatenated input stream in at least one other context (namely Common Lisp).
The input streams in question are file input streams, although conceptually I don't know if that changes anything. I am hoping to find something equivalent to
$ cat file1 file2 file3 ... > alldata
and then reading alldata.
Is there a Boost class which implements such a thing? I know that this is a pretty simple concept, and therefore it's just a small matter of programming, but I'm hoping that someone has already worked out the details.
It's not streams, but you might find this (and related) of interest (in particular the scatter/gather section right at the bottom): https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/buffer.h... Having said that, while ASIO does provide file streams as well, this is sort of opposite to your use case, and it doesn't directly address what you're looking for. Still, it would be possible to use similar techniques to write your own multi-stream that could be read as if it were one stream. Although writing ASIO integrations is not for the faint of heart, so this is likely overkill unless you're already wanting to mix in ASIO for other reasons.