Skip to content

FEATURE: Make more tools read stdin for input #59

Open
@DrMcCoy

Description

@DrMcCoy

(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:

  1. 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)?
  2. Change all uses of skip() with a negative parameter to use that new method
  3. Change SeekableReadStream::skip() to take an unsigned value and mandate it to only skip forwards
  4. 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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions