(Split from #58)
Which tools exactly do you need to be able to read from stdin?
Many (Most? All? of the tools that can read textual data should already be able to read from stdin.
Many (Most? All?) of the tools that read binary data currently don't, because they need SeekableReadStreams, and stdin obviously isn't seekable. However, often this is only used for SeekableReadStream::skip() and only in a forward direction.
So I could probably fix that by:
- Introduce a companion method to
skip() that seeks backwards. Though I'm not sure what to call it. rewind()? Or rather rewind() is seek(0, kOriginBegin), while rewind(size_t n) is seek(-n, kOriginCurrent)?
- Change all uses of
skip() with a negative parameter to use that new method
- Change
SeekableReadStream::skip() to take an unsigned value and mandate it to only skip forwards
- Add a virtual method
skip in ReadStream that implements it using read(). SeekableReadStream still overrides it with the seek()-using-implementation
That would give us a ReadStream that can do skip() and we might be able to downgrade some uses of SeekableReadStream to ReadStream instead, which means we can use StdInStream there.
I would need to evaluate that on a case-by-case basis, though.
Thoughts?
(Split from #58)
Which tools exactly do you need to be able to read from stdin?
Many (Most? All? of the tools that can read textual data should already be able to read from stdin.
Many (Most? All?) of the tools that read binary data currently don't, because they need
SeekableReadStreams, and stdin obviously isn't seekable. However, often this is only used forSeekableReadStream::skip()and only in a forward direction.So I could probably fix that by:
skip()that seeks backwards. Though I'm not sure what to call it.rewind()? Or ratherrewind()isseek(0, kOriginBegin), whilerewind(size_t n)isseek(-n, kOriginCurrent)?skip()with a negative parameter to use that new methodSeekableReadStream::skip()to take an unsigned value and mandate it to only skip forwardsskipinReadStreamthat implements it usingread().SeekableReadStreamstill overrides it with theseek()-using-implementationThat would give us a
ReadStreamthat can doskip()and we might be able to downgrade some uses ofSeekableReadStreamtoReadStreaminstead, which means we can useStdInStreamthere.I would need to evaluate that on a case-by-case basis, though.
Thoughts?